Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 10
refactor skin selection#894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
63880ce47fac0e3e10a425e1243779bbd874710dad88af7eca6a9fda3077c2b9e3d46b4b51592ee479522f4b06d986354a7fb22c49479d62de526ea2f96b13d0a19fe83a221669e5b70File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,15 +3,15 @@ | ||
| <v-card-title>Set Skin</v-card-title> | ||
| <v-card-text> | ||
| <v-select | ||
| :items="items" | ||
| :items="skins" | ||
| label="Skin" | ||
| placeholder="Pick a Skin" | ||
| hint="The default skin is Vector." | ||
| persistent-hint | ||
| prepend-icon="mdi-web" | ||
| v-model="skin" | ||
| :disabled="inFlight" | ||
deer-wmde marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| :error-messages="error" | ||
| v-model="skinId" | ||
| ></v-select> | ||
| </v-card-text> | ||
| <v-card-actions> | ||
| @@ -22,45 +22,62 @@ | ||
| <span>It may take up to 10 seconds for changes to be reflected on your wiki</span> | ||
| </v-tooltip> | ||
| </v-card-actions> | ||
| <Message ref="message" /> | ||
| </v-card> | ||
| </template> | ||
| <script> | ||
| import Message from '../Features/Message.vue' | ||
| export default { | ||
| name: 'Skin', | ||
| components: { | ||
| Message | ||
| }, | ||
| props: [ | ||
| 'wikiId' | ||
| ], | ||
| data () { | ||
| return { | ||
| items: [ | ||
| 'Vector', | ||
| 'Modern', | ||
| 'Timeless' | ||
| skins: [ | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right, so we removed them again because they are not ready to be used yet. After our next mediawiki update we will be able to include them here. Until then I changed this PR so that it's just some code refactoring, basically preparation to add them in the future + reuse of the snackbar for alerts Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see I will then merge this | ||
| { | ||
| value: 'vector', | ||
| text: 'Vector' | ||
| }, | ||
| { | ||
| value: 'modern', | ||
| text: 'Modern' | ||
| }, | ||
| { | ||
| value: 'timeless', | ||
| text: 'Timeless' | ||
| } | ||
| ], | ||
| skin: '', | ||
| inFlight: false, | ||
| error: '' | ||
| skinId: '', | ||
| message: false | ||
| } | ||
| }, | ||
| created () { | ||
| const skin = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin | ||
| this.skin = skin.charAt(0).toUpperCase() + skin.slice(1) | ||
| this.skinId = this.$store.state.wikis.currentWikiSettings.wgDefaultSkin | ||
| }, | ||
| computed: { | ||
| skin () { | ||
| return this.skins.find(skin => skin.value === this.skinId) | ||
| } | ||
| }, | ||
| methods: { | ||
| doSetSkin () { | ||
| const wiki = this.wikiId | ||
| // API needs the skin ID which is lower case.. | ||
| const value = this.skin.toLowerCase() | ||
| const value = this.skin.value | ||
| this.$store | ||
| .dispatch('updateSkin', { wiki, value }) | ||
| .then(() => { | ||
| alert('Update success!') | ||
| this.$refs.message.show('success', `Your default skin has been updated to ${this.skin.text}.`) | ||
| }) | ||
| .catch(err => { | ||
| console.log(err.response) | ||
| alert('Something went wrong.') | ||
| console.error(err.response) | ||
| this.$refs.message.show('error', 'Something went wrong while updating your default skin. Please try again.') | ||
| }) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <template> | ||
| <v-snackbar :color="status" elevation="24" v-model="visible"> | ||
| {{ text }} | ||
| <template v-slot:action> | ||
| <v-btn | ||
| text | ||
| variant="text" | ||
| @click="hide" | ||
| > | ||
| Close | ||
| </v-btn> | ||
| </template> | ||
| </v-snackbar> | ||
| </template> | ||
| <script> | ||
| export default { | ||
| data () { | ||
| return { | ||
| visible: false, | ||
| text: 'Hello, this is a snackbar message!', | ||
| status: 'success' | ||
| } | ||
| }, | ||
| methods: { | ||
| show (status, message) { | ||
| this.status = status | ||
| this.text = message | ||
| this.visible = true | ||
| }, | ||
| hide () { | ||
| this.visible = false | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
| <style scoped> | ||
| </style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://v2.vuejs.org/v2/guide/components#Passing-Data-to-Child-Components-with-Props
I believe generally it's recommended to use props rather than
$refsto pass data down to child components. Did you try this and find it wasn't possible?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah I'm just a vue noob, will adjust soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just looked at the docs, I'm not just passing data but calling a method, not sure if there would be another way then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could argue that we shouldnt know about the method and design the component in a way that changing the properties calls the method, but now I'm way out of bounds of my knowledge about vue architecture