AppManagement.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!--
  2. - @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  3. -
  4. - @author Julius Härtl <jus@bitgrid.net>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -
  21. -->
  22. <script>
  23. export default {
  24. computed: {
  25. appGroups() {
  26. return this.app.groups.map(group => { return { id: group, name: group } })
  27. },
  28. loading() {
  29. const self = this
  30. return function(id) {
  31. return self.$store.getters.loading(id)
  32. }
  33. },
  34. installing() {
  35. return this.$store.getters.loading('install')
  36. },
  37. enableButtonText() {
  38. if (this.app.needsDownload) {
  39. return t('settings', 'Download and enable')
  40. }
  41. return t('settings', 'Enable')
  42. },
  43. forceEnableButtonText() {
  44. if (this.app.needsDownload) {
  45. return t('settings', 'Enable untested app')
  46. }
  47. return t('settings', 'Enable untested app')
  48. },
  49. enableButtonTooltip() {
  50. if (this.app.needsDownload) {
  51. return t('settings', 'The app will be downloaded from the app store')
  52. }
  53. return false
  54. },
  55. forceEnableButtonTooltip() {
  56. const base = t('settings', 'This app is not marked as compatible with your Nextcloud version. If you continue you will still be able to install the app. Note that the app might not work as expected.')
  57. if (this.app.needsDownload) {
  58. return base + ' ' + t('settings', 'The app will be downloaded from the app store')
  59. }
  60. return base
  61. },
  62. },
  63. mounted() {
  64. if (this.app.groups.length > 0) {
  65. this.groupCheckedAppsData = true
  66. }
  67. },
  68. methods: {
  69. asyncFindGroup(query) {
  70. return this.$store.dispatch('getGroups', { search: query, limit: 5, offset: 0 })
  71. },
  72. isLimitedToGroups(app) {
  73. if (this.app.groups.length || this.groupCheckedAppsData) {
  74. return true
  75. }
  76. return false
  77. },
  78. setGroupLimit: function() {
  79. if (!this.groupCheckedAppsData) {
  80. this.$store.dispatch('enableApp', { appId: this.app.id, groups: [] })
  81. }
  82. },
  83. canLimitToGroups(app) {
  84. if ((app.types && app.types.includes('filesystem'))
  85. || app.types.includes('prelogin')
  86. || app.types.includes('authentication')
  87. || app.types.includes('logging')
  88. || app.types.includes('prevent_group_restriction')) {
  89. return false
  90. }
  91. return true
  92. },
  93. addGroupLimitation(group) {
  94. const groups = this.app.groups.concat([]).concat([group.id])
  95. this.$store.dispatch('enableApp', { appId: this.app.id, groups: groups })
  96. },
  97. removeGroupLimitation(group) {
  98. const currentGroups = this.app.groups.concat([])
  99. const index = currentGroups.indexOf(group.id)
  100. if (index > -1) {
  101. currentGroups.splice(index, 1)
  102. }
  103. this.$store.dispatch('enableApp', { appId: this.app.id, groups: currentGroups })
  104. },
  105. forceEnable(appId) {
  106. this.$store.dispatch('forceEnableApp', { appId: appId, groups: [] })
  107. .then((response) => { OC.Settings.Apps.rebuildNavigation() })
  108. .catch((error) => { OC.Notification.show(error) })
  109. },
  110. enable(appId) {
  111. this.$store.dispatch('enableApp', { appId: appId, groups: [] })
  112. .then((response) => { OC.Settings.Apps.rebuildNavigation() })
  113. .catch((error) => { OC.Notification.show(error) })
  114. },
  115. disable(appId) {
  116. this.$store.dispatch('disableApp', { appId: appId })
  117. .then((response) => { OC.Settings.Apps.rebuildNavigation() })
  118. .catch((error) => { OC.Notification.show(error) })
  119. },
  120. remove(appId) {
  121. this.$store.dispatch('uninstallApp', { appId: appId })
  122. .then((response) => { OC.Settings.Apps.rebuildNavigation() })
  123. .catch((error) => { OC.Notification.show(error) })
  124. },
  125. install(appId) {
  126. this.$store.dispatch('enableApp', { appId: appId })
  127. .then((response) => { OC.Settings.Apps.rebuildNavigation() })
  128. .catch((error) => { OC.Notification.show(error) })
  129. },
  130. update(appId) {
  131. this.$store.dispatch('updateApp', { appId: appId })
  132. .then((response) => { OC.Settings.Apps.rebuildNavigation() })
  133. .catch((error) => { OC.Notification.show(error) })
  134. },
  135. },
  136. }
  137. </script>