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: remodel shamir flow #21871

Merged
merged 26 commits into from
Jul 19, 2023
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a8a339c
clickable label on raft join
hashishaw Jul 12, 2023
76265e4
Small adjustments on current shamir components
hashishaw Jul 13, 2023
c512826
Add shamir/form with stub test
hashishaw Jul 13, 2023
c3ca3bb
Add WIP shamir/flow component which works for unseal action
hashishaw Jul 13, 2023
d6b4eb5
Use new components on unseal flow
hashishaw Jul 13, 2023
42818d3
WIP
hashishaw Jul 14, 2023
5a01308
Add ChoosePgpKeyForm component for selecting PGP key
hashishaw Jul 14, 2023
f16bf04
Add Shamir/DrTokenFlow component and updates to Shamir/Flow which it …
hashishaw Jul 14, 2023
4c749ea
Small updates to Shamir/Form
hashishaw Jul 14, 2023
79c4c7e
Use updated Shamir components for unseal and replication generate token
hashishaw Jul 14, 2023
ce6b34c
remove old shamir components
hashishaw Jul 14, 2023
d8c963e
Merge branch 'main' into ui/revisit-shamir-flow
hashishaw Jul 18, 2023
8568325
Shamir/Form test
hashishaw Jul 14, 2023
74f56f9
Move selectors to shared, Shamir::Flow tests, cleanup
hashishaw Jul 14, 2023
fda9b8d
Test coverage for cluster adapter generateDrOperationToken
hashishaw Jul 17, 2023
fd16390
Choose-pgp-key-form tests
hashishaw Jul 18, 2023
31cae97
dr-token-flow-test
hashishaw Jul 18, 2023
5ce7248
Shamir/form test cleanup
hashishaw Jul 18, 2023
43003a9
Update generateDrOperationToken to match latest docs
hashishaw Jul 18, 2023
467efcf
cleanup, address comments
hashishaw Jul 18, 2023
b0df709
fix tests
hashishaw Jul 19, 2023
646337e
Add changelog
hashishaw Jul 19, 2023
54c010a
Merge branch 'main' into ui/revisit-shamir-flow
hashishaw Jul 19, 2023
5b4aa03
Address comments
hashishaw Jul 19, 2023
c98e74d
Fix lint
hashishaw Jul 19, 2023
01c0bfc
Merge branch 'main' into ui/revisit-shamir-flow
hashishaw Jul 19, 2023
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
Prev Previous commit
Next Next commit
Add shamir/form with stub test
  • Loading branch information
hashishaw committed Jul 13, 2023

Verified

This commit was signed with the committer’s verified signature.
tomhjp Tom Proctor
commit c51282678034313652f82f028bb27667472975d3
54 changes: 54 additions & 0 deletions ui/lib/core/addon/components/shamir/form.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<form id="shamir" aria-label="shamir form" {{on "submit" (fn this.onSubmit this.key)}} ...attributes>
{{#if @errors}}
<div class="has-bottom-margin-m">
<MessageError @errors={{@errors}} />
</div>
{{/if}}
<div class="has-bottom-margin-m">
{{#if @otp}}
<Hds::Alert @type="inline" @color="highlight" class="has-bottom-margin-s" as |A|>
<A.Title>Info</A.Title>
<A.Description>
Below is the generated OTP. This will be used to encode the generated Operation Token. Make sure to save this, as
you will need it later to decode the Operation Token.
</A.Description>
</Hds::Alert>
<div class="has-background-gray-100 box has-copy-button" tabindex="-1">
<HoverCopyButton @copyValue={{@otp}} />
<h4 class="title is-7 is-marginless">
One Time Password (otp)
</h4>
<code class="is-word-break">{{@otp}}</code>
</div>
{{/if}}
{{#if (has-block)}}
{{yield}}
{{else if @formText}}
{{@formText}}
{{/if}}
</div>
<div class="field">
<label for="key" class="is-label">
Unseal Key Portion
</label>
<div class="control">
<Input class="input" @type="password" name="key" @value={{this.key}} autocomplete="off" />
</div>
</div>
<div class="columns is-mobile">
<div class="column is-narrow">
<button type="submit" class="button is-primary" disabled={{this.loading}} data-test-shamir-submit>
{{@buttonText}}
</button>
</div>
<div class="column is-flex-v-centered is-flex-end">
{{#if this.hasProgress}}
<ShamirProgress @threshold={{@threshold}} @progress={{@progress}} />
{{/if}}
</div>
</div>
{{! <div class="box-fake is-shadowless">
</div>
<div class="box is-marginless is-shadowless">
</div> }}
</form>
57 changes: 57 additions & 0 deletions ui/lib/core/addon/components/shamir/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

/**
* @module ShamirFormComponent
* These components are used to make progress against a Shamir seal.
* Depending on the response, and external polling, the component will show
* progress and optional
*
* @example
* ```js
* <ShamirForm
* @onSubmit={{this.handleKeySubmit}}
* @threshold={{cluster.threshold}}
* @progress={{cluster.progress}}
* @fetchOnInit={{true}}
* @onShamirSuccess={{transition-to "vault.cluster"}}
* />
* ```
*
* @param {Function} onSubmit - method which handles the action for shamir
* @param {number} threshold - min number of keys required to unlock shamir seal
* @param {number} progress - number of keys given so far for unlock
* @param {string} buttonText - CTA for the form submit button. Defaults to "Submit"
* @param {string} formText - text that renders on the form if no block provided
* @param {string} otp - if otp is present, it will show a section describing what to do with it
*
*/
export default class ShamirFormComponent extends Component {
@tracked key = '';
@tracked loading = false;

get buttonText() {
return this.args.buttonText || 'Submit';
}
get hasProgress() {
return this.args.progress > 0;
}
resetForm() {
this.key = '';
this.loading = false;
}

@action
async onSubmit(key, evt) {
evt.preventDefault();

if (!key) {
return;
}
// Parent handles action and passes in errors if present
// If this method throws an error, we want it to throw
await this.args.onSubmit({ key });
this.resetForm();
}
}
1 change: 1 addition & 0 deletions ui/lib/core/app/components/shamir/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'core/components/shamir/form';
26 changes: 26 additions & 0 deletions ui/tests/integration/components/shamir/form-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | shamir/form', function (hooks) {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`<Shamir::Form />`);

assert.dom(this.element).hasText('');

// Template block usage:
await render(hbs`
<Shamir::Form>
template block text
</Shamir::Form>
`);

assert.dom(this.element).hasText('template block text');
});
});