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.

AppStore.vue 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!--
  2. - @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  3. -
  4. - @author Julius Härtl <jus@bitgrid.net>
  5. - @author Ferdinand Thiessen <opensource@fthiessen.de>
  6. -
  7. - @license AGPL-3.0-or-later
  8. -
  9. - This program is free software: you can redistribute it and/or modify
  10. - it under the terms of the GNU Affero General Public License as
  11. - published by the Free Software Foundation, either version 3 of the
  12. - License, or (at your option) any later version.
  13. -
  14. - This program is distributed in the hope that it will be useful,
  15. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. - GNU Affero General Public License for more details.
  18. -
  19. - You should have received a copy of the GNU Affero General Public License
  20. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. -
  22. -->
  23. <template>
  24. <!-- Apps list -->
  25. <NcAppContent class="app-settings-content"
  26. :page-heading="appStoreLabel">
  27. <h2 class="app-settings-content__label" v-text="viewLabel" />
  28. <AppStoreDiscoverSection v-if="currentCategory === 'discover'" />
  29. <NcEmptyContent v-else-if="isLoading"
  30. class="empty-content__loading"
  31. :name="t('settings', 'Loading app list')">
  32. <template #icon>
  33. <NcLoadingIcon :size="64" />
  34. </template>
  35. </NcEmptyContent>
  36. <AppList v-else :category="currentCategory" />
  37. </NcAppContent>
  38. </template>
  39. <script setup lang="ts">
  40. import { translate as t } from '@nextcloud/l10n'
  41. import { computed, getCurrentInstance, onBeforeMount, watchEffect } from 'vue'
  42. import { useRoute } from 'vue-router/composables'
  43. import { useAppsStore } from '../store/apps-store'
  44. import { APPS_SECTION_ENUM } from '../constants/AppsConstants'
  45. import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js'
  46. import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
  47. import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
  48. import AppList from '../components/AppList.vue'
  49. import AppStoreDiscoverSection from '../components/AppStoreDiscover/AppStoreDiscoverSection.vue'
  50. const route = useRoute()
  51. const store = useAppsStore()
  52. /**
  53. * ID of the current active category, default is `discover`
  54. */
  55. const currentCategory = computed(() => route.params?.category ?? 'discover')
  56. const appStoreLabel = t('settings', 'App Store')
  57. const viewLabel = computed(() => APPS_SECTION_ENUM[currentCategory.value] ?? store.getCategoryById(currentCategory.value)?.displayName ?? appStoreLabel)
  58. watchEffect(() => {
  59. window.document.title = `${viewLabel.value} - ${appStoreLabel} - Nextcloud`
  60. })
  61. // TODO this part should be migrated to pinia
  62. const instance = getCurrentInstance()
  63. /** Is the app list loading */
  64. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  65. const isLoading = computed(() => (instance?.proxy as any).$store.getters.loading('list'))
  66. onBeforeMount(() => {
  67. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  68. (instance?.proxy as any).$store.dispatch('getCategories', { shouldRefetchCategories: true });
  69. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  70. (instance?.proxy as any).$store.dispatch('getAllApps')
  71. })
  72. </script>
  73. <style scoped>
  74. .empty-content__loading {
  75. height: 100%;
  76. }
  77. .app-settings-content__label {
  78. margin-block-start: var(--app-navigation-padding);
  79. margin-inline-start: calc(var(--default-clickable-area) + var(--app-navigation-padding) * 2);
  80. min-height: var(--default-clickable-area);
  81. line-height: var(--default-clickable-area);
  82. vertical-align: center;
  83. }
  84. </style>