refactor(client): remove unused togglable property from module configurations, delete moduleFilters utility as it is no longer needed

Former-commit-id: 82c5b3734ef31a85c949c03a1b6509ce09ded56f [formerly 9f88208490e900614c8e9d0d9a8aea54c34411a1] [formerly 215f296edb46186dc56e2dfcad4f27dd60a17da0 [formerly 540d4f1a3957e32c505756154e0188fabb2d53b7]]
Former-commit-id: 87a78a6a72988589b0442f1e48b048649887366d [formerly 9f029492124ee2c02b31a186a47f8fef8118d26a]
Former-commit-id: 390379d2e8827b2989f3ac7b24ac4e010654e369
This commit is contained in:
Melvin Chia
2025-10-05 21:51:57 +08:00
parent 562551a1fb
commit de83231fe4
5 changed files with 4 additions and 45 deletions

View File

@@ -6,6 +6,5 @@ export default {
icon: 'tabler:dashboard',
routes: {
dashboard: lazy(() => import('.'))
},
togglable: false
}
} satisfies ModuleConfig

View File

@@ -6,6 +6,5 @@ export default {
icon: 'tabler:password',
routes: {
'api-keys': lazy(() => import('.'))
},
togglable: false
}
} satisfies ModuleConfig

View File

@@ -6,6 +6,5 @@ export default {
icon: 'tabler:history',
routes: {
backups: lazy(() => import('.'))
},
togglable: false
}
} satisfies ModuleConfig

View File

@@ -6,6 +6,5 @@ export default {
icon: 'tabler:palette',
routes: {
personalization: lazy(() => import('.'))
},
togglable: false
}
} satisfies ModuleConfig

View File

@@ -1,37 +0,0 @@
import _ from 'lodash'
import type { ModuleConfig } from 'shared'
/**
* Determines if a module should be enabled based on user preferences and configuration
*/
export function shouldModuleBeEnabled(
item: ModuleConfig,
enabledModules: string[]
): boolean {
// If the module is force disabled, it should never be enabled
if (item.forceDisable) {
return false
}
// If the module is not togglable, it's always enabled
if (!item.togglable) {
return true
}
// For togglable modules, check if it's in the enabled modules list
const moduleKey = _.kebabCase(item.name)
return enabledModules.includes(moduleKey)
}
/**
* Filters modules based on visibility and enablement rules
*/
export function getEnabledModules(
items: ModuleConfig[],
enabledModules: string[]
): ModuleConfig[] {
return items.filter(
item => !item.hidden && shouldModuleBeEnabled(item, enabledModules)
)
}