Skip to content

Commit

Permalink
feat: dispatch event when undeployed policy is clicked in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine CORDIER authored and a-cordier committed Jul 4, 2023
1 parent ec23507 commit e548ed5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/policy-studio/gv-design/gv-design.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ export class GvDesign extends KeyboardElement(LitElement) {
} catch (e) {}
}

_onDisplayPolicyCTA({ detail: { policy } }) {
dispatchCustomEvent(this, 'display-policy-cta', { policy });
}

_fetchDocumentation(policy) {
if (this.documentation == null || this.documentation.id !== policy.id) {
dispatchCustomEvent(this, 'fetch-documentation', { policy });
Expand Down Expand Up @@ -1415,6 +1419,7 @@ export class GvDesign extends KeyboardElement(LitElement) {
?readonly="${readonlyMode}"
@gv-policy-studio-menu:target-policy="${this._onTargetPolicy}"
@gv-policy-studio-menu:fetch-documentation="${this._onOpenDocumentationFromMenu}"
@gv-policy-studio-menu:display-policy-cta="${this._onDisplayPolicyCTA}"
@gv-policy-studio-menu:dragend-policy="${this._onDragEndPolicy}"
>
<div slot="header" class="search-policies">
Expand Down Expand Up @@ -1490,6 +1495,7 @@ export class GvDesign extends KeyboardElement(LitElement) {
@gv-policy-studio-menu:delete-flow="${this._onDeleteFlow}"
@gv-policy-studio-menu:duplicate-flow="${this._onDuplicateFlow}"
@gv-policy-studio-menu:select-flows="${this._onSelectFlows}"
@gv-policy-studio-menu:display-policy-cta="${this._onDisplayPolicyCTA}"
>
<div slot="header" class="header-actions">
${this._flowFilterOptions != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ export class GvPolicyStudioMenu extends LitElement {
}

_onClickPolicy(policy) {
if (!policy.deployed) {
dispatchCustomEvent(this, 'display-policy-cta', { policy });
return;
}
if (!this.disabled) {
this.selectedIds = [policy.id];
dispatchCustomEvent(this, 'fetch-documentation', { policy });
Expand Down Expand Up @@ -762,7 +766,8 @@ export class GvPolicyStudioMenu extends LitElement {
)
: ''}
</div>
<slot name="footer"></slot>`;
<slot name="footer"></slot>
<gv-modal> </gv-modal>`;
}
}

Expand Down

0 comments on commit e548ed5

Please sign in to comment.