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/transit modal #8575

Merged
merged 43 commits into from Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b0bc2c9
wip -- add modal component using ember-wormhole, add static content b…
noelledaley Jan 31, 2020
a2cd2ef
add onClose to modal
noelledaley Jan 31, 2020
871d73d
WIP
noelledaley Feb 3, 2020
3317658
add copy and close button
noelledaley Mar 5, 2020
fc43094
add copy and close button
noelledaley Mar 5, 2020
6446835
and copy and close button to modal
noelledaley Mar 5, 2020
69e5898
use modal on each key action page
noelledaley Mar 5, 2020
977061c
make text copied text more generic
noelledaley Mar 5, 2020
1ec7fc5
update datakey textareas to codemirror
noelledaley Mar 5, 2020
31eebde
only show user input on encrypt and decrypt
noelledaley Mar 5, 2020
45509a3
only show user input on all key actions
noelledaley Mar 5, 2020
ff2d630
separate copy ciphertext, plaintext, and close button on datakey modal
noelledaley Mar 5, 2020
050a9bb
style ciphertext and plaintext as code
noelledaley Mar 5, 2020
6dfc0ee
only show separate copy buttons on datakey modal if both outputs are …
noelledaley Mar 5, 2020
41547a8
update modal styling
noelledaley Mar 6, 2020
1d15670
style modal
noelledaley Mar 6, 2020
405a7c4
add descriptions to each key action
noelledaley Mar 6, 2020
ec03440
remove conditional from hmac modal since we only ever show hmac output
noelledaley Mar 6, 2020
333637c
add modal for export key action
noelledaley Mar 6, 2020
3c61fea
make output scroll horizontally with copy button next to it
noelledaley Mar 7, 2020
56eabd4
make output scroll horizontally with copy button next to it
noelledaley Mar 7, 2020
38c680c
escape & in copy and close button, format text output so it scrolls h…
noelledaley Mar 7, 2020
3dd903b
fix formatting of key action descriptions
noelledaley Mar 7, 2020
c58ad93
Ui/add transit modal tests (#8523)
chelshaw Mar 11, 2020
edd28bb
WIP // remove box shadow from key actions descriptions
chelshaw Mar 12, 2020
d301802
WIP // flash messages on successful action match mocks
chelshaw Mar 12, 2020
5820104
WIP // remove ciphertext view after datakey created
chelshaw Mar 12, 2020
8140808
WIP // make flash messages when copy & closing less generic, and matc…
chelshaw Mar 12, 2020
d5d5948
WIP // Optionally show close button on modal, with tests
chelshaw Mar 12, 2020
c4f301b
remove unused deps from modal test
chelshaw Mar 12, 2020
c0c484c
WIP // Fix verify modal styling and content
chelshaw Mar 13, 2020
976ac31
Add modal for sign action
chelshaw Mar 13, 2020
44f275b
Fix output of non-wrapped export key
chelshaw Mar 13, 2020
308a73a
Fix output of non-wrapped export key
chelshaw Mar 13, 2020
f44ead5
Add description to JSDOCS about modal component
chelshaw Mar 13, 2020
ede8168
Add help text about plaintext encoded in base64
chelshaw Mar 13, 2020
c6b7043
add flash msgs for datakey and export
noelledaley Mar 13, 2020
3e63aed
flash success msg when closing modal on export page
noelledaley Mar 13, 2020
fac589b
clarify sign success msg
noelledaley Mar 13, 2020
d22be37
address PR feedback
noelledaley Mar 13, 2020
848acf1
add indentation for export key json
noelledaley Mar 13, 2020
07e9c9d
Fix modal tests pt 2
chelshaw Mar 13, 2020
4596626
Remove decode after decrypt in transit tests
chelshaw Mar 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions ui/app/components/modal.js
@@ -0,0 +1,21 @@
/**
* @module Modal
* Modal components are used to overlay content on top of the page. Has a darkened background,
* a title, and in order to close it you must pass an onClose function.
*
* @example
* ```js
* <Modal @title={'myTitle'} @showCloseButton={true} @onClose={() => {}}/>
* ```
* @param {function} onClose - onClose is the action taken when someone clicks the modal background or close button (if shown).
* @param {string} [title] - This text shows up in the header section of the modal.
* @param {boolean} [showCloseButton=false] - controls whether the close button in the top right corner shows.
*/

import Component from '@ember/component';

export default Component.extend({
title: null,
showCloseButton: false,
onClose: () => {},
});
29 changes: 28 additions & 1 deletion ui/app/components/transit-key-actions.js
Expand Up @@ -43,12 +43,24 @@ const PARAMS_FOR_ACTION = {
decrypt: ['ciphertext', 'context', 'nonce'],
rewrap: ['ciphertext', 'context', 'nonce', 'key_version'],
};
const SUCCESS_MESSAGE_FOR_ACTION = {
sign: 'Signed your data',
// the verify action doesn't trigger a success message
hmac: 'Created your hash output',
encrypt: 'Created a wrapped token for your data',
decrypt: 'Decrypted the data from your token',
rewrap: 'Created a new token for your data',
datakey: 'Generated your key',
export: 'Exported your key',
};
export default Component.extend(TRANSIT_PARAMS, {
store: service(),
flashMessages: service(),

// public attrs
selectedAction: null,
key: null,
isModalActive: false,

onRefresh() {},
init() {
Expand Down Expand Up @@ -137,6 +149,12 @@ export default Component.extend(TRANSIT_PARAMS, {
this.set('errors', null);
},

triggerSuccessMessage(action) {
const message = SUCCESS_MESSAGE_FOR_ACTION[action];
if (!message) return;
this.get('flashMessages').success(message);
},

handleSuccess(resp, options, action) {
let props = {};
if (resp && resp.data) {
Expand All @@ -149,10 +167,12 @@ export default Component.extend(TRANSIT_PARAMS, {
if (options.wrapTTL) {
props = assign({}, props, { wrappedToken: resp.wrap_info.token });
}
this.toggleProperty('isModalActive');
this.setProperties(props);
if (action === 'rotate') {
this.get('onRefresh')();
}
this.triggerSuccessMessage(action);
},

compactData(data) {
Expand Down Expand Up @@ -184,6 +204,13 @@ export default Component.extend(TRANSIT_PARAMS, {
arr.forEach(param => this.set(param, null));
},

toggleModal(successMessage) {
if (!!successMessage && typeof successMessage === 'string') {
this.get('flashMessages').success(successMessage);
}
this.toggleProperty('isModalActive');
},

doSubmit(data, options = {}) {
const { backend, id } = this.getModelInfo();
const action = this.get('selectedAction');
Expand All @@ -192,7 +219,7 @@ export default Component.extend(TRANSIT_PARAMS, {
if (action === 'encrypt' && !!formData.plaintext) {
formData.plaintext = encodeString(formData.plaintext);
}
if ((action === 'hmac' || action === 'verify') && !!formData.input) {
if ((action === 'hmac' || action === 'verify' || action === 'sign') && !!formData.input) {
formData.input = encodeString(formData.input);
}
}
Expand Down
44 changes: 44 additions & 0 deletions ui/app/styles/components/modal.scss
@@ -0,0 +1,44 @@
.modal-background {
background: rgb(235, 238, 242, 0.9);
}

.modal-card {
box-shadow: $box-shadow-highest;
border: 1px solid $grey-light;

&-head {
border-radius: 0;
background-color: $grey-lightest;
border-bottom: 1px solid $grey-light;
}

&-foot {
border-radius: 0;
border: 0;
background-color: $white;
}

&-title.title {
margin: 0;
}

.copy-text {
background-color: $grey-lightest;
padding: $spacing-s;
margin-bottom: $spacing-s;

code {
overflow: scroll;
max-width: calc(100% - 36px);
background-color: inherit;
}
}

.copy-close {
margin-top: $spacing-s;
}
}

pre {
background-color: inherit;
}
3 changes: 2 additions & 1 deletion ui/app/styles/components/transit-card.scss
Expand Up @@ -9,10 +9,11 @@

.transit-card {
border-radius: $radius;
box-shadow: 0 0 0 1px rgba($grey-dark, 0.3), $box-shadow-middle;
box-shadow: 0 0 0 1px rgba($grey-light, 0.4);
display: grid;
grid-template-columns: 0.45fr 2fr;
padding: $spacing-m;
border: none;

.transit-icon {
justify-self: center;
Expand Down
1 change: 1 addition & 0 deletions ui/app/styles/core.scss
Expand Up @@ -68,6 +68,7 @@
@import './components/loader';
@import './components/login-form';
@import './components/masked-input';
@import './components/modal';
@import './components/namespace-picker';
@import './components/namespace-reminder';
@import './components/navigate-input';
Expand Down
14 changes: 14 additions & 0 deletions ui/app/templates/components/modal.hbs
@@ -0,0 +1,14 @@
{{#ember-wormhole to="modal-wormhole"}}
<div class="modal {{if isActive 'is-active'}}" aria-modal="true">
<div class="modal-background" onclick={{onClose}} data-test-modal-background></div>
<div class="modal-card">
<header class="modal-card-head">
<h2 class="modal-card-title title is-5" data-test-modal-title>{{title}}</h2>
{{#if showCloseButton}}
<button class="delete" aria-label="close" onclick={{onClose}} data-test-modal-close-button></button>
{{/if}}
</header>
{{yield}}
</div>
</div>
{{/ember-wormhole}}