fix(settings): Only use id in categories - drop duplicated ident property

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2024-02-22 17:16:32 +01:00 committed by skjnldsv
parent 5207274148
commit dd7fba2c95
3 changed files with 7 additions and 23 deletions

View file

@ -184,17 +184,11 @@ class AppSettingsController extends Controller {
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() {

View file

@ -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>

View file

@ -125,52 +125,42 @@ class AppSettingsControllerTest extends TestCase {
$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',
],
]);