@nuxt-customer-portal/core 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PortalFeatureDefinition } from '@nuxt-customer-portal/core/shared/types/feature'
|
|
2
2
|
import {
|
|
3
|
+
isPortalFeatureEnabled,
|
|
3
4
|
mergePortalModuleMenuContributions,
|
|
4
5
|
sortPortalDashboardWidgets,
|
|
5
6
|
upsertPortalFeature
|
|
@@ -9,44 +10,33 @@ export const usePortalFeatures = () => {
|
|
|
9
10
|
const features = useState<PortalFeatureDefinition[]>('portal-features', () => [])
|
|
10
11
|
const enabledModules = useState<string[] | null>('portal-enabled-modules', () => null)
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
if (!['timesheets', 'invoices', 'service-requests', 'invoice-timesheets'].includes(feature.id)) {
|
|
17
|
-
return true
|
|
18
|
-
}
|
|
19
|
-
return enabledModules.value.includes(feature.id)
|
|
20
|
-
}
|
|
13
|
+
const enabledFeatures = computed(() =>
|
|
14
|
+
features.value.filter((feature) => isPortalFeatureEnabled(feature, enabledModules.value))
|
|
15
|
+
)
|
|
21
16
|
|
|
22
17
|
const registerFeature = (feature: PortalFeatureDefinition) => {
|
|
23
18
|
features.value = upsertPortalFeature(features.value, feature)
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
const navigation = computed(() =>
|
|
27
|
-
|
|
28
|
-
.filter(featureEnabled)
|
|
22
|
+
enabledFeatures.value
|
|
29
23
|
.flatMap((feature) => feature.navigation ?? [])
|
|
30
24
|
.sort((a, b) => (a.order ?? 100) - (b.order ?? 100))
|
|
31
25
|
)
|
|
32
26
|
|
|
33
27
|
const dashboardWidgets = computed(() =>
|
|
34
|
-
sortPortalDashboardWidgets(
|
|
35
|
-
features.value.filter(featureEnabled).flatMap((feature) => feature.dashboardWidgets ?? [])
|
|
36
|
-
)
|
|
28
|
+
sortPortalDashboardWidgets(enabledFeatures.value.flatMap((feature) => feature.dashboardWidgets ?? []))
|
|
37
29
|
)
|
|
38
30
|
|
|
39
31
|
const modules = computed(() => {
|
|
40
|
-
const enabledFeatures = features.value.filter(featureEnabled)
|
|
41
32
|
return mergePortalModuleMenuContributions(
|
|
42
|
-
enabledFeatures.flatMap((feature) => feature.modules ?? []),
|
|
43
|
-
enabledFeatures.flatMap((feature) => feature.moduleMenuItems ?? [])
|
|
33
|
+
enabledFeatures.value.flatMap((feature) => feature.modules ?? []),
|
|
34
|
+
enabledFeatures.value.flatMap((feature) => feature.moduleMenuItems ?? [])
|
|
44
35
|
).sort((a, b) => (a.order ?? 100) - (b.order ?? 100))
|
|
45
36
|
})
|
|
46
37
|
|
|
47
38
|
const surfaces = computed(() =>
|
|
48
|
-
|
|
49
|
-
.filter(featureEnabled)
|
|
39
|
+
enabledFeatures.value
|
|
50
40
|
.flatMap((feature) => feature.surfaces ?? [])
|
|
51
41
|
.sort((a, b) => (a.order ?? 100) - (b.order ?? 100) || a.id.localeCompare(b.id))
|
|
52
42
|
)
|
|
@@ -55,14 +45,14 @@ export const usePortalFeatures = () => {
|
|
|
55
45
|
computed(() => surfaces.value.filter((contribution) => contribution.surface === surface))
|
|
56
46
|
|
|
57
47
|
const clientIntegrations = computed(() =>
|
|
58
|
-
|
|
59
|
-
.filter(featureEnabled)
|
|
48
|
+
enabledFeatures.value
|
|
60
49
|
.flatMap((feature) => (feature.clientIntegration ? [feature.clientIntegration] : []))
|
|
61
50
|
.sort((left, right) => left.moduleId.localeCompare(right.moduleId))
|
|
62
51
|
)
|
|
63
52
|
|
|
64
53
|
return {
|
|
65
54
|
features: readonly(features),
|
|
55
|
+
enabledFeatures: readonly(enabledFeatures),
|
|
66
56
|
navigation,
|
|
67
57
|
modules,
|
|
68
58
|
dashboardWidgets,
|
package/package.json
CHANGED
package/portal.manifest.mjs
CHANGED
|
@@ -8,6 +8,13 @@ import type {
|
|
|
8
8
|
PortalRolePolicy
|
|
9
9
|
} from './types/feature'
|
|
10
10
|
|
|
11
|
+
const configurablePortalFeatureIds = new Set(['timesheets', 'invoices', 'service-requests', 'invoice-timesheets'])
|
|
12
|
+
|
|
13
|
+
export const isPortalFeatureEnabled = (
|
|
14
|
+
feature: PortalFeatureDefinition,
|
|
15
|
+
enabledModules: readonly string[] | null
|
|
16
|
+
): boolean => !enabledModules || !configurablePortalFeatureIds.has(feature.id) || enabledModules.includes(feature.id)
|
|
17
|
+
|
|
11
18
|
export const mergePortalModuleMenuContributions = (
|
|
12
19
|
modules: readonly PortalModuleContribution[],
|
|
13
20
|
contributions: readonly PortalModuleMenuContribution[]
|