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 2 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;
}
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>
{{this.modalDisplay.title}}
</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
Loading