-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: [VAULT-17044] Replication card #22354
Merged
kiannaquach
merged 18 commits into
ui/landing-page-dashboard
from
ui/VAULT-17044/replication-card-dashboard
Aug 17, 2023
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
37375d0
Initial replication card setup
kiannaquach ee17690
Merge branch 'ui/landing-page-dashboard' into ui/VAULT-17044/replicat…
kiannaquach 1ecfdfd
Consider replication states
kiannaquach e1a564d
Some more cleanup
kiannaquach 4e2707f
Add refresh button
kiannaquach 38ce56d
Add integration tests
kiannaquach 2f20280
Update action in controller
kiannaquach 0c66e6a
Refactor replication-card to use stat text
kiannaquach fd310c3
Fix integration tests
kiannaquach 38b4376
Add idle state tests
kiannaquach ad73f9d
Refactor component and update tests
kiannaquach 765eb20
Put stat text back
kiannaquach addad1b
Remove extra lines
kiannaquach 1752e53
Put selectors in own file
kiannaquach 27bacd3
Add copyright
kiannaquach cddb7a3
Merge branch 'ui/landing-page-dashboard' into ui/VAULT-17044/replicat…
kiannaquach c2031a2
Address feedback!
kiannaquach 37a3a7d
Remove extra div
kiannaquach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import Controller from '@ember/controller'; | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import timestamp from 'core/utils/timestamp'; | ||
|
||
export default class DashboardController extends Controller { | ||
@tracked replicationUpdatedAt = timestamp.now().toISOString(); | ||
|
||
@action | ||
refreshModel() { | ||
this.replicationUpdatedAt = timestamp.now().toISOString(); | ||
this.send('refreshRoute'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,10 @@ | |
&.is-7 { | ||
font-size: $size-7; | ||
} | ||
|
||
&.is-8 { | ||
font-size: $size-8; | ||
} | ||
} | ||
|
||
.form-section .title { | ||
|
92 changes: 92 additions & 0 deletions
92
ui/app/templates/components/dashboard/replication-card.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{{! | ||
Copyright (c) HashiCorp, Inc. | ||
SPDX-License-Identifier: BUSL-1.1 | ||
~}} | ||
|
||
<div class="is-flex-between"> | ||
<h3 class="title is-4 has-bottom-margin-xxs" data-test-client-count-title> | ||
Replication | ||
</h3> | ||
|
||
<LinkTo class="is-no-underline" @route="vault.cluster.replication.index"> | ||
Details | ||
</LinkTo> | ||
</div> | ||
|
||
{{! check if dr replication and performance replication exists }} | ||
{{#if (or @replication.dr.clusterId @replication.performance.clusterId)}} | ||
<hr class="has-background-gray-100" /> | ||
{{! check if user has access to both perf replication and dr replication }} | ||
{{#if (and @version.hasPerfReplication @version.hasDRReplication)}} | ||
<div | ||
kiannaquach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class="is-grid grid-2-columns grid-gap-2 has-top-margin-m has-bottom-margin-xs grid-align-items-start" | ||
data-test-dr-perf-replication | ||
> | ||
<Dashboard::ReplicationStateText | ||
@title="DR primary" | ||
@name="dr" | ||
@state={{@replication.dr.state}} | ||
@clusterStates={{cluster-states @replication.dr.state}} | ||
/> | ||
<Dashboard::ReplicationStateText | ||
@title="Perf primary" | ||
@name="performance" | ||
@state={{if @replication.performance.clusterId @replication.performance.state "not set up"}} | ||
@clusterStates={{if @replication.performance.clusterId (cluster-states @replication.performance.state)}} | ||
/> | ||
</div> | ||
{{! if user only has access to dr replication }} | ||
{{else if @version.hasDRReplication}} | ||
<LinkTo | ||
class="title is-5 has-text-weight-semibold is-marginless" | ||
@route="vault.cluster.replication.mode.index" | ||
@model="dr" | ||
> | ||
DR Primary | ||
</LinkTo> | ||
|
||
<div | ||
class="is-grid grid-2-columns grid-gap-2 has-top-margin-m has-bottom-margin-m grid-align-items-start" | ||
data-test-dr-replication | ||
> | ||
<Dashboard::ReplicationStateText | ||
@title="state" | ||
@state={{@replication.dr.state}} | ||
@clusterStates={{cluster-states @replication.dr.state}} | ||
@subText="The current operating state of the cluster." | ||
/> | ||
<StatText | ||
@label="known secondaries" | ||
@value={{@replication.dr.knownSecondaries.length}} | ||
@size="l" | ||
@subText="Number of secondaries connected to this primary." | ||
data-test-stat-text="known secondaries" | ||
/> | ||
</div> | ||
{{/if}} | ||
<div class="has-top-margin-s is-flex-center"> | ||
<Hds::Button | ||
@text="Refresh" | ||
@isIconOnly={{true}} | ||
@color="tertiary" | ||
@icon="sync" | ||
class="has-padding-xxs" | ||
{{on "click" @refresh}} | ||
data-test-refresh | ||
/> | ||
<small class="has-left-margin-xs has-text-grey"> | ||
Updated | ||
{{date-format @updatedAt "MMM dd, yyyy HH:mm:SS"}} | ||
</small> | ||
</div> | ||
{{else}} | ||
<EmptyState | ||
@title="Replication not set up" | ||
@message="Data will be listed here. Enable a primary replication cluster to get started." | ||
class="has-top-margin-m" | ||
> | ||
<div> | ||
<LinkTo @route="vault.cluster.replication">Enable replication</LinkTo> | ||
</div> | ||
</EmptyState> | ||
{{/if}} |
48 changes: 48 additions & 0 deletions
48
ui/app/templates/components/dashboard/replication-state-text.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{{! | ||
Copyright (c) HashiCorp, Inc. | ||
SPDX-License-Identifier: BUSL-1.1 | ||
~}} | ||
|
||
<div> | ||
{{#if @name}} | ||
<LinkTo | ||
class="title is-5 has-text-weight-semibold has-bottom-margin-xs" | ||
@route="vault.cluster.replication.mode.index" | ||
@model={{@name}} | ||
data-test-title={{@title}} | ||
> | ||
{{@title}} | ||
</LinkTo> | ||
{{else}} | ||
<h2 class="title is-5 has-text-weight-semibold has-bottom-margin-xs" data-test-title={{@title}}> | ||
{{@title}} | ||
</h2> | ||
{{/if}} | ||
|
||
{{#if @subText}} | ||
<div class="title is-8 has-font-weight-normal has-text-grey-dark" data-test-subtext={{@title}}> | ||
{{@subText}} | ||
</div> | ||
{{/if}} | ||
|
||
<ToolTip @verticalPosition="above" @horizontalPosition="center" as |T|> | ||
<T.Trigger | ||
data-test-tooltip-trigger | ||
tabindex="-1" | ||
class="title is-3 has-font-weight-normal has-top-margin-xxs has-bottom-margin-xxs" | ||
data-test-tooltip-title={{@title}} | ||
> | ||
{{or @state "not set up"}} | ||
|
||
<FlightIcon | ||
@name={{or @clusterStates.glyph "x-circle"}} | ||
class={{if @clusterStates.isOk "has-text-success" "has-text-danger"}} | ||
/> | ||
</T.Trigger> | ||
<T.Content @defaultClass="tool-tip smaller-font"> | ||
<div class="box" data-test-hover-copy-tooltip-text> | ||
The cluster's current operating state | ||
</div> | ||
</T.Content> | ||
</ToolTip> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
const SELECTORS = { | ||
getReplicationTitle: (type, name) => `[data-test-${type}-replication] [data-test-title="${name}"]`, | ||
getStateTooltipTitle: (type, name) => `[data-test-${type}-replication] [data-test-tooltip-title="${name}"]`, | ||
getStateTooltipIcon: (type, name, icon) => | ||
`[data-test-${type}-replication] [data-test-tooltip-title="${name}"] [data-test-icon="${icon}"]`, | ||
drOnlyStateSubText: '[data-test-dr-replication] [data-test-subtext="state"]', | ||
knownSecondariesLabel: '[data-test-stat-text="known secondaries"] .stat-label', | ||
knownSecondariesSubtext: '[data-test-stat-text="known secondaries"] .stat-text', | ||
knownSecondariesValue: '[data-test-stat-text="known secondaries"] .stat-value', | ||
replicationEmptyState: '[data-test-component="empty-state"]', | ||
replicationEmptyStateTitle: '[data-test-component="empty-state"] .empty-state-title', | ||
replicationEmptyStateMessage: '[data-test-component="empty-state"] .empty-state-message', | ||
replicationEmptyStateActions: '[data-test-component="empty-state"] .empty-state-actions', | ||
}; | ||
|
||
export default SELECTORS; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the entire model hook will refresh when this method is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct! The replication query is attached to the top-level
cluster
route model. We customize the findRecord in the cluster adapter