From 40ca5e0e3b7b20dd76881f86a8ecc84ba8d8b1de Mon Sep 17 00:00:00 2001 From: albina Date: Thu, 12 Sep 2024 13:43:41 +0000 Subject: [PATCH 1/2] fix(efs): Set up for separate feature flag --- .../src/forms/prerequisites.ts | 9 ++++- .../src/lib/InheritanceReportTemplate.ts | 24 ++++++++++--- .../src/lib/getApplicationFeatureFlags.ts | 34 +++++++++++++++++++ libs/feature-flags/src/lib/features.ts | 1 - 4 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 libs/application/templates/inheritance-report/src/lib/getApplicationFeatureFlags.ts diff --git a/libs/application/templates/inheritance-report/src/forms/prerequisites.ts b/libs/application/templates/inheritance-report/src/forms/prerequisites.ts index 52d7119c5e8a..421b7b3c5e29 100644 --- a/libs/application/templates/inheritance-report/src/forms/prerequisites.ts +++ b/libs/application/templates/inheritance-report/src/forms/prerequisites.ts @@ -9,7 +9,10 @@ import { DefaultEvents, Form, FormModes } from '@island.is/application/types' import { ESTATE_INHERITANCE, PREPAID_INHERITANCE } from '../lib/constants' import { m } from '../lib/messages' -export const getForm = (): Form => +export const getForm = ({ + allowEstateApplication = false, + allowPrepaidApplication = false, +}): Form => buildForm({ id: 'PrerequisitesDraft', title: '', @@ -34,10 +37,14 @@ export const getForm = (): Form => { value: ESTATE_INHERITANCE, label: m.preDataCollectionApplicationForDefault, + disabled: !allowEstateApplication, + //TODO: remove tooltip when this application is ready to go live + tooltip: 'Þessi tengund af umsókn er í vinnslu', }, { value: PREPAID_INHERITANCE, label: m.preDataCollectionApplicationForPrepaid, + disabled: !allowPrepaidApplication, }, ], }), diff --git a/libs/application/templates/inheritance-report/src/lib/InheritanceReportTemplate.ts b/libs/application/templates/inheritance-report/src/lib/InheritanceReportTemplate.ts index 8ad9f70b01fa..960ee83d0bc1 100644 --- a/libs/application/templates/inheritance-report/src/lib/InheritanceReportTemplate.ts +++ b/libs/application/templates/inheritance-report/src/lib/InheritanceReportTemplate.ts @@ -25,8 +25,12 @@ import { Roles, States, } from './constants' -import { Features } from '@island.is/feature-flags' import { EstateOnEntryApi, MaritalStatusApi } from '../dataProviders' +import { FeatureFlagClient } from '@island.is/feature-flags' +import { + getApplicationFeatureFlags, + InheritanceReportFeatureFlags, +} from './getApplicationFeatureFlags' const configuration = ApplicationConfigurations[ApplicationTypes.INHERITANCE_REPORT] @@ -50,7 +54,6 @@ const InheritanceReportTemplate: ApplicationTemplate< institution: m.institution, dataSchema: inheritanceReportSchema, translationNamespaces: [configuration.translation], - featureFlag: Features.inheritanceReport, allowMultipleApplicationsInDraft: false, stateMachineConfig: { initial: States.prerequisites, @@ -64,12 +67,25 @@ const InheritanceReportTemplate: ApplicationTemplate< roles: [ { id: Roles.ESTATE_INHERITANCE_APPLICANT, - formLoader: async () => { + formLoader: async ({ featureFlagClient }) => { + const featureFlags = await getApplicationFeatureFlags( + featureFlagClient as FeatureFlagClient, + ) + const getForm = await import('../forms/prerequisites').then( (val) => val.getForm, ) - return getForm() + return getForm({ + allowEstateApplication: + featureFlags[ + InheritanceReportFeatureFlags.AllowEstateApplication + ], + allowPrepaidApplication: + featureFlags[ + InheritanceReportFeatureFlags.AllowPrepaidApplication + ], + }) }, actions: [{ event: 'SUBMIT', name: '', type: 'primary' }], write: 'all', diff --git a/libs/application/templates/inheritance-report/src/lib/getApplicationFeatureFlags.ts b/libs/application/templates/inheritance-report/src/lib/getApplicationFeatureFlags.ts new file mode 100644 index 000000000000..99024009cd67 --- /dev/null +++ b/libs/application/templates/inheritance-report/src/lib/getApplicationFeatureFlags.ts @@ -0,0 +1,34 @@ +import { FeatureFlagClient } from '@island.is/feature-flags' + +export enum InheritanceReportFeatureFlags { + AllowEstateApplication = 'isInheritanceReportApplicationEnabled', + AllowPrepaidApplication = 'isInheritanceReportPrepaidApplicationEnabled', +} + +export const getApplicationFeatureFlags = async ( + client: FeatureFlagClient, +): Promise> => { + const featureFlags: InheritanceReportFeatureFlags[] = [ + InheritanceReportFeatureFlags.AllowEstateApplication, + InheritanceReportFeatureFlags.AllowPrepaidApplication, + ] + + return ( + await Promise.all( + featureFlags.map(async (key: InheritanceReportFeatureFlags) => { + return { key, value: !!(await client.getValue(key, false)) } + }), + ) + ).reduce( + ( + acc, + { key, value }: { key: InheritanceReportFeatureFlags; value: boolean }, + ) => { + return { + ...acc, + [key]: value, + } + }, + {} as Record, + ) +} diff --git a/libs/feature-flags/src/lib/features.ts b/libs/feature-flags/src/lib/features.ts index 5abd7e28aad8..eb5bde4c7e7d 100644 --- a/libs/feature-flags/src/lib/features.ts +++ b/libs/feature-flags/src/lib/features.ts @@ -11,7 +11,6 @@ export enum Features { passportApplication = 'isPassportApplicationEnabled', passportAnnulmentApplication = 'isPassportAnnulmentApplicationEnabled', financialStatementInao = 'financialStatementInao', - inheritanceReport = 'isInheritanceReportApplicationEnabled', transportAuthorityDigitalTachographCompanyCard = 'isTransportAuthorityDigitalTachographCompanyCardEnabled', transportAuthorityDigitalTachographWorkshopCard = 'isTransportAuthorityDigitalTachographWorkshopCardEnabled', alcoholTaxRedemption = 'isAlcoholTaxRedemptionEnabled', From 294894515e9eadfe13b81a99216496c9a0cff175 Mon Sep 17 00:00:00 2001 From: albina Date: Thu, 12 Sep 2024 14:04:05 +0000 Subject: [PATCH 2/2] message tooltip --- .../templates/inheritance-report/src/forms/prerequisites.ts | 2 +- .../templates/inheritance-report/src/lib/messages.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/application/templates/inheritance-report/src/forms/prerequisites.ts b/libs/application/templates/inheritance-report/src/forms/prerequisites.ts index 421b7b3c5e29..74b17ab2358b 100644 --- a/libs/application/templates/inheritance-report/src/forms/prerequisites.ts +++ b/libs/application/templates/inheritance-report/src/forms/prerequisites.ts @@ -39,7 +39,7 @@ export const getForm = ({ label: m.preDataCollectionApplicationForDefault, disabled: !allowEstateApplication, //TODO: remove tooltip when this application is ready to go live - tooltip: 'Þessi tengund af umsókn er í vinnslu', + tooltip: m.preDataCollectionApplicationForDefaultTooltip, }, { value: PREPAID_INHERITANCE, diff --git a/libs/application/templates/inheritance-report/src/lib/messages.ts b/libs/application/templates/inheritance-report/src/lib/messages.ts index 6e5341b35271..9c0d900d2423 100644 --- a/libs/application/templates/inheritance-report/src/lib/messages.ts +++ b/libs/application/templates/inheritance-report/src/lib/messages.ts @@ -61,6 +61,11 @@ export const m = defineMessages({ defaultMessage: 'Dánarbú', description: '', }, + preDataCollectionApplicationForDefaultTooltip: { + id: 'ir.application:preDataCollectionApplicationForDefaultTooltip', + defaultMessage: 'Ekki er búið að opna fyrir umsóknir af þessari gerð.', + description: '', + }, // Application begin applicationName: { id: 'ir.application:applicationName',