Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Hds::Dropdown replace PopupMenu #25321

Merged
merged 60 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
fbdeda6
Move confirm-modal to its own component so it can be used with dropdowns
hashishaw Jan 24, 2024
aa3b8ee
Refactor popup-metadata component
hashishaw Jan 24, 2024
4acacd0
Refactor popup-members component
hashishaw Jan 24, 2024
60c07fd
cleanup, confirm-action uses confirm-modal
hashishaw Jan 24, 2024
8ced2dd
Refactor PopupAlias
hashishaw Jan 24, 2024
2a5ca5e
cleanup, test selectors
hashishaw Jan 24, 2024
3fe23e9
refactor popup-policy
hashishaw Jan 24, 2024
0764acf
remove popup-base
hashishaw Jan 24, 2024
0e40f25
replace popup-menu in mfa components
hashishaw Jan 25, 2024
b3ebb65
replace popup-menu in secret-list
hashishaw Jan 25, 2024
496c95d
replace popup-menu in transit-form-show
hashishaw Jan 25, 2024
fdff18f
replace popup-menu on ssh-role-item
hashishaw Jan 25, 2024
77ee6ba
replace popup-menu in aws-role-item
hashishaw Jan 25, 2024
6870150
replace popup-menu in database-list-item
hashishaw Jan 25, 2024
cb489d6
add confirm-modal test
hashishaw Jan 25, 2024
c4d300b
Update popup-menu on oidc/client-list, plus tests
hashishaw Jan 25, 2024
ed98c4d
replace popup-menu in oidc/provider-list, with test
hashishaw Jan 25, 2024
0914966
replace popup-menu on transform list items
hashishaw Jan 25, 2024
7e88157
replace popup-menu on kv list component
hashishaw Jan 25, 2024
8875feb
replace popup-menu on kv version list
hashishaw Jan 25, 2024
7482e08
replace popup-menu on pki lists
hashishaw Jan 25, 2024
c101a7f
fix belongsTo capabilities relationship
hashishaw Feb 5, 2024
7e4b91f
use hds::dropdown in policy list
hellobontempo Feb 6, 2024
db13279
fix @text args from copy pasta
hellobontempo Feb 6, 2024
32978c4
rename policy tracked property and still pass in to function
hellobontempo Feb 6, 2024
db192c2
add copyright headers
hellobontempo Feb 7, 2024
e90e1e2
add changelog;
hellobontempo Feb 7, 2024
0fc9760
identity index and tests
hellobontempo Feb 7, 2024
ba0bccd
oidc resources
hellobontempo Feb 7, 2024
6b46155
test fixes for first 29 cherrypicked commits ending with: ba0bccd1e08…
hellobontempo Feb 8, 2024
1a66fb9
cherry-pick of 'auth method and secret engines popup menus' and skip …
hellobontempo Feb 8, 2024
e4bfed2
rename changelog add one more copyright header
hellobontempo Feb 8, 2024
c7c48e4
whoops theres the header
hellobontempo Feb 8, 2024
77186bf
fix stable identifier issue in auth backend list: userpass secret bac…
hellobontempo Feb 8, 2024
37b48ee
custom message list
hellobontempo Feb 7, 2024
b5fc951
secondary menu;
hellobontempo Feb 7, 2024
fbfa01a
wizard popup
hellobontempo Feb 7, 2024
66854a9
Revert "wizard popup"
hellobontempo Feb 9, 2024
ebc96b7
Revert "secondary menu;"
hellobontempo Feb 9, 2024
14253ff
Revert "custom message list"
hellobontempo Feb 9, 2024
8aa9e93
Revert "fix stable identifier issue in auth backend list: userpass se…
hellobontempo Feb 9, 2024
f0db94c
Revert "whoops theres the header"
hellobontempo Feb 9, 2024
81d2748
Revert "rename changelog add one more copyright header"
hellobontempo Feb 9, 2024
f810938
Revert "cherry-pick of 'auth method and secret engines popup menus' a…
hellobontempo Feb 9, 2024
7f4ecd8
actually add copyright header and rename changelog
hellobontempo Feb 9, 2024
c892405
custom message list
hellobontempo Feb 7, 2024
88864c8
policies index; replication secondary
hellobontempo Feb 9, 2024
8e06bb4
wizard popup
hellobontempo Feb 7, 2024
f21f9e5
rename metadata tracked
hellobontempo Feb 9, 2024
cf73b9c
add listPosition for clarity
hellobontempo Feb 9, 2024
b6ecef6
remove @color=secondary args from interactive elements
hellobontempo Feb 7, 2024
91e3ae1
fix qp arg and update to @query for dd.Interactive
hellobontempo Feb 9, 2024
b2f4cff
add loading spinner because its nice
hellobontempo Feb 7, 2024
fdd7878
attempt of backends.hbs dropdown
hellobontempo Feb 9, 2024
49eca9c
attempt of methods.hbs
hellobontempo Feb 9, 2024
878c0c3
Revert "attempt of methods.hbs"
hellobontempo Feb 9, 2024
a500371
Merge branch 'main' into ui/VAULT-17697/hds-dropdown-replace-popup-menu
hashishaw Feb 9, 2024
86787a1
remove space
hashishaw Feb 9, 2024
1a86c63
Merge branch 'main' into ui/VAULT-17697/hds-dropdown-replace-popup-menu
hashishaw Feb 9, 2024
9ea0aed
capabilities relationship is not async
hashishaw Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/25321.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Use Hds::Dropdown component to replace list view popup menus
```
46 changes: 0 additions & 46 deletions ui/app/components/identity/_popup-base.js

This file was deleted.

51 changes: 32 additions & 19 deletions ui/app/components/identity/popup-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,38 @@
* SPDX-License-Identifier: BUSL-1.1
*/

import Base from './_popup-base';
import Component from '@glimmer/component';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import errorMessage from 'vault/utils/error-message';

export default Base.extend({
messageArgs(model) {
const type = model.get('identityType');
const id = model.id;
return [type, id];
},
export default class IdentityPopupAlias extends Component {
@service flashMessages;
@tracked showConfirmModal = false;

successMessage(type, id) {
return `Successfully deleted ${type}: ${id}`;
},
onSuccess(type, id) {
if (this.args.onSuccess) {
this.args.onSuccess();
}
this.flashMessages.success(`Successfully deleted ${type}: ${id}`);
}
onError(err, type, id) {
if (this.args.onError) {
this.args.onError();
}
const error = errorMessage(err);
this.flashMessages.danger(`There was a problem deleting ${type}: ${id} - ${error}`);
}

errorMessage(e, type, id) {
const error = e.errors ? e.errors.join(' ') : e.message;
return `There was a problem deleting ${type}: ${id} - ${error}`;
},

transaction(model) {
return model.destroyRecord();
},
});
@action
async deleteAlias() {
const { identityType, id } = this.args.item;
try {
await this.args.item.destroyRecord();
this.onSuccess(identityType, id);
} catch (e) {
this.onError(e, identityType, id);
}
}
}
75 changes: 41 additions & 34 deletions ui/app/components/identity/popup-members.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@
* SPDX-License-Identifier: BUSL-1.1
*/

import { alias } from '@ember/object/computed';
import { computed } from '@ember/object';
import Base from './_popup-base';

export default Base.extend({
model: alias('params.firstObject'),

groupArray: computed('params', function () {
return this.params.objectAt(1);
}),

memberId: computed('params', function () {
return this.params.objectAt(2);
}),

messageArgs(/*model, groupArray, memberId*/) {
return [...arguments];
},

successMessage(model, groupArray, memberId) {
return `Successfully removed '${memberId}' from the group`;
},

errorMessage(e, model, groupArray, memberId) {
const error = e.errors ? e.errors.join(' ') : e.message;
return `There was a problem removing '${memberId}' from the group - ${error}`;
},

transaction(model, groupArray, memberId) {
const members = model.get(groupArray);
model.set(groupArray, members.without(memberId));
return model.save();
},
});
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import errorMessage from 'vault/utils/error-message';

export default class IdentityPopupMembers extends Component {
@service flashMessages;
@tracked showConfirmModal = false;

onSuccess(memberId) {
if (this.args.onSuccess) {
this.args.onSuccess();
}
this.flashMessages.success(`Successfully removed '${memberId}' from the group`);
}
onError(err, memberId) {
if (this.args.onError) {
this.args.onError();
}
const error = errorMessage(err);
this.flashMessages.danger(`There was a problem removing '${memberId}' from the group - ${error}`);
}

transaction() {
const members = this.args.model[this.args.groupArray];
this.args.model[this.args.groupArray] = members.without(this.args.memberId);
return this.args.model.save();
}

@action
async removeGroup() {
const memberId = this.args.memberId;
try {
await this.transaction();
this.onSuccess(memberId);
} catch (e) {
this.onError(e, memberId);
}
}
}
63 changes: 38 additions & 25 deletions ui/app/components/identity/popup-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,45 @@
* SPDX-License-Identifier: BUSL-1.1
*/

import Base from './_popup-base';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { action } from '@ember/object';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import errorMessage from 'vault/utils/error-message';

export default Base.extend({
model: alias('params.firstObject'),
key: computed('params', function () {
return this.params.objectAt(1);
}),
export default class IdentityPopupMetadata extends Component {
@service flashMessages;
@tracked showConfirmModal = false;

messageArgs(model, key) {
return [model, key];
},
onSuccess(key) {
if (this.args.onSuccess) {
this.args.onSuccess();
}
this.flashMessages.success(`Successfully removed '${key}' from metadata`);
}
onError(err, key) {
if (this.args.onError) {
this.args.onError();
}
const error = errorMessage(err);
this.flashMessages.danger(`There was a problem removing '${key}' from the metadata - ${error}`);
}

successMessage(model, key) {
return `Successfully removed '${key}' from metadata`;
},
errorMessage(e, model, key) {
const error = e.errors ? e.errors.join(' ') : e.message;
return `There was a problem removing '${key}' from the metadata - ${error}`;
},
transaction() {
const metadata = this.args.model.metadata;
delete metadata[this.args.key];
this.args.model.metadata = { ...metadata };
return this.args.model.save();
}

transaction(model, key) {
const metadata = model.metadata;
delete metadata[key];
model.set('metadata', { ...metadata });
return model.save();
},
});
@action
async removeMetadata() {
const key = this.args.key;
try {
await this.transaction();
this.onSuccess(key);
} catch (e) {
this.onError(e, key);
}
}
}
65 changes: 40 additions & 25 deletions ui/app/components/identity/popup-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,47 @@
* SPDX-License-Identifier: BUSL-1.1
*/

import { alias } from '@ember/object/computed';
import { computed } from '@ember/object';
import Base from './_popup-base';
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { service } from '@ember/service';
import errorMessage from 'vault/utils/error-message';
import { tracked } from '@glimmer/tracking';

export default Base.extend({
model: alias('params.firstObject'),
policyName: computed('params', function () {
return this.params.objectAt(1);
}),
export default class IdentityPopupPolicy extends Component {
@service flashMessages;
@tracked showConfirmModal = false;

messageArgs(model, policyName) {
return [model, policyName];
},
onSuccess(policyName, modelId) {
if (this.args.onSuccess) {
this.args.onSuccess();
}
this.flashMessages.success(`Successfully removed '${policyName}' policy from ${modelId} `);
hashishaw marked this conversation as resolved.
Show resolved Hide resolved
}
onError(err, policyName) {
if (this.args.onError) {
this.args.onError();
}
const error = errorMessage(err);
this.flashMessages.danger(`There was a problem removing '${policyName}' policy - ${error}`);
}

successMessage(model, policyName) {
return `Successfully removed '${policyName}' policy from ${model.id} `;
},
transaction() {
const policies = this.args.model.policies;
this.args.model.policies = policies.without(this.args.policyName);
return this.args.model.save();
}

errorMessage(e, model, policyName) {
const error = e.errors ? e.errors.join(' ') : e.message;
return `There was a problem removing '${policyName}' policy - ${error}`;
},

transaction(model, policyName) {
const policies = model.get('policies');
model.set('policies', policies.without(policyName));
return model.save();
},
});
@action
async removePolicy() {
const {
policyName,
model: { id },
} = this.args;
try {
await this.transaction();
this.onSuccess(policyName, id);
} catch (e) {
this.onError(e, policyName);
}
}
}
11 changes: 11 additions & 0 deletions ui/app/components/secret-list/aws-role-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class SecretListAwsRoleItemComponent extends Component {
@tracked showConfirmModal = false;
}
11 changes: 11 additions & 0 deletions ui/app/components/secret-list/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class SecretListItemComponent extends Component {
@tracked showConfirmModal = false;
}
11 changes: 11 additions & 0 deletions ui/app/components/secret-list/ssh-role-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class SecretListSshRoleItemComponent extends Component {
@tracked showConfirmModal = false;
}
9 changes: 8 additions & 1 deletion ui/app/controllers/vault/cluster/access/identity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import ListController from 'core/mixins/list-controller';
export default Controller.extend(ListController, {
flashMessages: service(),

entityToDisable: null,
itemToDelete: null,

// callback from HDS pagination to set the queryParams page
get paginationQueryParams() {
return (page) => {
Expand All @@ -33,6 +36,9 @@ export default Controller.extend(ListController, {
this.flashMessages.success(
`There was a problem deleting ${type}: ${id} - ${e.errors.join(' ') || e.message}`
);
})
.finally(() => {
this.set('itemToDelete', null);
});
},

Expand All @@ -51,7 +57,8 @@ export default Controller.extend(ListController, {
this.flashMessages.success(
`There was a problem ${action[1]} ${type}: ${id} - ${e.errors.join(' ') || e.message}`
);
});
})
.finally(() => this.set('entityToDisable', null));
},
reloadRecord(model) {
model.reload();
Expand Down
Loading
Loading