admin-utilities-content.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template lang='pug'>
  2. v-card
  3. v-toolbar(flat, color='primary', dark, dense)
  4. .subheading {{ $t('admin:utilities.contentTitle') }}
  5. v-card-text
  6. v-subheader.pl-0.primary--text Migrate all pages to base language
  7. .body-1 If you created content before selecting a different locale and activating the namespacing capabilities, you may want to transfer all content to the base locale.
  8. .body-1.red--text: strong This operation is destructive and cannot be reversed! Make sure you have proper backups!
  9. .body-1.mt-3 Based on your current configuration, all pages will be migrated to the locale #[v-chip(label, small): strong {{currentLocale.toUpperCase()}}]
  10. .body-1.mt-3 Pages that are already in the target locale will not be touched. If a page already exists at the target, the source page will not be modified as it would create a conflict. If you want to overwrite the target content, you must first delete that page.
  11. v-btn(outline, color='primary', @click='migrateToLocale', :disabled='loading').ml-0.mt-3
  12. v-icon(left) build
  13. span Proceed
  14. </template>
  15. <script>
  16. import _ from 'lodash'
  17. import utilityContentMigrateLocaleMutation from 'gql/admin/utilities/utilities-mutation-content-migratelocale.gql'
  18. /* global siteLang */
  19. export default {
  20. data: () => {
  21. return {
  22. loading: false
  23. }
  24. },
  25. computed: {
  26. currentLocale() {
  27. return siteConfig.lang
  28. }
  29. },
  30. methods: {
  31. async migrateToLocale() {
  32. this.loading = true
  33. this.$store.commit(`loadingStart`, 'admin-utilities-content-migratelocale')
  34. try {
  35. const respRaw = await this.$apollo.mutate({
  36. mutation: utilityContentMigrateLocaleMutation,
  37. variables: {
  38. targetLocale: siteConfig.lang
  39. }
  40. })
  41. const resp = _.get(respRaw, 'data.pages.migrateToLocale.responseResult', {})
  42. if (resp.succeeded) {
  43. this.$store.commit('showNotification', {
  44. message: 'Migrated all content to target locale successfully.',
  45. style: 'success',
  46. icon: 'check'
  47. })
  48. } else {
  49. throw new Error(resp.message)
  50. }
  51. } catch (err) {
  52. this.$store.commit('pushGraphError', err)
  53. }
  54. this.$store.commit(`loadingStop`, 'admin-utilities-content-migratelocale')
  55. this.loading = false
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang='scss'>
  61. </style>