From 63880cec610fc7ef00b3787baf5c17a658a8b6a0 Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 24 Sep 2024 19:49:05 +0200 Subject: [PATCH 01/21] refactor skin Card --- .../Pages/ManageWiki/Cards/Skin.vue | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index e6264ff0..2dc76a58 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -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" > @@ -22,6 +20,18 @@ It may take up to 10 seconds for changes to be reflected on your wiki + + {{ message.text }} + + @@ -33,35 +43,45 @@ export default { ], data () { return { - items: [ - 'Vector', - 'Modern', - 'Timeless' - ], + skins: { + 'Vector legacy (2010)':'vector', + 'Vector (2022)':'vector-2022', + 'MinervaNeue':'minerva', + 'Modern':'modern', + 'Timeless':'timeless' + }, skin: '', - inFlight: false, - error: '' + message: false + } + }, + computed: { + items() { + return Object.entries(this.skins).map(([key, value]) => key); } }, 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 } } } } From 47fac0e7a6e311bf03c605c281d89b50a47c36de Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 24 Sep 2024 20:11:32 +0200 Subject: [PATCH 02/21] formatting --- src/components/Pages/ManageWiki/Cards/Skin.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index 2dc76a58..d35b3f94 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -44,11 +44,11 @@ export default { data () { return { skins: { - 'Vector legacy (2010)':'vector', - 'Vector (2022)':'vector-2022', - 'MinervaNeue':'minerva', - 'Modern':'modern', - 'Timeless':'timeless' + 'Vector legacy (2010)': 'vector', + 'Vector (2022)': 'vector-2022', + MinervaNeue: 'minerva', + Modern: 'modern', + Timeless: 'timeless' }, skin: '', message: false @@ -56,14 +56,14 @@ export default { }, computed: { items() { - return Object.entries(this.skins).map(([key, value]) => key); + return Object.entries(this.skins).map(([key, value]) => key) } }, created () { const skin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin this.skin = Object.entries(this.skins).find( ([key, value]) => value === skin - )?.[0]; // use first result from 'find' if it exists + )?.[0] // use first result from 'find' if it exists }, methods: { doSetSkin () { @@ -77,7 +77,7 @@ export default { }) .catch(err => { console.log(err.response) - this.showMessage('error', `Something went wrong while saving your default skin. Please try again.`) + this.showMessage('error', 'Something went wrong while saving your default skin. Please try again.') }) }, showMessage (status, message) { From 3e10a4248177cd73c3f4f9c3be48871f1b72fc6e Mon Sep 17 00:00:00 2001 From: dena Date: Tue, 24 Sep 2024 20:12:57 +0200 Subject: [PATCH 03/21] formatting --- src/components/Pages/ManageWiki/Cards/Skin.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index d35b3f94..1e8c6051 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -55,7 +55,7 @@ export default { } }, computed: { - items() { + items () { return Object.entries(this.skins).map(([key, value]) => key) } }, From 5e124379917ba6dd7d10f12c5b4376a73696276f Mon Sep 17 00:00:00 2001 From: dena <91744937+deer-wmde@users.noreply.github.com> Date: Wed, 25 Sep 2024 07:02:56 +0200 Subject: [PATCH 04/21] Update Skin.vue --- src/components/Pages/ManageWiki/Cards/Skin.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index 1e8c6051..92791902 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -63,7 +63,7 @@ export default { const skin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin this.skin = Object.entries(this.skins).find( ([key, value]) => value === skin - )?.[0] // use first result from 'find' if it exists + )?.[0] // use key from 'find' result if it not undefined, see `skins` object above }, methods: { doSetSkin () { From 79bbd874cf3631d7663517d3c865b8e52ab9b47e Mon Sep 17 00:00:00 2001 From: dena <91744937+deer-wmde@users.noreply.github.com> Date: Wed, 25 Sep 2024 07:04:27 +0200 Subject: [PATCH 05/21] Update Skin.vue --- src/components/Pages/ManageWiki/Cards/Skin.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index 92791902..de1efc87 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -62,8 +62,8 @@ export default { created () { const skin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin this.skin = Object.entries(this.skins).find( - ([key, value]) => value === skin - )?.[0] // use key from 'find' result if it not undefined, see `skins` object above + ([skinName, skinId]) => skinName === skin + )?.[0] }, methods: { doSetSkin () { From 4710dadc375e00c6344ddc4c78538f9a3bc55c0c Mon Sep 17 00:00:00 2001 From: dena Date: Wed, 25 Sep 2024 07:27:27 +0200 Subject: [PATCH 06/21] improve readability --- .../Pages/ManageWiki/Cards/Skin.vue | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index de1efc87..6f2154ed 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -9,7 +9,7 @@ hint="The default skin is Vector legacy (2010)." persistent-hint prepend-icon="mdi-web" - v-model="skin" + v-model="skinName" > @@ -50,34 +50,34 @@ export default { Modern: 'modern', Timeless: 'timeless' }, - skin: '', + skinName: '', message: false } }, computed: { items () { - return Object.entries(this.skins).map(([key, value]) => key) + return Object.entries(this.skins).map(([skinName, skin]) => skinName) } }, created () { - const skin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin - this.skin = Object.entries(this.skins).find( - ([skinName, skinId]) => skinName === skin + const defaultSkin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin + this.skinName = Object.entries(this.skins).find( + ([skinName, skin]) => defaultSkin === skin )?.[0] }, methods: { doSetSkin () { const wiki = this.wikiId - const value = this.skins[this.skin] + const skin = this.skins[this.skinName] this.$store - .dispatch('updateSkin', { wiki, value }) + .dispatch('updateSkin', { wiki, skin }) .then(() => { - this.showMessage('success', 'Your default skin has been updated.') + this.showMessage('success', `Your default skin has been updated to ${this.skinName}.`) }) .catch(err => { console.log(err.response) - this.showMessage('error', 'Something went wrong while saving your default skin. Please try again.') + this.showMessage('error', 'Something went wrong while updating your default skin. Please try again.') }) }, showMessage (status, message) { From 88af7ec997f62c2c7b3afd7e9d1e3f70b7278179 Mon Sep 17 00:00:00 2001 From: dena Date: Wed, 25 Sep 2024 08:05:49 +0200 Subject: [PATCH 07/21] more refactoring --- .../Pages/ManageWiki/Cards/Skin.vue | 58 ++++++++++++------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index 6f2154ed..ffede1d6 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -3,13 +3,13 @@ Set Skin @@ -43,37 +43,53 @@ export default { ], data () { return { - skins: { - 'Vector legacy (2010)': 'vector', - 'Vector (2022)': 'vector-2022', - MinervaNeue: 'minerva', - Modern: 'modern', - Timeless: 'timeless' - }, - skinName: '', + skins: [ + { + value: 'vector', + text: 'Vector legacy (2010)' + }, + { + value: 'vector-2022', + text: 'Vector (2022)' + }, + { + value: 'minerva', + text: 'MinervaNeue' + }, + { + value: 'modern', + text: 'Modern' + }, + { + value: 'timeless', + text: 'Timeless' + }, + ], + skinId: '', message: false } }, - computed: { - items () { - return Object.entries(this.skins).map(([skinName, skin]) => skinName) - } - }, created () { const defaultSkin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin - this.skinName = Object.entries(this.skins).find( - ([skinName, skin]) => defaultSkin === skin - )?.[0] + this.skinId = this.getSkinBySkinId(defaultSkin).value }, methods: { + getSkinBySkinId (skinId) { + const skin = Object.entries(this.skins).find( + ([key, skinObject]) => skinObject.value === skinId + )?.[1] + + return skin + }, doSetSkin () { const wiki = this.wikiId - const skin = this.skins[this.skinName] + const skin = this.getSkinBySkinId(this.skinId) + const value = skin.value this.$store - .dispatch('updateSkin', { wiki, skin }) + .dispatch('updateSkin', { wiki, value }) .then(() => { - this.showMessage('success', `Your default skin has been updated to ${this.skinName}.`) + this.showMessage('success', `Your default skin has been updated to ${skin.text}.`) }) .catch(err => { console.log(err.response) From a6a9fda1da0340a614f96d9051ce90171164fd0e Mon Sep 17 00:00:00 2001 From: dena Date: Wed, 25 Sep 2024 08:51:05 +0200 Subject: [PATCH 08/21] add Snackbar component --- .../Pages/ManageWiki/Features/Snackbar.vue | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/components/Pages/ManageWiki/Features/Snackbar.vue diff --git a/src/components/Pages/ManageWiki/Features/Snackbar.vue b/src/components/Pages/ManageWiki/Features/Snackbar.vue new file mode 100644 index 00000000..6540a5cc --- /dev/null +++ b/src/components/Pages/ManageWiki/Features/Snackbar.vue @@ -0,0 +1,43 @@ + + + + + From 3077c2b577cef8069f686b73b8c5cd54492b7c19 Mon Sep 17 00:00:00 2001 From: dena Date: Wed, 25 Sep 2024 08:53:38 +0200 Subject: [PATCH 09/21] rename component --- .../Pages/ManageWiki/Features/{Snackbar.vue => Message.vue} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/components/Pages/ManageWiki/Features/{Snackbar.vue => Message.vue} (100%) diff --git a/src/components/Pages/ManageWiki/Features/Snackbar.vue b/src/components/Pages/ManageWiki/Features/Message.vue similarity index 100% rename from src/components/Pages/ManageWiki/Features/Snackbar.vue rename to src/components/Pages/ManageWiki/Features/Message.vue From 9e3d46b5ead99136fa4ea0a9243d8abc64bbcc52 Mon Sep 17 00:00:00 2001 From: dena Date: Wed, 25 Sep 2024 08:54:15 +0200 Subject: [PATCH 10/21] use Message component --- .../Pages/ManageWiki/Cards/Skin.vue | 44 +++++++------------ 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/Skin.vue b/src/components/Pages/ManageWiki/Cards/Skin.vue index ffede1d6..ed14d54d 100644 --- a/src/components/Pages/ManageWiki/Cards/Skin.vue +++ b/src/components/Pages/ManageWiki/Cards/Skin.vue @@ -20,24 +20,18 @@ It may take up to 10 seconds for changes to be reflected on your wiki - - {{ message.text }} - - + From 4b51592233d04760fb87e12a6b6c58b92f5294df Mon Sep 17 00:00:00 2001 From: dena Date: Wed, 25 Sep 2024 08:54:24 +0200 Subject: [PATCH 11/21] use Message component in QuestyCaptcha --- .../Pages/ManageWiki/Cards/QuestyCaptcha.vue | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue b/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue index eacfe365..0beee9f1 100644 --- a/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue +++ b/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue @@ -81,24 +81,18 @@ - - {{ message.text }} - - + diff --git a/src/components/Pages/ManageWiki/Features/Message.vue b/src/components/Pages/ManageWiki/Features/Message.vue index 6540a5cc..2fd1a6e0 100644 --- a/src/components/Pages/ManageWiki/Features/Message.vue +++ b/src/components/Pages/ManageWiki/Features/Message.vue @@ -27,9 +27,6 @@ export default { this.status = status this.text = message this.visible = true - - console.log(message) - console.log(status) }, hide () { From 2f4b06d3e272d9a1d307ae3f2a96d2b7856cfa43 Mon Sep 17 00:00:00 2001 From: dena Date: Wed, 25 Sep 2024 09:00:26 +0200 Subject: [PATCH 13/21] formatting --- .../Pages/ManageWiki/Cards/QuestyCaptcha.vue | 2 +- src/components/Pages/ManageWiki/Cards/Skin.vue | 18 +++++++++--------- .../Pages/ManageWiki/Features/Message.vue | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue b/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue index 0beee9f1..f0d3cac8 100644 --- a/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue +++ b/src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue @@ -86,7 +86,7 @@ diff --git a/src/components/Pages/ManageWiki/Features/Message.vue b/src/components/Pages/ManageWiki/Features/Message.vue index 2fd1a6e0..7d6367a6 100644 --- a/src/components/Pages/ManageWiki/Features/Message.vue +++ b/src/components/Pages/ManageWiki/Features/Message.vue @@ -15,12 +15,12 @@