Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(settings): Only use id in categories - drop duplicated ident
…property

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux authored and skjnldsv committed Feb 23, 2024
commit dd7fba2c95ba6cc495e4f31a4f21e9409d85e10e
14 changes: 4 additions & 10 deletions apps/settings/lib/Controller/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,11 @@ public function listCategories(): JSONResponse {
private function getAllCategories() {
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);

$formattedCategories = [];
$categories = $this->categoryFetcher->get();
foreach ($categories as $category) {
$formattedCategories[] = [
'id' => $category['id'],
'ident' => $category['id'],
'displayName' => $category['translations'][$currentLanguage]['name'] ?? $category['translations']['en']['name'],
];
}

return $formattedCategories;
return array_map(fn ($category) => [
'id' => $category['id'],
'displayName' => $category['translations'][$currentLanguage]['name'] ?? $category['translations']['en']['name'],
], $categories);
}

private function fetchApps() {
Expand Down
6 changes: 3 additions & 3 deletions apps/settings/src/views/Apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
:name="$options.APPS_SECTION_ENUM.featured" />

<NcAppNavigationItem v-for="cat in categories"
:key="'icon-category-' + cat.ident"
:icon="'icon-category-' + cat.ident"
:key="'icon-category-' + cat.id"
:icon="'icon-category-' + cat.id"
:to="{
name: 'apps-category',
params: { category: cat.ident },
params: { category: cat.id },
}"
:name="cat.displayName" />
</template>
Expand Down
10 changes: 0 additions & 10 deletions apps/settings/tests/Controller/AppSettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,52 +125,42 @@ public function testListCategories() {
$expected = new JSONResponse([
[
'id' => 'auth',
'ident' => 'auth',
'displayName' => 'Authentication & authorization',
],
[
'id' => 'customization',
'ident' => 'customization',
'displayName' => 'Customization',
],
[
'id' => 'files',
'ident' => 'files',
'displayName' => 'Files',
],
[
'id' => 'integration',
'ident' => 'integration',
'displayName' => 'Integration',
],
[
'id' => 'monitoring',
'ident' => 'monitoring',
'displayName' => 'Monitoring',
],
[
'id' => 'multimedia',
'ident' => 'multimedia',
'displayName' => 'Multimedia',
],
[
'id' => 'office',
'ident' => 'office',
'displayName' => 'Office & text',
],
[
'id' => 'organization',
'ident' => 'organization',
'displayName' => 'Organization',
],
[
'id' => 'social',
'ident' => 'social',
'displayName' => 'Social & communication',
],
[
'id' => 'tools',
'ident' => 'tools',
'displayName' => 'Tools',
],
]);
Expand Down