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.

appManagement.vue 4.6KB

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. mounted() {
  25. if (this.app.groups.length > 0) {
  26. this.groupCheckedAppsData = true;
  27. }
  28. },
  29. computed: {
  30. appGroups() {
  31. return this.app.groups.map(group => {return {id: group, name: group}});
  32. },
  33. loading() {
  34. let self = this;
  35. return function(id) {
  36. return self.$store.getters.loading(id);
  37. }
  38. },
  39. installing() {
  40. return this.$store.getters.loading('install');
  41. },
  42. enableButtonText() {
  43. if (this.app.needsDownload) {
  44. return t('settings', 'Download and enable');
  45. }
  46. return t('settings', 'Enable');
  47. },
  48. forceEnableButtonText() {
  49. if (this.app.needsDownload) {
  50. return t('settings', 'Enable untested app');
  51. }
  52. return t('settings', 'Enable untested app');
  53. },
  54. enableButtonTooltip() {
  55. if (this.app.needsDownload) {
  56. return t('settings','The app will be downloaded from the app store');
  57. }
  58. return false;
  59. },
  60. forceEnableButtonTooltip() {
  61. 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.');
  62. if (this.app.needsDownload) {
  63. return base + ' ' + t('settings','The app will be downloaded from the app store');
  64. }
  65. return base;
  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. let groups = this.app.groups.concat([]).concat([group.id]);
  95. this.$store.dispatch('enableApp', { appId: this.app.id, groups: groups});
  96. },
  97. removeGroupLimitation(group) {
  98. let currentGroups = this.app.groups.concat([]);
  99. let 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>