diff --git a/CHANGELOG.md b/CHANGELOG.md
index 98226ab..f96bb7d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
## [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
+
## 5.1.0
### Added
* fix #425: allow to set a color using hex code
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
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
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: {