Skip to content

Commit

Permalink
refactor skin Card
Browse files Browse the repository at this point in the history
  • Loading branch information
deer-wmde committed Sep 24, 2024
1 parent f32972c commit 63880ce
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions src/components/Pages/ManageWiki/Cards/Skin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
:items="items"
label="Skin"
placeholder="Pick a Skin"
hint="The default skin is Vector."
hint="The default skin is Vector legacy (2010)."
persistent-hint
prepend-icon="mdi-web"
v-model="skin"
:disabled="inFlight"
:error-messages="error"
></v-select>
</v-card-text>
<v-card-actions>
Expand All @@ -22,6 +20,18 @@
<span>It may take up to 10 seconds for changes to be reflected on your wiki</span>
</v-tooltip>
</v-card-actions>
<v-snackbar :color="message.status" elevation="24" v-model="message.show">
{{ message.text }}
<template v-slot:action>
<v-btn
text
variant="text"
@click="message.show = false"
>
Close
</v-btn>
</template>
</v-snackbar>
</v-card>
</template>

Expand All @@ -33,35 +43,45 @@ export default {
],
data () {
return {
items: [
'Vector',
'Modern',
'Timeless'
],
skins: {
'Vector legacy (2010)':'vector',

Check failure on line 47 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before value for key 'Vector legacy (2010)'
'Vector (2022)':'vector-2022',

Check failure on line 48 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before value for key 'Vector (2022)'
'MinervaNeue':'minerva',

Check failure on line 49 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Unnecessarily quoted property 'MinervaNeue' found

Check failure on line 49 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before value for key 'MinervaNeue'
'Modern':'modern',

Check failure on line 50 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Unnecessarily quoted property 'Modern' found

Check failure on line 50 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before value for key 'Modern'
'Timeless':'timeless'

Check failure on line 51 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Unnecessarily quoted property 'Timeless' found

Check failure on line 51 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before value for key 'Timeless'
},
skin: '',
inFlight: false,
error: ''
message: false
}
},
computed: {
items() {

Check failure on line 58 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses
return Object.entries(this.skins).map(([key, value]) => key);

Check failure on line 59 in src/components/Pages/ManageWiki/Cards/Skin.vue

View workflow job for this annotation

GitHub Actions / build (22)

Extra semicolon
}
},
created () {
const skin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin
this.skin = skin.charAt(0).toUpperCase() + skin.slice(1)
this.skin = Object.entries(this.skins).find(
([key, value]) => value === skin
)?.[0]; // use first result from 'find' if it exists
},
methods: {
doSetSkin () {
const wiki = this.wikiId
// API needs the skin ID which is lower case..
const value = this.skin.toLowerCase()
const value = this.skins[this.skin]
this.$store
.dispatch('updateSkin', { wiki, value })
.then(() => {
alert('Update success!')
this.showMessage('success', 'Your default skin has been updated.')
})
.catch(err => {
console.log(err.response)
alert('Something went wrong.')
this.showMessage('error', `Something went wrong while saving your default skin. Please try again.`)
})
},
showMessage (status, message) {
this.message = { status: status, text: message, show: true }
}
}
}
Expand Down

0 comments on commit 63880ce

Please sign in to comment.