From 4e488e15c653953a2d828a76505c2bfc8f4e717c Mon Sep 17 00:00:00 2001 From: ThibaudAv Date: Wed, 14 Aug 2024 12:23:09 +0200 Subject: [PATCH] feat: policy studio - add prerequisiteMessage for SPG --- .../gio-ps-flow-details-phase-step.component.html | 3 +++ .../gio-ps-flow-details-phase-step.component.ts | 8 +++++++- .../gio-ps-flow-details-phase-step.harness.ts | 8 ++++++++ .../gio-ps-flow-details-phase.harness.ts | 2 ++ .../components/step-form/gio-ps-step-form.component.html | 4 ++++ .../components/step-form/gio-ps-step-form.component.ts | 7 ++++++- .../lib/models/policy/SharedPolicyGroupPolicy.fixture.ts | 1 + .../src/lib/models/policy/SharedPolicyGroupPolicy.ts | 1 + .../lib/policy-studio/gio-policy-studio.component.spec.ts | 3 ++- 9 files changed, 34 insertions(+), 3 deletions(-) diff --git a/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase-step/gio-ps-flow-details-phase-step.component.html b/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase-step/gio-ps-flow-details-phase-step.component.html index afe4464ae..d6cea85ae 100644 --- a/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase-step/gio-ps-flow-details-phase-step.component.html +++ b/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase-step/gio-ps-flow-details-phase-step.component.html @@ -25,6 +25,9 @@ + @if (getPrerequisiteMessage) { + + } { + const tooltip = await this.locatorForOptional(MatTooltipHarness.with({ selector: '.info__head__info' }))(); + // FIXME: await tooltip.getTooltipText(); returns empty string. when it's in a condition. I haven't figured out how to get over it. + // This hack allows to validate the info anyway + return tooltip ? 'HasInfoMessage' : undefined; + } + public async clickOnEdit(): Promise { const matMenu = await this.locatorFor(MatMenuHarness)(); await matMenu.clickItem({ text: 'Edit' }); diff --git a/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.ts b/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.ts index 07f69b0e2..2f342ee8d 100644 --- a/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.ts +++ b/projects/ui-policy-studio-angular/src/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.ts @@ -91,12 +91,14 @@ export class GioPolicyStudioDetailsPhaseHarness extends ComponentHarness { const step = await stepDiv.childLocatorFor(GioPolicyStudioDetailsPhaseStepHarness)(); const conditionDiv = await stepDiv.childLocatorForOptional(DivHarness.with({ selector: '.content__step__policy__condition' }))(); const description = await step.getDescription(); + const infoMessage = await step.getInfoMessage(); return { type: 'step', name: await step.getName(), hasCondition: !!conditionDiv, ...(description ? { description } : {}), + ...(infoMessage ? { infoMessage } : {}), }; }), ); diff --git a/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.html b/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.html index 459a0b860..74671281e 100644 --- a/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.html +++ b/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.html @@ -48,6 +48,10 @@
Documentation
+ + Prerequisite message + {{ infoBanner }} + diff --git a/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.ts b/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.ts index 48cbe8aaf..38b2a1661 100644 --- a/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.ts +++ b/projects/ui-policy-studio-angular/src/lib/components/step-form/gio-ps-step-form.component.ts @@ -18,6 +18,7 @@ import { ReactiveFormsModule, UntypedFormControl, UntypedFormGroup } from '@angu import { catchError, map, takeUntil } from 'rxjs/operators'; import { Observable, of, Subject } from 'rxjs'; import { + GioBannerModule, GioFormJsonSchemaComponent, GioFormJsonSchemaModule, GioJsonSchema, @@ -43,6 +44,7 @@ import { GioPolicyStudioService } from '../../policy-studio/gio-policy-studio.se GioFormJsonSchemaModule, GioAsciidoctorModule, GioLoaderModule, + GioBannerModule, ], selector: 'gio-ps-step-form', templateUrl: './gio-ps-step-form.component.html', @@ -69,6 +71,7 @@ export class GioPolicyStudioStepFormComponent implements OnChanges, OnInit, OnDe public policySchema$?: Observable; public policyDocumentation$?: Observable; + public infoBanner?: string; public stepForm?: UntypedFormGroup; @@ -97,7 +100,9 @@ export class GioPolicyStudioStepFormComponent implements OnChanges, OnInit, OnDe if (isSharedPolicyGroupPolicy(this.genericPolicy)) { this.policySchema$ = of({}); - this.policyDocumentation$ = of('No documentation available.'); + this.policyDocumentation$ = of(' '); + + this.infoBanner = this.genericPolicy.prerequisiteMessage; } } if (changes.executionPhase) { diff --git a/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.fixture.ts b/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.fixture.ts index c0903ea37..83b53e951 100644 --- a/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.fixture.ts +++ b/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.fixture.ts @@ -26,6 +26,7 @@ export function fakeProxyRequestSharedPolicyGroupPolicy( policyId: 'shared-policy-group-policy', name: 'Test PROXY SPG', description: 'Test Shared Policy Group request phase', + prerequisiteMessage: 'The resource cache "my-cache" is required', apiType: 'PROXY', phase: 'REQUEST', }; diff --git a/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.ts b/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.ts index f4b5ad74f..b32b0fa26 100644 --- a/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.ts +++ b/projects/ui-policy-studio-angular/src/lib/models/policy/SharedPolicyGroupPolicy.ts @@ -23,6 +23,7 @@ export type SharedPolicyGroupPolicy = { policyId: string; name: string; description?: string; + prerequisiteMessage?: string; apiType: ApiType; phase: ExecutionPhase; }; diff --git a/projects/ui-policy-studio-angular/src/lib/policy-studio/gio-policy-studio.component.spec.ts b/projects/ui-policy-studio-angular/src/lib/policy-studio/gio-policy-studio.component.spec.ts index 7634376d1..8f98c4cb3 100644 --- a/projects/ui-policy-studio-angular/src/lib/policy-studio/gio-policy-studio.component.spec.ts +++ b/projects/ui-policy-studio-angular/src/lib/policy-studio/gio-policy-studio.component.spec.ts @@ -1317,7 +1317,7 @@ describe('GioPolicyStudioComponent', () => { const commonFlows = [ fakeHttpFlow({ name: 'Flow 1', - request: [fakeRateLimitStep()], + request: [fakeRateLimitStep(), fakeSharedPolicyGroupPolicyStep()], response: [fakeTestPolicyStep()], }), ]; @@ -1332,6 +1332,7 @@ describe('GioPolicyStudioComponent', () => { expect(await requestPhase?.getSteps()).toStrictEqual([ { name: 'HTTP Proxy', type: 'connector' }, { name: 'Rate Limit', description: 'Step description', hasCondition: false, type: 'step' }, + { name: 'Test PROXY SPG', description: 'Shared Policy Group', hasCondition: false, type: 'step', infoMessage: 'HasInfoMessage' }, { name: 'HTTP Proxy', type: 'connector' }, ]);