mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 20:17:59 +00:00
Add Inline Alert component
This commit is contained in:
22
ui/app/components/alert-inline.js
Normal file
22
ui/app/components/alert-inline.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import Component from '@ember/component';
|
||||||
|
import { computed } from '@ember/object';
|
||||||
|
|
||||||
|
import { messageTypes } from 'vault/helpers/message-types';
|
||||||
|
|
||||||
|
export default Component.extend({
|
||||||
|
type: null,
|
||||||
|
|
||||||
|
classNames: ['message-inline'],
|
||||||
|
|
||||||
|
textClass: computed('type', function() {
|
||||||
|
if (this.get('type') == 'danger') {
|
||||||
|
return messageTypes([this.get('type')]).glyphClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}),
|
||||||
|
|
||||||
|
alertType: computed('type', function() {
|
||||||
|
return messageTypes([this.get('type')]);
|
||||||
|
}),
|
||||||
|
});
|
||||||
@@ -22,4 +22,4 @@
|
|||||||
|
|
||||||
.splash-page-header {
|
.splash-page-header {
|
||||||
padding: $size-6 $size-5;
|
padding: $size-6 $size-5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
.unseal-warning.message {
|
.unseal-warning.message {
|
||||||
margin: -1px -1px 0;
|
margin: -1px -1px 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,3 +96,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-inline {
|
||||||
|
display: flex;
|
||||||
|
margin: -$spacing-xs 0 $spacing-l;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
flex: 0;
|
||||||
|
margin: 0 $spacing-xxs 0 0;
|
||||||
|
min-width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
8
ui/app/templates/components/alert-inline.hbs
Normal file
8
ui/app/templates/components/alert-inline.hbs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<ICon
|
||||||
|
@glyph="{{alertType.glyph}}"
|
||||||
|
@class="{{alertType.glyphClass}}"
|
||||||
|
@size="16"
|
||||||
|
/>
|
||||||
|
<p class="{{textClass}}">
|
||||||
|
{{message}}
|
||||||
|
</p>
|
||||||
@@ -125,9 +125,10 @@
|
|||||||
/>
|
/>
|
||||||
{{#if attr.options.validationAttr}}
|
{{#if attr.options.validationAttr}}
|
||||||
{{#if (and (get model valuePath) (not (get model attr.options.validationAttr)))}}
|
{{#if (and (get model valuePath) (not (get model attr.options.validationAttr)))}}
|
||||||
<p class="has-text-danger">
|
<AlertInline
|
||||||
{{attr.options.invalidMessage}}
|
@type="danger"
|
||||||
</p>
|
@message={{attr.options.invalidMessage}}
|
||||||
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{{#each displayErrors as |error|}}
|
{{#each displayErrors as |error|}}
|
||||||
<AlertBanner
|
<AlertBanner
|
||||||
@type="danger"
|
@type="danger"
|
||||||
@message="{{error}}"
|
@message={{error}}
|
||||||
data-test-error
|
data-test-error
|
||||||
/>
|
/>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
{{#if warning}}
|
{{#if warning}}
|
||||||
<AlertBanner
|
<AlertBanner
|
||||||
@type="warning"
|
@type="warning"
|
||||||
@message="{{warning}}"
|
@message={{warning}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#each inputList as |data index|}}
|
{{#each inputList as |data index|}}
|
||||||
|
|||||||
@@ -7,14 +7,18 @@
|
|||||||
(not model.performance.replicationDisabled)
|
(not model.performance.replicationDisabled)
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
<p data-test-demote-warning>
|
|
||||||
<em class="has-text-danger">Caution</em>: Demoting this DR primary cluster
|
<div data-test-demote-warning>
|
||||||
would result in a DR secondary and in that mode Vault is read-only. This
|
<AlertInline
|
||||||
cluster is also currently operating as a Performance
|
@type="danger"
|
||||||
{{capitalize model.performance.modeForUrl}}, demoting it will leave your
|
@message="Demoting this DR primary cluster
|
||||||
replication setup without a performance primary cluster until a new
|
would result in a DR secondary and in that mode Vault is read-only. This
|
||||||
cluster is promoted.
|
cluster is also currently operating as a Performance
|
||||||
</p>
|
capitalize model.performance.modeForUrl}}, demoting it will leave your
|
||||||
|
replication setup without a performance primary cluster until a new
|
||||||
|
cluster is promoted."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<p>
|
<p>
|
||||||
Demote this {{replicationDisplayMode}} primary cluster to a {{replicationDisplayMode}} secondary. The resulting secondary cluster will not
|
Demote this {{replicationDisplayMode}} primary cluster to a {{replicationDisplayMode}} secondary. The resulting secondary cluster will not
|
||||||
|
|||||||
@@ -31,10 +31,10 @@
|
|||||||
The cluster will no longer be able to connect to the primary.
|
The cluster will no longer be able to connect to the primary.
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<AlertInline
|
||||||
<em class="has-text-danger">Caution</em>: re-enabling this node as a primary or secondary will
|
@type="danger"
|
||||||
change its cluster ID.
|
@message="Caution: re-enabling this node as a primary or secondary will change its cluster ID."
|
||||||
</p>
|
/>
|
||||||
<p>
|
<p>
|
||||||
In the secondary case this means a wipe of the
|
In the secondary case this means a wipe of the
|
||||||
underlying storage when connected to a primary, and in the primary case,
|
underlying storage when connected to a primary, and in the primary case,
|
||||||
|
|||||||
@@ -141,9 +141,10 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{{#if (eq mode 'secondary')}}
|
{{#if (eq mode 'secondary')}}
|
||||||
<p class="help">
|
<AlertInline
|
||||||
<em class="has-text-danger">Caution</em>: this will <em>immediately</em> clear <strong>all</strong> data in this cluster!
|
@type="warning"
|
||||||
</p>
|
@message="This will immediately clear all data in this cluster!"
|
||||||
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{#if (eq mode 'primary')}}
|
{{#if (eq mode 'primary')}}
|
||||||
|
|||||||
@@ -45,10 +45,11 @@
|
|||||||
Force promotion of this cluster
|
Force promotion of this cluster
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<p class="help has-text-grey">
|
<AlertInline
|
||||||
<em class="has-text-danger">Caution</em>: Forcing promotion could result in data loss if data isn't fully replicated. Force promotion
|
@type="warning"
|
||||||
promotes the cluster even if certain safety checks fail.
|
@message="Forcing promotion could result in data loss if data isn't fully replicated. Force promotion
|
||||||
</p>
|
promotes the cluster even if certain safety checks fail."
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@@ -74,10 +75,11 @@
|
|||||||
</h4>
|
</h4>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p>Promote the cluster to primary.</p>
|
<p>Promote the cluster to primary.</p>
|
||||||
<p>
|
<AlertInline
|
||||||
<em class="has-text-danger">Caution</em>: Vault replication is not designed for active-active usage and enabling two primaries should never be done, as it can lead to data loss if they or their secondaries are ever reconnected.
|
@type="warning"
|
||||||
If the cluster has a primary, be sure to demote it before promoting a secondary.
|
@message="Vault replication is not designed for active-active usage and enabling two primaries should never be done, as it can lead to data loss if they or their secondaries are ever reconnected.
|
||||||
</p>
|
If the cluster has a primary, be sure to demote it before promoting a secondary."
|
||||||
|
/>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="primary_cluster_addr" class="is-label">
|
<label for="primary_cluster_addr" class="is-label">
|
||||||
Primary cluster address <em class="is-optional">(optional)</em>
|
Primary cluster address <em class="is-optional">(optional)</em>
|
||||||
@@ -101,10 +103,11 @@
|
|||||||
Force promotion of this cluster
|
Force promotion of this cluster
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<p class="help has-text-grey">
|
<AlertInline
|
||||||
<em class="has-text-danger">Caution</em>: Forcing promotion could result in data loss if data isn't fully replicated. Force promotion
|
@type="warning"
|
||||||
promotes the cluster even if certain safety checks fail.
|
@message="Forcing promotion could result in data loss if data isn't fully replicated. Force promotion
|
||||||
</p>
|
promotes the cluster even if certain safety checks fail."
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
{{#if (gt model.credentialTypes.length 1)}}
|
{{#if (gt model.credentialTypes.length 1)}}
|
||||||
<AlertBanner
|
<AlertBanner
|
||||||
@type="warning"
|
@type="warning"
|
||||||
@message="This role has more than one <code>credential_type</code>, currently: <code>{{join ', ' model.credentialTypes}}</code>.
|
@message="This role has more than one credential_type, currently: {{join ', ' model.credentialTypes}}.
|
||||||
Multiple credential types is deprecated and you must choose one in order to save this role."
|
Multiple credential types is deprecated and you must choose one in order to save this role."
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#each (if (eq mode 'edit') (drop 1 model.fields) model.fields) as |attr|}}
|
{{#each (if (eq mode 'edit') (drop 1 model.fields) model.fields) as |attr|}}
|
||||||
|
|||||||
@@ -11,34 +11,28 @@
|
|||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
<div class="box is-sideless is-fullwidth is-marginless">
|
<div class="box is-sideless is-fullwidth is-marginless">
|
||||||
<div class="box">
|
{{#if (eq model.httpStatus 400)}}
|
||||||
<div class="columns is-centered">
|
<AlertBanner
|
||||||
<div class="column is-half has-text-centered">
|
@type="danger"
|
||||||
{{#if (eq model.httpStatus 400)}}
|
@message="{{model.keyId}} is not a valid lease ID"
|
||||||
<p class="box is-shadowless has-text-danger" data-test-lease-error="true">
|
/>
|
||||||
{{i-con glyph='close'}}
|
{{else if (eq model.httpStatus 404)}}
|
||||||
<code class="has-text-danger">{{model.keyId}}</code> is not a valid lease ID
|
<p class="message">
|
||||||
</p>
|
Unable to find lease for the <code>id</code>: <code>{{model.keyId}}</code>. Try going back to the
|
||||||
{{else if (eq model.httpStatus 404)}}
|
{{#link-to "vault.cluster.access.leases"}}lookup{{/link-to}}
|
||||||
<p class="message">
|
and re-entering the <code>id</code>.
|
||||||
Unable to find lease for the <code>id</code>: <code>{{model.keyId}}</code>. Try going back to the
|
</p>
|
||||||
{{#link-to "vault.cluster.access.leases"}}lookup{{/link-to}}
|
{{else if (eq model.httpStatus 403)}}
|
||||||
and re-entering the <code>id</code>.
|
<p class="message">
|
||||||
</p>
|
You don't have access to <code>{{model.keyId}}</code>. If you think you've reached this page in error, please contact your administrator.
|
||||||
{{else if (eq model.httpStatus 403)}}
|
</p>
|
||||||
<p class="message">
|
{{else}}
|
||||||
You don't have access to <code>{{model.keyId}}</code>. If you think you've reached this page in error, please contact your administrator.
|
{{#each model.errors as |error|}}
|
||||||
</p>
|
<p class="message">
|
||||||
{{else}}
|
{{error}}
|
||||||
{{#each model.errors as |error|}}
|
</p>
|
||||||
<p class="message">
|
{{/each}}
|
||||||
{{error}}
|
{{/if}}
|
||||||
</p>
|
|
||||||
{{/each}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="field is-grouped box is-fullwidth is-bottomless">
|
<div class="field is-grouped box is-fullwidth is-bottomless">
|
||||||
{{#link-to "vault.cluster.access.leases" class="button"}}
|
{{#link-to "vault.cluster.access.leases" class="button"}}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</p.levelLeft>
|
</p.levelLeft>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
|
||||||
<form class="" {{ action "savePolicy" model on="submit"}}>
|
<form {{ action "savePolicy" model on="submit"}}>
|
||||||
<div class="box is-bottomless is-fullwidth is-marginless">
|
<div class="box is-bottomless is-fullwidth is-marginless">
|
||||||
{{message-error model=model}}
|
{{message-error model=model}}
|
||||||
<NamespaceReminder @mode="create" @noun="policy" />
|
<NamespaceReminder @mode="create" @noun="policy" />
|
||||||
|
|||||||
17
ui/tests/integration/components/alert-inline-test.js
Normal file
17
ui/tests/integration/components/alert-inline-test.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { module, test } from 'qunit';
|
||||||
|
import { setupRenderingTest } from 'ember-qunit';
|
||||||
|
import { render } from '@ember/test-helpers';
|
||||||
|
import hbs from 'htmlbars-inline-precompile';
|
||||||
|
|
||||||
|
module('Integration | Component | alert-inline', 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`{{alert-inline type="danger" message="test message"}}`);
|
||||||
|
|
||||||
|
assert.equal(this.element.textContent.trim(), 'test message');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { clickable, collection, fillable, text, value } from 'ember-cli-page-object';
|
import { clickable, collection, fillable, text, value } from 'ember-cli-page-object';
|
||||||
import fields from './form-field';
|
import fields from './form-field';
|
||||||
import errorText from './message-in-page';
|
import errorText from './alert-banner';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...fields,
|
...fields,
|
||||||
|
|||||||
Reference in New Issue
Block a user