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: Part 4 - hds adoption replace <Modal> #23451

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions ui/app/styles/core/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@
color: $red-500;
}

&.is-warning-outlined {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing because this color doesn't exist in HDS buttons

background-color: $yellow-010;
border: 1px solid $yellow-700;
color: $yellow-700;
}

&.is-flat {
min-width: auto;
border: none;
Expand Down
7 changes: 7 additions & 0 deletions ui/app/styles/core/element-styling.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,10 @@ form {
label {
cursor: pointer;
}

// HDS modifications
.hds-modal {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure where to put this - if there are more I may create a separate file, but it seemed okay here for now

// if a component contains a modal, the modal inherits styling from the parent container
// i.e. if a toolbar button opens a modal
white-space: wrap;
}
5 changes: 0 additions & 5 deletions ui/lib/core/addon/helpers/message-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ export const MESSAGE_TYPES = {
glyph: 'loading',
text: 'Loading',
},
rotation: {
class: 'is-info',
glyphClass: 'has-text-grey',
glyph: 'rotate-cw',
},
};

export function messageTypes([type]) {
Expand Down
31 changes: 13 additions & 18 deletions ui/lib/kubernetes/addon/components/page/configure.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,21 @@
</div>

{{#if this.showConfirm}}
<Modal
@title="Edit configuration"
@type="warning"
@isActive={{this.showConfirm}}
@showCloseButton={{true}}
@onClose={{fn (mut this.showConfirm) false}}
>
<section class="modal-card-body">
<Hds::Modal id="kubernetes-edit-config-modal" @onClose={{fn (mut this.showConfirm) false}} @color="warning" as |M|>
<M.Header @icon="alert-triangle">
Edit configuration
</M.Header>
<M.Body>
<p>
Making changes to your configuration may affect how Vault will reach the Kubernetes API and authenticate with it. Are
you sure?
</p>
</section>
<footer class="modal-card-foot modal-card-foot-outlined">
<button data-test-config-confirm type="button" class="button is-primary" {{on "click" (perform this.save)}}>
Confirm
</button>
<button type="button" class="button" onclick={{fn (mut this.showConfirm) false}}>
Cancel
</button>
</footer>
</Modal>
</M.Body>
<M.Footer as |F|>
<Hds::ButtonSet>
<Hds::Button data-test-config-confirm {{on "click" (perform this.save)}} @text="Confirm" />
<Hds::Button {{on "click" F.close}} @color="secondary" @text="Cancel" />
</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
{{/if}}
55 changes: 31 additions & 24 deletions ui/lib/kv/addon/components/kv-delete-modal.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<button type="button" class="toolbar-link" {{on "click" (fn (mut this.modalOpen) true)}} data-test-kv-delete={{@mode}}>
{{yield}}
</button>
<Hds::Button
@text={{or @text (capitalize @mode)}}
@color="secondary"
class="toolbar-button"
{{on "click" (fn (mut this.modalOpen) true)}}
data-test-kv-delete={{@mode}}
/>

{{#if this.modalOpen}}
<Modal
@title={{this.modalDisplay.title}}
<Hds::Modal
id="kv-delete-modal-{{@mode}}"
@color={{this.modalDisplay.color}}
@onClose={{fn (mut this.modalOpen) false}}
@isActive={{this.modalOpen}}
@type={{this.modalDisplay.type}}
@showCloseButton={{true}}
data-test-delete-modal
as |M|
>
<section class="modal-card-body">
<M.Header @icon="trash">
{{this.modalDisplay.title}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is every header going to be a trash icon or should we add an icon key to the modalDisplay object in the component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all delete related, so they'll all have the trash!

</M.Header>
<M.Body>
<p class="has-bottom-margin-s">
{{this.modalDisplay.intro}}
</p>
Expand Down Expand Up @@ -45,19 +52,19 @@
{{/each}}
</div>
{{/if}}
</section>
<footer class="modal-card-foot modal-card-foot-outlined">
<button
type="button"
class="button {{if (eq this.modalDisplay.type 'danger') 'is-danger-outlined' 'is-warning-outlined'}}"
{{on "click" this.onDelete}}
data-test-delete-modal-confirm
>
Confirm
</button>
<button type="button" class="button is-secondary" {{on "click" (fn (mut this.modalOpen) false)}}>
Cancel
</button>
</footer>
</Modal>
</M.Body>
<M.Footer as |F|>
<Hds::ButtonSet>
<Hds::Button
@text="Confirm"
{{on "click" this.onDelete}}
@color={{if (eq this.modalDisplay.color "critical") this.modalDisplay.color}}
data-test-delete-modal-confirm
/>

<Hds::Button @text="Cancel" @color="secondary" {{on "click" F.close}} />

</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
{{/if}}
7 changes: 4 additions & 3 deletions ui/lib/kv/addon/components/kv-delete-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { assert } from '@ember/debug';
* @param {string} mode - delete, delete-metadata, or destroy.
* @param {object} secret - The kv/data model.
* @param {object} [metadata] - The kv/metadata model. It is only required when mode is "delete" or "metadata-delete".
* @param {string} [text] - Button text that renders in KV v2 toolbar, defaults to capitalize @mode
* @param {callback} onDelete - callback function fired to handle delete event.
*/

Expand All @@ -34,20 +35,20 @@ export default class KvDeleteModal extends Component {
case 'delete':
return {
title: 'Delete version?',
type: 'warning',
color: 'warning',
intro:
'There are two ways to delete a version of a secret. Both delete actions can be undeleted later. How would you like to proceed?',
};
case 'destroy':
return {
title: 'Destroy version?',
type: 'danger',
color: 'critical',
intro: `This action will permanently destroy Version ${this.args.version} of the secret, and the secret data cannot be read or recovered later.`,
};
case 'delete-metadata':
return {
title: 'Delete metadata and secret data?',
type: 'danger',
color: 'critical',
intro:
'This will permanently delete the metadata and versions of the secret. All version history will be removed. This cannot be undone.',
};
Expand Down
8 changes: 2 additions & 6 deletions ui/lib/kv/addon/components/page/secret/details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@
@metadata={{@metadata}}
@onDelete={{this.handleDestruction}}
@version={{this.version}}
>
Delete
</KvDeleteModal>
/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-10-02 at 2 06 12 PM

{{/if}}
{{#if this.showDestroy}}
<KvDeleteModal @mode="destroy" @secret={{@secret}} @onDelete={{this.handleDestruction}} @version={{this.version}}>
Destroy
</KvDeleteModal>
<KvDeleteModal @mode="destroy" @secret={{@secret}} @onDelete={{this.handleDestruction}} @version={{this.version}} />
{{/if}}
{{#if (or @secret.canReadData @secret.canReadMetadata @secret.canEditData)}}
<div class="toolbar-separator"></div>
Expand Down
9 changes: 6 additions & 3 deletions ui/lib/kv/addon/components/page/secret/metadata/details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

<:toolbarActions>
{{#if @secret.canDeleteMetadata}}
<KvDeleteModal @mode="delete-metadata" @metadata={{@metadata}} @onDelete={{this.onDelete}}>
Permanently delete
</KvDeleteModal>
<KvDeleteModal
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-10-02 at 2 06 30 PM

@mode="delete-metadata"
@metadata={{@metadata}}
@onDelete={{this.onDelete}}
@text="Permanently delete"
/>
{{/if}}
{{#if @secret.canUpdateMetadata}}
<ToolbarLink @route="secret.metadata.edit" data-test-edit-metadata>Edit metadata</ToolbarLink>
Expand Down
54 changes: 26 additions & 28 deletions ui/lib/ldap/addon/components/accounts-checked-out.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,35 @@
</OverviewCard>

{{#if this.selectedStatus}}
<Modal
@title="Account Check-in"
@isActive={{this.selectedStatus}}
@showCloseButton={{true}}
@onClose={{fn (mut this.selectedStatus) undefined}}
>
<section class="modal-card-body">
<Hds::Modal id="account-check-in-modal" @onClose={{fn (mut this.selectedStatus) undefined}} as |M|>
<M.Header>
Account Check-in
</M.Header>
<M.Body>
<p>
This action will check-in account
{{this.selectedStatus.account}}
back to the library. Do you want to proceed?
</p>
</section>
<footer class="modal-card-foot modal-card-foot-outlined">
<button
type="button"
class="button is-primary {{if this.save.isRunning 'is-loading'}}"
disabled={{this.checkIn.isRunning}}
data-test-check-in-confirm
{{on "click" (perform this.checkIn)}}
>
Confirm
</button>
<button
type="button"
class="button"
disabled={{this.checkIn.isRunning}}
{{on "click" (fn (mut this.selectedStatus) "")}}
>
Cancel
</button>
</footer>
</Modal>
</M.Body>
<M.Footer>
<Hds::ButtonSet>
<Hds::Button
@icon={{if this.save.isRunning "is-loading"}}
disabled={{this.checkIn.isRunning}}
data-test-check-in-confirm
{{on "click" (perform this.checkIn)}}
@text="Confirm"
/>
<Hds::Button
@icon={{if this.save.isRunning "is-loading"}}
@color="secondary"
disabled={{this.checkIn.isRunning}}
{{on "click" (fn (mut this.selectedStatus) "")}}
@text="Cancel"
/>

</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
{{/if}}
41 changes: 18 additions & 23 deletions ui/lib/ldap/addon/components/page/configure.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,11 @@
</form>

{{#if this.showRotatePrompt}}
<Modal
@title="Rotate your root password?"
@type="info"
@isActive={{this.showRotatePrompt}}
@showCloseButton={{true}}
@onClose={{fn (mut this.showRotatePrompt) false}}
>
<section class="modal-card-body">
<Hds::Modal id="ldap-rotate-password-modal" @onClose={{fn (mut this.showRotatePrompt) false}} as |M|>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiousity - do modals always need id's now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I can tell - but I wondered if screen readers used them. I also thought that we could use them in a general test selector .hds-modal#${id}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying, Claire! I think it's a great pattern to add the ids to each modal :)

<M.Header @icon="info">
Rotate your root password?
</M.Header>
<M.Body>
<p>
It’s best practice to rotate the administrator (root) password immediately after the initial configuration of the
LDAP engine. The rotation will update the password both in Vault and your directory server. Once rotated,
Expand All @@ -95,19 +92,17 @@
<p>
Would you like to rotate your new credentials? You can also do this later.
</p>
</section>
<footer class="modal-card-foot modal-card-foot-outlined">
<button
data-test-save-with-rotate
type="button"
class="button is-primary"
{{on "click" (fn (perform this.save) null true)}}
>
Save and rotate
</button>
<button data-test-save-without-rotate type="button" class="button" {{on "click" (fn (perform this.save) null false)}}>
Save without rotating
</button>
</footer>
</Modal>
</M.Body>
<M.Footer>
<Hds::ButtonSet>
<Hds::Button data-test-save-with-rotate @text="Save and rotate" {{on "click" (fn (perform this.save) null true)}} />
<Hds::Button
data-test-save-without-rotate
@text="Save without rotating"
@color="secondary"
{{on "click" (fn (perform this.save) null false)}}
/>
</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
{{/if}}
35 changes: 13 additions & 22 deletions ui/lib/ldap/addon/components/page/library/details/accounts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,23 @@
</div>

{{#if this.showCheckOutPrompt}}
<Modal
@title="Account Check-out"
@isActive={{this.showCheckOutPrompt}}
@showCloseButton={{true}}
@onClose={{fn (mut this.showCheckOutPrompt) false}}
>
<section class="modal-card-body">
<Hds::Modal id="account-check-out-modal" @onClose={{fn (mut this.showCheckOutPrompt) false}} as |M|>
<M.Header>
Account Check-out
</M.Header>
<M.Body>
<p>
Current generated credential’s time-to-live is set at
{{format-duration @library.ttl}}. You can set a different limit if you’d like:
</p>
<br />
<TtlPicker @label="TTL" @hideToggle={{true}} @initialValue={{@library.ttl}} @onChange={{this.setTtl}} />
</section>
<footer class="modal-card-foot modal-card-foot-outlined">
<button data-test-check-out="save" type="button" class="button is-primary" {{on "click" this.checkOut}}>
Check-out
</button>
<button
data-test-check-out="cancel"
type="button"
class="button"
{{on "click" (fn (mut this.showCheckOutPrompt) false)}}
>
Cancel
</button>
</footer>
</Modal>
</M.Body>
<M.Footer as |F|>
<Hds::ButtonSet>
<Hds::Button data-test-check-out="save" @text="Check-out" {{on "click" this.checkOut}} />
<Hds::Button data-test-check-out="cancel" @text="Cancel" @color="secondary" {{on "click" F.close}} />
</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
{{/if}}
Loading
Loading