mirror of
https://github.com/romancm/gamebrary
synced 2024-12-18 15:23:14 +00:00
removed legacy boards
This commit is contained in:
parent
f3e57015d6
commit
c3d22d8c0f
1 changed files with 1 additions and 137 deletions
|
@ -51,61 +51,12 @@
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
</b-card>
|
</b-card>
|
||||||
|
|
||||||
<b-card
|
|
||||||
no-body
|
|
||||||
border-variant="warning"
|
|
||||||
class="clickable mt-3"
|
|
||||||
v-for="platform in ownedPlatforms"
|
|
||||||
:key="platform.id"
|
|
||||||
@click="openDeprecationWarning(platform)"
|
|
||||||
>
|
|
||||||
<b-card-body>
|
|
||||||
<h4 class="mb-2">
|
|
||||||
{{ platform.name }}
|
|
||||||
<b-badge variant="warning">{{ $t('boards.deprecated') }}</b-badge>
|
|
||||||
</h4>
|
|
||||||
</b-card-body>
|
|
||||||
</b-card>
|
|
||||||
|
|
||||||
<b-modal
|
|
||||||
id="deprecation-warning"
|
|
||||||
:title="tempPlatform && tempPlatform.name ? tempPlatform.name : 'Migration warning'"
|
|
||||||
hide-footer
|
|
||||||
@hidden="resetLegacyPlatform"
|
|
||||||
>
|
|
||||||
<b-alert show variant="warning">
|
|
||||||
<h4>Deprecation warning</h4>
|
|
||||||
<p>Platform-based boards will be phased out soon</p>
|
|
||||||
<p>Please click the button below to convert this platform into a board.</p>
|
|
||||||
<p>If you have any questions or need help feel free to email
|
|
||||||
<strong>contact@gamebrary.com</strong> and/or open defects in
|
|
||||||
<a href="https://github.com/romancm/gamebrary/issues" target="_blank">GitHub</a></p>
|
|
||||||
</b-alert>
|
|
||||||
|
|
||||||
<b-button
|
|
||||||
variant="success"
|
|
||||||
@click="convertLegacyBoard({ tempPlatform, migratePlatform })"
|
|
||||||
:disabled="saving"
|
|
||||||
>
|
|
||||||
<b-spinner small v-if="saving" />
|
|
||||||
<span v-else>Convert to board</span>
|
|
||||||
</b-button>
|
|
||||||
|
|
||||||
<b-button
|
|
||||||
variant="danger"
|
|
||||||
@click="deleteLegacyPlatform(tempPlatform)"
|
|
||||||
>
|
|
||||||
Delete legacy board
|
|
||||||
</b-button>
|
|
||||||
</b-modal>
|
|
||||||
</b-overlay>
|
</b-overlay>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CreateBoard from '@/components/Board/CreateBoard';
|
import CreateBoard from '@/components/Board/CreateBoard';
|
||||||
import legacyPlatforms from '@/platforms';
|
|
||||||
|
|
||||||
import { mapState, mapGetters } from 'vuex';
|
import { mapState, mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
@ -117,23 +68,16 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
tempPlatform: null,
|
|
||||||
migratePlatform: null,
|
|
||||||
saving: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['boards', 'platforms', 'platformNames', 'wallpapers', 'gameLists', 'settings']),
|
...mapState(['boards', 'wallpapers', 'gameLists', 'settings']),
|
||||||
...mapGetters(['platformNames', 'sortedBoards', 'nightMode']),
|
...mapGetters(['platformNames', 'sortedBoards', 'nightMode']),
|
||||||
|
|
||||||
hasLists() {
|
hasLists() {
|
||||||
return Object.keys(this.gameLists).length > 0;
|
return Object.keys(this.gameLists).length > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
ownedPlatforms() {
|
|
||||||
return legacyPlatforms.filter(({ code }) => this.gameLists[code]);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -146,86 +90,6 @@ export default {
|
||||||
this.loadPlatforms();
|
this.loadPlatforms();
|
||||||
},
|
},
|
||||||
|
|
||||||
async convertLegacyBoard({ tempPlatform, migratePlatform }) {
|
|
||||||
this.saving = true;
|
|
||||||
|
|
||||||
const lists = migratePlatform.map(({ games, name }) => {
|
|
||||||
const list = {
|
|
||||||
name,
|
|
||||||
games,
|
|
||||||
settings: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
return list;
|
|
||||||
});
|
|
||||||
|
|
||||||
const { id } = tempPlatform;
|
|
||||||
|
|
||||||
const parsedPlatforms = isNaN(id) && id.includes(',')
|
|
||||||
? id.split(',').map(platformId => Number(platformId))
|
|
||||||
: [id];
|
|
||||||
|
|
||||||
const newBoard = {
|
|
||||||
description: '',
|
|
||||||
lists,
|
|
||||||
name: tempPlatform.name,
|
|
||||||
platforms: parsedPlatforms,
|
|
||||||
theme: null,
|
|
||||||
wallpaper: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
await this.$store.dispatch('CREATE_BOARD', newBoard)
|
|
||||||
.catch(() => {
|
|
||||||
this.saving = false;
|
|
||||||
this.$bvToast.toast('There was an error creating board', { title: 'Error', variant: 'error' });
|
|
||||||
});
|
|
||||||
|
|
||||||
this.saving = false;
|
|
||||||
this.$bvToast.toast('Board converted', { title: 'Success', variant: 'success' });
|
|
||||||
this.$bvModal.hide('deprecation-warning');
|
|
||||||
this.showDeleteLegacyPlatform(tempPlatform);
|
|
||||||
},
|
|
||||||
|
|
||||||
showDeleteLegacyPlatform(tempPlatform) {
|
|
||||||
this.$bvModal.msgBoxConfirm('You can now safely delete your legacy platform', {
|
|
||||||
title: 'Board converted',
|
|
||||||
okVariant: 'danger',
|
|
||||||
cancelTitle: 'Dismiss',
|
|
||||||
okTitle: 'Delete legacy board',
|
|
||||||
})
|
|
||||||
.then((value) => {
|
|
||||||
if (value) {
|
|
||||||
this.deleteLegacyPlatform(tempPlatform);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
openDeprecationWarning(platform) {
|
|
||||||
this.migratePlatform = this.gameLists[platform.code];
|
|
||||||
this.tempPlatform = platform;
|
|
||||||
this.$bvModal.show('deprecation-warning');
|
|
||||||
},
|
|
||||||
|
|
||||||
resetLegacyPlatform() {
|
|
||||||
this.tempPlatform = null;
|
|
||||||
this.migratePlatform = null;
|
|
||||||
},
|
|
||||||
|
|
||||||
deleteLegacyPlatform(platform) {
|
|
||||||
this.$store.commit('SET_ACTIVE_PLATFORM_LEGACY', platform);
|
|
||||||
|
|
||||||
this.$store.commit('REMOVE_PLATFORM_LEGACY');
|
|
||||||
|
|
||||||
this.$store.dispatch('SAVE_LEGACY_LISTS', this.gameLists)
|
|
||||||
.then(() => {
|
|
||||||
this.$bvModal.hide('deprecation-warning');
|
|
||||||
this.$bvToast.toast('Legacy board deleted', { title: 'Success', variant: 'success' });
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$store.commit('SET_SESSION_EXPIRED', true);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
getWallpaper({ wallpaper, name }) {
|
getWallpaper({ wallpaper, name }) {
|
||||||
const boardWallpaper = this.wallpapers.find(({ fullPath }) => fullPath === wallpaper);
|
const boardWallpaper = this.wallpapers.find(({ fullPath }) => fullPath === wallpaper);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue