You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
4.3 KiB

5 years ago
5 years ago
5 years ago
  1. <template lang='pug'>
  2. v-card
  3. v-toolbar(flat, color='primary', dark, dense)
  4. .subtitle-1 {{ $t('admin:utilities.contentTitle') }}
  5. v-card-text
  6. .subtitle-1.pb-3.primary--text Rebuild Page Tree
  7. .body-2 The virtual structure of your wiki is automatically inferred from all page paths. You can trigger a full rebuild of the tree if some virtual folders are missing or not valid anymore.
  8. v-btn(outlined, color='primary', @click='rebuildTree', :disabled='loading').ml-0.mt-3
  9. v-icon(left) mdi-gesture-double-tap
  10. span Proceed
  11. v-divider.my-5
  12. .subtitle-1.pb-3.pl-0.primary--text Migrate all pages to target locale
  13. .body-2 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.
  14. .body-2.red--text: strong This operation is destructive and cannot be reversed! Make sure you have proper backups!
  15. v-toolbar.radius-7.mt-5(flat, :color='$vuetify.theme.dark ? `grey darken-3-d5` : `grey lighten-4`', height='80')
  16. v-select(
  17. label='Source Locale'
  18. outlined
  19. hide-details
  20. :items='locales'
  21. item-text='name'
  22. item-value='code'
  23. v-model='sourceLocale'
  24. )
  25. v-icon.mx-3(large) mdi-chevron-right-box-outline
  26. v-select(
  27. label='Target Locale'
  28. outlined
  29. hide-details
  30. :items='locales'
  31. item-text='name'
  32. item-value='code'
  33. v-model='targetLocale'
  34. )
  35. .body-2.mt-5 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 page, you must first delete it.
  36. v-btn(outlined, color='primary', @click='migrateToLocale', :disabled='loading').ml-0.mt-3
  37. v-icon(left) mdi-gesture-double-tap
  38. span Proceed
  39. </template>
  40. <script>
  41. import _ from 'lodash'
  42. import utilityContentMigrateLocaleMutation from 'gql/admin/utilities/utilities-mutation-content-migratelocale.gql'
  43. import utilityContentRebuildTreeMutation from 'gql/admin/utilities/utilities-mutation-content-rebuildtree.gql'
  44. /* global siteLangs, siteConfig */
  45. export default {
  46. data: () => {
  47. return {
  48. loading: false,
  49. sourceLocale: '',
  50. targetLocale: ''
  51. }
  52. },
  53. computed: {
  54. currentLocale () {
  55. return siteConfig.lang
  56. },
  57. locales () {
  58. return siteLangs
  59. }
  60. },
  61. methods: {
  62. async rebuildTree () {
  63. this.loading = true
  64. this.$store.commit(`loadingStart`, 'admin-utilities-content-rebuildtree')
  65. try {
  66. const respRaw = await this.$apollo.mutate({
  67. mutation: utilityContentRebuildTreeMutation
  68. })
  69. const resp = _.get(respRaw, 'data.pages.rebuildTree.responseResult', {})
  70. if (resp.succeeded) {
  71. this.$store.commit('showNotification', {
  72. message: 'Page Tree rebuilt successfully.',
  73. style: 'success',
  74. icon: 'check'
  75. })
  76. } else {
  77. throw new Error(resp.message)
  78. }
  79. } catch (err) {
  80. this.$store.commit('pushGraphError', err)
  81. }
  82. this.$store.commit(`loadingStop`, 'admin-utilities-content-rebuildtree')
  83. this.loading = false
  84. },
  85. async migrateToLocale () {
  86. this.loading = true
  87. this.$store.commit(`loadingStart`, 'admin-utilities-content-migratelocale')
  88. try {
  89. const respRaw = await this.$apollo.mutate({
  90. mutation: utilityContentMigrateLocaleMutation,
  91. variables: {
  92. sourceLocale: this.sourceLocale,
  93. targetLocale: this.targetLocale
  94. }
  95. })
  96. const resp = _.get(respRaw, 'data.pages.migrateToLocale.responseResult', {})
  97. if (resp.succeeded) {
  98. this.$store.commit('showNotification', {
  99. message: `Migrated ${_.get(respRaw, 'data.pages.migrateToLocale.count', 0)} page(s) to target locale successfully.`,
  100. style: 'success',
  101. icon: 'check'
  102. })
  103. } else {
  104. throw new Error(resp.message)
  105. }
  106. } catch (err) {
  107. this.$store.commit('pushGraphError', err)
  108. }
  109. this.$store.commit(`loadingStop`, 'admin-utilities-content-migratelocale')
  110. this.loading = false
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang='scss'>
  116. </style>