mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-02 19:47:54 +00:00 
			
		
		
		
	UI: Fix delete from list using Item.callMethod (#25608)
* Fix multiple confirm modals showing on delete auth item * fix muliple confirm modals on KMIP items delete * fix multiple modals on namespace list
This commit is contained in:
		@@ -27,14 +27,7 @@ import { tracked } from '@glimmer/tracking';
 | 
				
			|||||||
export default class GeneratedItemList extends Component {
 | 
					export default class GeneratedItemList extends Component {
 | 
				
			||||||
  @service router;
 | 
					  @service router;
 | 
				
			||||||
  @service store;
 | 
					  @service store;
 | 
				
			||||||
  @tracked showConfirmModal = false;
 | 
					  @tracked itemToDelete = null;
 | 
				
			||||||
 | 
					 | 
				
			||||||
  get model() {
 | 
					 | 
				
			||||||
    return this.args.model || null;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  get itemType() {
 | 
					 | 
				
			||||||
    return this.args.itemType || null;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @action
 | 
					  @action
 | 
				
			||||||
  refreshItemList() {
 | 
					  refreshItemList() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,37 +37,30 @@
 | 
				
			|||||||
  <ToolbarActions>
 | 
					  <ToolbarActions>
 | 
				
			||||||
    <ToolbarLink
 | 
					    <ToolbarLink
 | 
				
			||||||
      @route="vault.cluster.access.method.item.create"
 | 
					      @route="vault.cluster.access.method.item.create"
 | 
				
			||||||
      @model={{this.itemType}}
 | 
					      @model={{@itemType}}
 | 
				
			||||||
      @type="add"
 | 
					      @type="add"
 | 
				
			||||||
      data-test-entity-create-link={{this.itemType}}
 | 
					      data-test-entity-create-link={{@itemType}}
 | 
				
			||||||
    >
 | 
					    >
 | 
				
			||||||
      Create
 | 
					      Create
 | 
				
			||||||
      {{singularize this.itemType}}
 | 
					      {{singularize @itemType}}
 | 
				
			||||||
    </ToolbarLink>
 | 
					    </ToolbarLink>
 | 
				
			||||||
  </ToolbarActions>
 | 
					  </ToolbarActions>
 | 
				
			||||||
</Toolbar>
 | 
					</Toolbar>
 | 
				
			||||||
<ListView
 | 
					<ListView @items={{@model}} @itemNoun={{@itemType}} @paginationRouteName="vault.cluster.access.method.item.list" as |list|>
 | 
				
			||||||
  @items={{this.model}}
 | 
					 | 
				
			||||||
  @itemNoun={{this.itemType}}
 | 
					 | 
				
			||||||
  @paginationRouteName="vault.cluster.access.method.item.list"
 | 
					 | 
				
			||||||
  as |list|
 | 
					 | 
				
			||||||
>
 | 
					 | 
				
			||||||
  {{#if list.empty}}
 | 
					  {{#if list.empty}}
 | 
				
			||||||
    <list.empty
 | 
					    <list.empty
 | 
				
			||||||
      @title="No {{pluralize this.itemType}} yet"
 | 
					      @title="No {{pluralize @itemType}} yet"
 | 
				
			||||||
      @message="A list of {{pluralize
 | 
					      @message="A list of {{pluralize @itemType}} will be listed here. Create your first {{@itemType}} to get started."
 | 
				
			||||||
        this.itemType
 | 
					 | 
				
			||||||
      }} will be listed here. Create your first {{this.itemType}} to get started."
 | 
					 | 
				
			||||||
    >
 | 
					    >
 | 
				
			||||||
      <Hds::Link::Standalone
 | 
					      <Hds::Link::Standalone
 | 
				
			||||||
        @icon="plus"
 | 
					        @icon="plus"
 | 
				
			||||||
        @text="Create {{singularize this.itemType}}"
 | 
					        @text="Create {{singularize @itemType}}"
 | 
				
			||||||
        @route="vault.cluster.access.method.item.create"
 | 
					        @route="vault.cluster.access.method.item.create"
 | 
				
			||||||
        @model={{this.itemType}}
 | 
					        @model={{@itemType}}
 | 
				
			||||||
      />
 | 
					      />
 | 
				
			||||||
    </list.empty>
 | 
					    </list.empty>
 | 
				
			||||||
  {{else if list.item}}
 | 
					  {{else if list.item}}
 | 
				
			||||||
    <ListItem @linkParams={{array "vault.cluster.access.method.item.show" this.itemType list.item.id}} as |Item|>
 | 
					    <ListItem @linkParams={{array "vault.cluster.access.method.item.show" @itemType list.item.id}} as |Item|>
 | 
				
			||||||
      <Item.content>
 | 
					      <Item.content>
 | 
				
			||||||
        <Icon @name="folder" class="has-text-grey-light" />{{list.item.id}}
 | 
					        <Icon @name="folder" class="has-text-grey-light" />{{list.item.id}}
 | 
				
			||||||
      </Item.content>
 | 
					      </Item.content>
 | 
				
			||||||
@@ -80,39 +73,38 @@
 | 
				
			|||||||
            data-test-popup-menu-trigger
 | 
					            data-test-popup-menu-trigger
 | 
				
			||||||
          />
 | 
					          />
 | 
				
			||||||
          <dd.Interactive
 | 
					          <dd.Interactive
 | 
				
			||||||
            @text="View {{singularize this.itemType}}"
 | 
					            @text="View {{singularize @itemType}}"
 | 
				
			||||||
            @route="vault.cluster.access.method.item.show"
 | 
					            @route="vault.cluster.access.method.item.show"
 | 
				
			||||||
            @model={{list.item.id}}
 | 
					            @model={{list.item.id}}
 | 
				
			||||||
          />
 | 
					          />
 | 
				
			||||||
          <dd.Interactive
 | 
					          <dd.Interactive
 | 
				
			||||||
            @text="Edit {{singularize this.itemType}}"
 | 
					            @text="Edit {{singularize @itemType}}"
 | 
				
			||||||
            @route="vault.cluster.access.method.item.edit"
 | 
					            @route="vault.cluster.access.method.item.edit"
 | 
				
			||||||
            @model={{list.item.id}}
 | 
					            @model={{list.item.id}}
 | 
				
			||||||
          />
 | 
					          />
 | 
				
			||||||
          <dd.Interactive
 | 
					          <dd.Interactive
 | 
				
			||||||
            @text="Delete {{singularize this.itemType}}"
 | 
					            @text="Delete {{singularize @itemType}}"
 | 
				
			||||||
            @color="critical"
 | 
					            @color="critical"
 | 
				
			||||||
            {{on "click" (fn (mut this.showConfirmModal) true)}}
 | 
					            {{on "click" (fn (mut this.itemToDelete) list.item)}}
 | 
				
			||||||
          />
 | 
					          />
 | 
				
			||||||
        </Hds::Dropdown>
 | 
					        </Hds::Dropdown>
 | 
				
			||||||
      </Item.menu>
 | 
					      </Item.menu>
 | 
				
			||||||
 | 
					      {{#if (eq list.item this.itemToDelete)}}
 | 
				
			||||||
      {{#if this.showConfirmModal}}
 | 
					 | 
				
			||||||
        <ConfirmModal
 | 
					        <ConfirmModal
 | 
				
			||||||
          @color="critical"
 | 
					          @color="critical"
 | 
				
			||||||
          @onClose={{fn (mut this.showConfirmModal) false}}
 | 
					          @onClose={{fn (mut this.itemToDelete) null}}
 | 
				
			||||||
          @onConfirm={{action
 | 
					          @onConfirm={{action
 | 
				
			||||||
            (perform
 | 
					            (perform
 | 
				
			||||||
              Item.callMethod
 | 
					              Item.callMethod
 | 
				
			||||||
              "destroyRecord"
 | 
					              "destroyRecord"
 | 
				
			||||||
              list.item
 | 
					              this.itemToDelete
 | 
				
			||||||
              (concat "Successfully deleted " (singularize this.itemType) " " list.item.id ".")
 | 
					              (concat "Successfully deleted " (singularize @itemType) " " this.itemToDelete.id ".")
 | 
				
			||||||
              (concat "There was an error deleting this " (singularize this.itemType))
 | 
					              (concat "There was an error deleting this " (singularize @itemType))
 | 
				
			||||||
              (action "refreshItemList")
 | 
					              (action "refreshItemList")
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
          }}
 | 
					          }}
 | 
				
			||||||
          @confirmTitle="Delete {{singularize this.itemType}}?"
 | 
					          @confirmTitle="Delete {{singularize @itemType}}?"
 | 
				
			||||||
          @confirmMessage="Are you sure you want to delete {{singularize this.itemType}} {{list.item.id}}?"
 | 
					          @confirmMessage="Are you sure you want to delete {{singularize @itemType}} {{this.itemToDelete.id}}?"
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
      {{/if}}
 | 
					      {{/if}}
 | 
				
			||||||
    </ListItem>
 | 
					    </ListItem>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,18 +46,18 @@
 | 
				
			|||||||
                </dd.Generic>
 | 
					                </dd.Generic>
 | 
				
			||||||
              {{/if}}
 | 
					              {{/if}}
 | 
				
			||||||
            {{/let}}
 | 
					            {{/let}}
 | 
				
			||||||
            <dd.Interactive @text="Delete" @color="critical" {{on "click" (fn (mut this.showConfirmModal) true)}} />
 | 
					            <dd.Interactive @text="Delete" @color="critical" {{on "click" (fn (mut this.nsToDelete) list.item)}} />
 | 
				
			||||||
          </Hds::Dropdown>
 | 
					          </Hds::Dropdown>
 | 
				
			||||||
          {{#if this.showConfirmModal}}
 | 
					          {{#if (eq this.nsToDelete list.item)}}
 | 
				
			||||||
            <ConfirmModal
 | 
					            <ConfirmModal
 | 
				
			||||||
              @color="critical"
 | 
					              @color="critical"
 | 
				
			||||||
              @onClose={{fn (mut this.showConfirmModal) false}}
 | 
					              @onClose={{fn (mut this.nsToDelete) null}}
 | 
				
			||||||
              @onConfirm={{action
 | 
					              @onConfirm={{action
 | 
				
			||||||
                (perform
 | 
					                (perform
 | 
				
			||||||
                  Item.callMethod
 | 
					                  Item.callMethod
 | 
				
			||||||
                  "destroyRecord"
 | 
					                  "destroyRecord"
 | 
				
			||||||
                  list.item
 | 
					                  this.nsToDelete
 | 
				
			||||||
                  (concat "Successfully deleted namespace: " list.item.id)
 | 
					                  (concat "Successfully deleted namespace: " this.nsToDelete.id)
 | 
				
			||||||
                  "There was an error deleting this namespace: "
 | 
					                  "There was an error deleting this namespace: "
 | 
				
			||||||
                  (action "refreshNamespaceList")
 | 
					                  (action "refreshNamespaceList")
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,22 +78,22 @@
 | 
				
			|||||||
            <dd.Interactive
 | 
					            <dd.Interactive
 | 
				
			||||||
              @text="Revoke credentials"
 | 
					              @text="Revoke credentials"
 | 
				
			||||||
              @color="critical"
 | 
					              @color="critical"
 | 
				
			||||||
              {{on "click" (fn (mut this.showConfirmModal) true)}}
 | 
					              {{on "click" (fn (mut this.credToRevoke) list.item)}}
 | 
				
			||||||
              data-test-confirm-action-trigger
 | 
					              data-test-confirm-action-trigger
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
          {{/if}}
 | 
					          {{/if}}
 | 
				
			||||||
        </Hds::Dropdown>
 | 
					        </Hds::Dropdown>
 | 
				
			||||||
        {{#if this.showConfirmModal}}
 | 
					        {{#if (eq this.credToRevoke list.item)}}
 | 
				
			||||||
          <ConfirmModal
 | 
					          <ConfirmModal
 | 
				
			||||||
            @color="critical"
 | 
					            @color="critical"
 | 
				
			||||||
            @onClose={{fn (mut this.showConfirmModal) false}}
 | 
					            @onClose={{fn (mut this.credToRevoke) null}}
 | 
				
			||||||
            @confirmTitle="Revoke this?"
 | 
					            @confirmTitle="Revoke this?"
 | 
				
			||||||
            @confirmMessage="Any client using these credentials will no longer be able to."
 | 
					            @confirmMessage="Any client using these credentials will no longer be able to."
 | 
				
			||||||
            @onConfirm={{action
 | 
					            @onConfirm={{action
 | 
				
			||||||
              (perform
 | 
					              (perform
 | 
				
			||||||
                Item.callMethod
 | 
					                Item.callMethod
 | 
				
			||||||
                "destroyRecord"
 | 
					                "destroyRecord"
 | 
				
			||||||
                list.item
 | 
					                this.credToRevoke
 | 
				
			||||||
                "Successfully revoked credentials"
 | 
					                "Successfully revoked credentials"
 | 
				
			||||||
                "There was an error revoking the credentials"
 | 
					                "There was an error revoking the credentials"
 | 
				
			||||||
                (action "refresh")
 | 
					                (action "refresh")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,27 +85,27 @@
 | 
				
			|||||||
              <dd.Interactive
 | 
					              <dd.Interactive
 | 
				
			||||||
                @text="Delete role"
 | 
					                @text="Delete role"
 | 
				
			||||||
                @color="critical"
 | 
					                @color="critical"
 | 
				
			||||||
                {{on "click" (fn (mut this.showConfirmModal) true)}}
 | 
					                {{on "click" (fn (mut this.roleToDelete) list.item)}}
 | 
				
			||||||
                data-test-confirm-action-trigger
 | 
					                data-test-confirm-action-trigger
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
            {{/if}}
 | 
					            {{/if}}
 | 
				
			||||||
          {{/if}}
 | 
					          {{/if}}
 | 
				
			||||||
        </Hds::Dropdown>
 | 
					        </Hds::Dropdown>
 | 
				
			||||||
        {{#if this.showConfirmModal}}
 | 
					        {{#if (eq this.roleToDelete list.item)}}
 | 
				
			||||||
          <ConfirmModal
 | 
					          <ConfirmModal
 | 
				
			||||||
            @color="critical"
 | 
					            @color="critical"
 | 
				
			||||||
            @confirmMessage="Are you sure you want to delete {{list.item.id}}?"
 | 
					            @confirmMessage="Are you sure you want to delete {{this.roleToDelete.id}}?"
 | 
				
			||||||
            @onConfirm={{action
 | 
					            @onConfirm={{action
 | 
				
			||||||
              (perform
 | 
					              (perform
 | 
				
			||||||
                Item.callMethod
 | 
					                Item.callMethod
 | 
				
			||||||
                "destroyRecord"
 | 
					                "destroyRecord"
 | 
				
			||||||
                list.item
 | 
					                this.roleToDelete
 | 
				
			||||||
                (concat "Successfully deleted role " list.item.id)
 | 
					                (concat "Successfully deleted role " this.roleToDelete.id)
 | 
				
			||||||
                (concat "There was an error deleting the role " list.item.id)
 | 
					                (concat "There was an error deleting the role " this.roleToDelete.id)
 | 
				
			||||||
                (action "refresh")
 | 
					                (action "refresh")
 | 
				
			||||||
              )
 | 
					              )
 | 
				
			||||||
            }}
 | 
					            }}
 | 
				
			||||||
            @onClose={{fn (mut this.showConfirmModal) false}}
 | 
					            @onClose={{fn (mut this.roleToDelete) null}}
 | 
				
			||||||
          />
 | 
					          />
 | 
				
			||||||
        {{/if}}
 | 
					        {{/if}}
 | 
				
			||||||
      </Item.menu>
 | 
					      </Item.menu>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,24 +69,24 @@
 | 
				
			|||||||
            <dd.Interactive
 | 
					            <dd.Interactive
 | 
				
			||||||
              @text="Delete scope"
 | 
					              @text="Delete scope"
 | 
				
			||||||
              @color="critical"
 | 
					              @color="critical"
 | 
				
			||||||
              {{on "click" (fn (mut this.showConfirmModal) true)}}
 | 
					              {{on "click" (fn (mut this.scopeToDelete) list.item)}}
 | 
				
			||||||
              data-test-confirm-action-trigger
 | 
					              data-test-confirm-action-trigger
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
          {{/if}}
 | 
					          {{/if}}
 | 
				
			||||||
        </Hds::Dropdown>
 | 
					        </Hds::Dropdown>
 | 
				
			||||||
        {{#if this.showConfirmModal}}
 | 
					        {{#if (eq this.scopeToDelete list.item)}}
 | 
				
			||||||
          <ConfirmModal
 | 
					          <ConfirmModal
 | 
				
			||||||
            @color="critical"
 | 
					            @color="critical"
 | 
				
			||||||
            @confirmTitle="Delete scope {{list.item.id}}?"
 | 
					            @confirmTitle="Delete scope {{this.scopeToDelete.id}}?"
 | 
				
			||||||
            @confirmMessage="This will permanently delete this scope and all roles and credentials contained within"
 | 
					            @confirmMessage="This will permanently delete this scope and all roles and credentials contained within"
 | 
				
			||||||
            @onClose={{fn (mut this.showConfirmModal) false}}
 | 
					            @onClose={{fn (mut this.scopeToDelete) null}}
 | 
				
			||||||
            @onConfirm={{action
 | 
					            @onConfirm={{action
 | 
				
			||||||
              (perform
 | 
					              (perform
 | 
				
			||||||
                Item.callMethod
 | 
					                Item.callMethod
 | 
				
			||||||
                "destroyRecord"
 | 
					                "destroyRecord"
 | 
				
			||||||
                list.item
 | 
					                this.scopeToDelete
 | 
				
			||||||
                (concat "Successfully deleted scope " list.item.id)
 | 
					                (concat "Successfully deleted scope " this.scopeToDelete.id)
 | 
				
			||||||
                (concat "There was an error deleting the scope " list.item.id)
 | 
					                (concat "There was an error deleting the scope " this.scopeToDelete.id)
 | 
				
			||||||
                (action "refresh")
 | 
					                (action "refresh")
 | 
				
			||||||
              )
 | 
					              )
 | 
				
			||||||
            }}
 | 
					            }}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user