From f58dedf5533a7286d38d7feea465d28c13729fdc Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 4 May 2025 13:11:05 +0200 Subject: [PATCH 1/4] fix(build): define appName to fix this error: "The '@nextcloud/vue' library was used without setting / replacing the 'appName'" --- webpack.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index d9876e8..0c16d61 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -77,6 +77,10 @@ module.exports = { new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'], }), + + new webpack.DefinePlugin({ + appName: JSON.stringify(appName), + }), ], resolve: { From cd4b3b1054af9d163b5391e10f670155dd48d993 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 4 May 2025 18:24:32 +0200 Subject: [PATCH 2/4] fix #349: add custom controller to retrieve core apps --- lib/Controller/CoreController.php | 74 +++++++++++++++++++++++++++++++ src/menus/StandardMenu.vue | 9 ++-- src/store/nav.js | 5 +-- 3 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 lib/Controller/CoreController.php diff --git a/lib/Controller/CoreController.php b/lib/Controller/CoreController.php new file mode 100644 index 0000000..9302ef3 --- /dev/null +++ b/lib/Controller/CoreController.php @@ -0,0 +1,74 @@ +. + */ + +namespace OCA\SideMenu\Controller; + +use OCA\SideMenu\Service\AppRepository; +use OCA\SideMenu\Service\ConfigProxy; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\FrontpageRoute; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; +use OCP\AppFramework\Http\Attribute\PublicPage; +use OCP\AppFramework\Http\JSONResponse; +use OCP\IRequest; +use OCP\IUserSession; + +class CoreController extends Controller +{ + public function __construct( + string $appName, + IRequest $request, + protected ConfigProxy $config, + protected AppRepository $appRepository, + ) { + parent::__construct($appName, $request); + } + + #[NoCSRFRequired] + #[NoAdminRequired] + #[PublicPage] + #[FrontpageRoute(verb: 'GET', url: '/core/apps')] + public function items(): JSONResponse + { + $user = \OC::$server[IUserSession::class]->getUser(); + $items = []; + + if (!$user) { + return new JSONResponse([ + 'items' => $items, + ]); + } + + $apps = $this->appRepository->getOrderedApps($user); + $keys = ['id', 'name', 'category', 'href', 'icon']; + + foreach ($apps as &$app) { + foreach ($app as $key => $value) { + if (!in_array($key, $keys)) { + unset($app[$key]); + } + } + } + + return new JSONResponse([ + 'items' => $apps, + ]); + } +} diff --git a/src/menus/StandardMenu.vue b/src/menus/StandardMenu.vue index fb16b59..81b9ff9 100644 --- a/src/menus/StandardMenu.vue +++ b/src/menus/StandardMenu.vue @@ -33,7 +33,7 @@ along with this program. If not, see . :data-app-id="app.id" class="app-menu-entry" :class="{ - 'app-menu-entry__active': app.active, + 'app-menu-entry__active': app.id === activeApp, 'app-menu-entry__hidden-label': hiddenLabels === 1, 'app-menu-main__show-hovered': hiddenLabels === 2, }" @@ -44,7 +44,7 @@ along with this program. If not, see . :class="{ 'has-unread': app.unread > 0 }" :aria-label="app.name" :target="targetBlankApps.indexOf(app.id) !== -1 ? '_blank' : undefined" - :aria-current="app.active ? 'page' : false" + :aria-current="app.id === activeApp ? 'page' : false" > . v-for="app in popoverAppList" :key="app.id" :aria-label="app.name" - :aria-current="app.active ? 'page' : false" + :aria-current="app.id === activeApp ? 'page' : false" :href="app.href" :style="makeStyle(app)" class="cm-standardmenu-app-menu-popover-entry app-menu-popover-entry" @@ -101,6 +101,7 @@ import { ref, onMounted } from 'vue' import { useConfigStore } from '../store/config.js' import { useNavStore } from '../store/nav.js' import { NcActions, NcActionLink } from '@nextcloud/vue' +import { getActiveAppId } from '../lib/app.js' const navStore = useNavStore() const configStore = useConfigStore() @@ -112,6 +113,7 @@ const topMenuApps = ref([]) const appsOrder = ref([]) const mainAppList = ref([]) const popoverAppList = ref([]) +const activeApp = ref(null) let resizeTimeout = null const setApps = (value) => { @@ -170,6 +172,7 @@ onMounted(async () => { hiddenLabels.value = config['top-menu-mouse-over-hidden-label'] topMenuApps.value = config['top-menu-apps'] appsOrder.value = config['apps-order'] + activeApp.value = getActiveAppId() ready.value = true setApps(await navStore.getCoreApps()) diff --git a/src/store/nav.js b/src/store/nav.js index 03a128e..98abe0d 100644 --- a/src/store/nav.js +++ b/src/store/nav.js @@ -41,10 +41,7 @@ export const useNavStore = defineStore('nav', () => { async function getCoreApps() { if (coreApps == null) { - coreApps = await axios - .get(generateOcsUrl('core/navigation', 2) + '/apps?format=json') - .then((response) => response.data) - .then((value) => value.ocs.data) + coreApps = await await axios.get(generateUrl('/apps/side_menu/core/apps')).then((response) => response.data.items) } return coreApps From 782faf6add65444a68cf03604344309a454e3838 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 4 May 2025 18:34:29 +0200 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98226ab..0bc595c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [Unreleased] +### Fixed +* fix(build): define appName to fix this error: "The `@nextcloud/vue` library was used without setting / replacing the `appName`" +* fix #349: add custom controller to retrieve core apps + ## 5.1.0 ### Added * fix #425: allow to set a color using hex code From 3f16a674e68c36fffa4c6abc2dba2ce55afda7bb Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 23 May 2025 09:02:11 +0200 Subject: [PATCH 4/4] release v5.1.1 --- CHANGELOG.md | 1 + appinfo/info.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc595c..f96bb7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [Unreleased] +## 5.1.1 ### Fixed * fix(build): define appName to fix this error: "The `@nextcloud/vue` library was used without setting / replacing the `appName`" * fix #349: add custom controller to retrieve core apps diff --git a/appinfo/info.xml b/appinfo/info.xml index a5e08f9..e5a95b2 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -30,7 +30,7 @@ Notice Because I believe in a free and decentralized Internet, [Gitnet](https://gitnet.fr) is **self-hosted at home**. In case of downtime, you can download **Custom Menu** from [here](https://kim.deblan.fr/~side_menu/). ]]> - 5.1.0 + 5.1.1 agpl Simon Vieille SideMenu