From c6dd21f4dd8c2f2bfdcddb32b3d88a008ffa862e Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 1 Dec 2021 11:33:33 +0000 Subject: [PATCH] ui: Refactor KV and Lock Sessions following partitions update (#11666) This commit uses all our new ways of doing things to Lock Sessions and their interactions with KV and Nodes. This is mostly around are new under-the-hood things, but also I took the opportunity to upgrade some of the CSS to reuse some of our CSS utils that have been made over the past few months (%csv-list and %horizontal-kv-list). Also added (and worked on existing) documentation for Lock Session related components. --- .changelog/11666.txt | 3 + .../app/components/composite-row/index.scss | 5 - .../app/components/composite-row/layout.scss | 5 - .../app/components/composite-row/skin.scss | 0 .../consul/lock-session/form/README.mdx | 31 ++++ .../consul/lock-session/form/index.hbs | 149 +++++++++++------- .../consul/lock-session/form/index.js | 3 - .../consul/lock-session/form/index.scss | 8 +- .../consul/lock-session/list/README.mdx | 19 +-- .../consul/lock-session/list/index.hbs | 62 +++++--- .../consul/lock-session/list/index.js | 5 - .../consul/lock-session/list/index.scss | 22 ++- .../lock-session/notifications/index.hbs | 37 ++++- .../components/data-loader/chart.xstate.js | 6 + .../app/components/data-loader/index.hbs | 5 +- .../app/components/data-loader/index.js | 7 + .../app/components/data-writer/index.hbs | 2 +- .../components/definition-table/layout.scss | 2 + .../app/components/list-collection/index.hbs | 2 +- .../app/components/list-row/layout.scss | 14 +- .../app/components/list-row/skin.scss | 3 +- .../app/routes/dc/nodes/show/sessions.js | 20 --- ui/packages/consul-ui/app/serializers/kv.js | 13 +- .../consul-ui/app/serializers/session.js | 15 +- ui/packages/consul-ui/app/styles/layout.scss | 17 +- .../app/styles/routes/dc/kv/index.scss | 7 + .../app/styles/routes/dc/nodes/index.scss | 3 + .../consul-ui/app/styles/typography.scss | 3 + .../consul-ui/app/templates/dc/kv/edit.hbs | 49 ++++-- .../app/templates/dc/nodes/show/sessions.hbs | 117 ++++++++++---- .../consul-ui/mock-api/v1/session/info/_ | 4 + .../dc/kvs/sessions/invalidate.feature | 2 +- 32 files changed, 436 insertions(+), 204 deletions(-) create mode 100644 .changelog/11666.txt delete mode 100644 ui/packages/consul-ui/app/components/composite-row/skin.scss create mode 100644 ui/packages/consul-ui/app/components/consul/lock-session/form/README.mdx delete mode 100644 ui/packages/consul-ui/app/components/consul/lock-session/form/index.js delete mode 100644 ui/packages/consul-ui/app/components/consul/lock-session/list/index.js delete mode 100644 ui/packages/consul-ui/app/routes/dc/nodes/show/sessions.js diff --git a/.changelog/11666.txt b/.changelog/11666.txt new file mode 100644 index 000000000..65080a068 --- /dev/null +++ b/.changelog/11666.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: Upgrade Lock Sessions to use partitions +``` diff --git a/ui/packages/consul-ui/app/components/composite-row/index.scss b/ui/packages/consul-ui/app/components/composite-row/index.scss index 2f56cbe05..2612d0ca1 100644 --- a/ui/packages/consul-ui/app/components/composite-row/index.scss +++ b/ui/packages/consul-ui/app/components/composite-row/index.scss @@ -1,5 +1,4 @@ @import './layout'; -@import './skin'; %composite-row { @extend %list-row; } @@ -33,12 +32,8 @@ .consul-auth-method-list > ul > li:not(:first-child) { @extend %with-composite-row-intent; } -.consul-lock-session-list ul > li:not(:first-child) { - @extend %with-one-action-row; -} // TODO: This hides the iconless dt's in the below lists as they don't have // tooltips the todo would be to wrap these texts in spans -.consul-lock-session-list ul > li:not(:first-child) dl:not([class]) dt, .consul-nspace-list > ul > li:not(:first-child) dt, .consul-token-list > ul > li:not(:first-child) dt, .consul-policy-list > ul li:not(:first-child) dl:not(.datacenter) dt, diff --git a/ui/packages/consul-ui/app/components/composite-row/layout.scss b/ui/packages/consul-ui/app/components/composite-row/layout.scss index fd3b465a5..b855ef108 100644 --- a/ui/packages/consul-ui/app/components/composite-row/layout.scss +++ b/ui/packages/consul-ui/app/components/composite-row/layout.scss @@ -7,11 +7,6 @@ 'header actions' 'detail actions'; } -%with-one-action-row { - @extend %composite-row; - grid-template-columns: 1fr auto; - padding-right: 12px; -} %composite-row-header { grid-area: header; align-self: start; diff --git a/ui/packages/consul-ui/app/components/composite-row/skin.scss b/ui/packages/consul-ui/app/components/composite-row/skin.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/form/README.mdx b/ui/packages/consul-ui/app/components/consul/lock-session/form/README.mdx new file mode 100644 index 000000000..8c6a372e9 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/lock-session/form/README.mdx @@ -0,0 +1,31 @@ +# Consul::LockSession::Form + +A component for rendering and deleting/invalidating a Lock Session. + +The form is fully functional and will delete/invalidate and show its +notifications when pressing the delete/invalidate button. + +```hbs preview-template + + {{#if source.data.ID}} + + {{/if}} + +``` + +## Arguments + +| Argument/Attribute | Type | Default | Description | +| --- | --- | --- | --- | +| `item` | `array` | | A Lock Session | +| `ondelete` | `function` | | An action to confirm when the `delete` (or Invalidate) action is clicked and confirmed | + +## See + +- [Template Source Code](./index.hbs) + +--- diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/form/index.hbs b/ui/packages/consul-ui/app/components/consul/lock-session/form/index.hbs index d3102b79e..ddb5a5b1a 100644 --- a/ui/packages/consul-ui/app/components/consul/lock-session/form/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/lock-session/form/index.hbs @@ -1,63 +1,106 @@ - - -
-

- Lock Session -

-
-{{#if api.data.Name}} -
Name
-
{{api.data.Name}}
-{{/if}} -
ID
-
{{api.data.ID}}
-
Node
-
- {{api.data.Node}} -
-
Delay
-
{{duration-from api.data.LockDelay}}
-
TTL
-
{{or api.data.TTL '-'}}
-
Behavior
-
{{api.data.Behavior}}
-{{#let api.data.checks as |checks|}} -
Health Checks
-
- {{#if (gt checks.length 0)}} - {{ join ', ' checks}} - {{else}} - - + + + + + + + + +
+
+ {{#if @item.Name}} +
Name
+
{{@item.Name}}
{{/if}} -
-{{/let}} -
-{{#if (can 'delete session' item=api.data)}} - +
ID
+
{{@item.ID}}
+
Node
+
+ + {{@item.Node}} + +
+
Delay
+
{{duration-from @item.LockDelay}}
+
TTL
+
{{or @item.TTL '-'}}
+
Behavior
+
{{@item.Behavior}}
+ {{#let @item.checks as |checks|}} +
Health Checks
+
+ {{#if (gt checks.length 0)}} + {{ join ', ' checks}} + {{else}} + - + {{/if}} +
+ {{/let}} + +
+ {{#if (can 'delete session' item=@item)}} + - + + Invalidate Session +

{{message}}

- - + + Confirm Invalidation + + + Cancel +
-{{/if}} - -
-
\ No newline at end of file + {{/if}} + + + \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/form/index.js b/ui/packages/consul-ui/app/components/consul/lock-session/form/index.js deleted file mode 100644 index 557064773..000000000 --- a/ui/packages/consul-ui/app/components/consul/lock-session/form/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Component from '@ember/component'; - -export default Component.extend({}); diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/form/index.scss b/ui/packages/consul-ui/app/components/consul/lock-session/form/index.scss index 3dab35b60..acb23ebdd 100644 --- a/ui/packages/consul-ui/app/components/consul/lock-session/form/index.scss +++ b/ui/packages/consul-ui/app/components/consul/lock-session/form/index.scss @@ -1,9 +1,3 @@ .consul-lock-session-form { - h2 { - @extend %h200; - border-bottom: var(--decor-border-200); - border-color: rgb(var(--tone-gray-200)); - padding-bottom: 0.2em; - margin-bottom: 0.5em; - } + overflow: hidden; } diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/list/README.mdx b/ui/packages/consul-ui/app/components/consul/lock-session/list/README.mdx index 5344c8168..bc9321fce 100644 --- a/ui/packages/consul-ui/app/components/consul/lock-session/list/README.mdx +++ b/ui/packages/consul-ui/app/components/consul/lock-session/list/README.mdx @@ -1,29 +1,26 @@ ---- -class: ember ---- # Consul::LockSession::List +A presentational component for rendering Node Lock Sessions + ```hbs preview-template - + ``` -A presentational component for rendering Node Lock Sessions - -### Arguments +## Arguments | Argument/Attribute | Type | Default | Description | | --- | --- | --- | --- | | `items` | `array` | | An array of Node Lock Sessions | -| `onInvalidate` | `function` | | An action to confirm when the `Invalidate` action is clicked and confirmed | +| `ondelete` | `function` | | An action to confirm when the `delete` (or Invalidate) action is clicked and confirmed | -### See +## See -- [Component Source Code](./index.js) - [Template Source Code](./index.hbs) --- diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/list/index.hbs b/ui/packages/consul-ui/app/components/consul/lock-session/list/index.hbs index 450474ba4..cf7f82690 100644 --- a/ui/packages/consul-ui/app/components/consul/lock-session/list/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/lock-session/list/index.hbs @@ -1,5 +1,8 @@ -{{#if (gt items.length 0)}} - + {{#if item.Name}} {{item.Name}} @@ -35,7 +38,9 @@
{{duration-from item.LockDelay}}
-
+
TTL
{{#if (eq item.TTL "")}} @@ -45,14 +50,18 @@ {{/if}}
-
+
Behavior
{{item.Behavior}}
{{#let (union item.NodeChecks item.ServiceChecks) as |checks|}}
-
+
Checks
@@ -67,27 +76,36 @@
{{/let}}
-{{#if (can "delete sessions")}} - + - + + Invalidate + -

- {{message}} -

- - +

+ {{message}} +

+ + Confirm Invalidate + + + Cancel +
-{{/if}} -
-{{/if}} \ No newline at end of file +
\ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/list/index.js b/ui/packages/consul-ui/app/components/consul/lock-session/list/index.js deleted file mode 100644 index 479865264..000000000 --- a/ui/packages/consul-ui/app/components/consul/lock-session/list/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component from '@ember/component'; - -export default Component.extend({ - tagName: '', -}); diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/list/index.scss b/ui/packages/consul-ui/app/components/consul/lock-session/list/index.scss index 7d7c82efe..79327901d 100644 --- a/ui/packages/consul-ui/app/components/consul/lock-session/list/index.scss +++ b/ui/packages/consul-ui/app/components/consul/lock-session/list/index.scss @@ -1,10 +1,16 @@ +.consul-lock-session-list ul > li:not(:first-child) { + @extend %composite-row; +} +.consul-lock-session-list button { + /* knock the button over a little */ + /* for meatball menus we use as much clickable space */ + /* as possible which is invisible hence why we need to */ + /* do this for a single button */ + margin-right: var(--horizontal-padding); +} +.consul-lock-session-list dl { + @extend %horizontal-kv-list; +} .consul-lock-session-list .checks dd { - display: inline-flex; - flex-wrap: wrap; - padding-left: 0px; -} -.consul-lock-session-list .checks dd > *:not(:last-child)::after { - content: ','; - margin-right: 0.3em; - display: inline; + @extend %csv-list; } diff --git a/ui/packages/consul-ui/app/components/consul/lock-session/notifications/index.hbs b/ui/packages/consul-ui/app/components/consul/lock-session/notifications/index.hbs index 52b97172c..865342932 100644 --- a/ui/packages/consul-ui/app/components/consul/lock-session/notifications/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/lock-session/notifications/index.hbs @@ -1,7 +1,36 @@ -{{#if (eq @type 'delete')}} - {{#if (eq @status 'success') }} - The session was invalidated. +{{#if (eq @type 'remove')}} + {{#if @error}} + + + Error! + + +

+ There was an error invalidating the Lock Session. + {{#if (and @error.status @error.detail)}} +
{{@error.status}}: {{@error.detail}} + {{/if}} +

+
+
{{else}} - There was an error invalidating the session. + + + Success! + + +

+ Your Lock Session has been invalidated. +

+
+
{{/if}} {{/if}} \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/data-loader/chart.xstate.js b/ui/packages/consul-ui/app/components/data-loader/chart.xstate.js index 94cc96131..dde7c5349 100644 --- a/ui/packages/consul-ui/app/components/data-loader/chart.xstate.js +++ b/ui/packages/consul-ui/app/components/data-loader/chart.xstate.js @@ -17,9 +17,15 @@ export default { target: 'loading', }, ], + INVALIDATE: [ + { + target: 'invalidating', + }, + ], }, states: { load: {}, + invalidating: {}, loading: { on: { SUCCESS: { diff --git a/ui/packages/consul-ui/app/components/data-loader/index.hbs b/ui/packages/consul-ui/app/components/data-loader/index.hbs index b62b7c3c3..b29d59a58 100644 --- a/ui/packages/consul-ui/app/components/data-loader/index.hbs +++ b/ui/packages/consul-ui/app/components/data-loader/index.hbs @@ -7,6 +7,7 @@ {{#let (hash data=data error=error + invalidate=(action "invalidate") dispatchError=(queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR")) ) as |api|}} @@ -16,7 +17,7 @@ {{! if we didn't specify any data}} {{#if (not items)}} {{! try and load the data if we aren't in an error state}} - + {{! but only if we only asked for a single load and we are in loading state}} {{#if (and src (or (not once) (state-matches state "loading")))}} - + {{#yield-slot name="disconnected" params=(block-params (action dispatch "RESET"))}} diff --git a/ui/packages/consul-ui/app/components/data-loader/index.js b/ui/packages/consul-ui/app/components/data-loader/index.js index 19967a12a..0039ba3d4 100644 --- a/ui/packages/consul-ui/app/components/data-loader/index.js +++ b/ui/packages/consul-ui/app/components/data-loader/index.js @@ -1,5 +1,6 @@ import Component from '@ember/component'; import { set } from '@ember/object'; +import { schedule } from '@ember/runloop'; import Slotted from 'block-slots'; import chart from './chart.xstate'; @@ -21,6 +22,12 @@ export default Component.extend(Slotted, { this.dispatch('LOAD'); }, actions: { + invalidate() { + this.dispatch('INVALIDATE'); + schedule('afterRender', () => { + this.dispatch('LOAD'); + }); + }, isLoaded: function() { return typeof this.items !== 'undefined' || typeof this.src === 'undefined'; }, diff --git a/ui/packages/consul-ui/app/components/data-writer/index.hbs b/ui/packages/consul-ui/app/components/data-writer/index.hbs index 048b775e0..53af6c856 100644 --- a/ui/packages/consul-ui/app/components/data-writer/index.hbs +++ b/ui/packages/consul-ui/app/components/data-writer/index.hbs @@ -90,7 +90,7 @@ as |after|}} {{#let (action dispatch "RESET") as |after|}} - {{#yield-slot name="error" params=(block-params after)}} + {{#yield-slot name="error" params=(block-params after api.error)}} {{yield api}} {{else}} dl { margin-bottom: 1.4em; } %definition-table dd > * { diff --git a/ui/packages/consul-ui/app/components/list-collection/index.hbs b/ui/packages/consul-ui/app/components/list-collection/index.hbs index a3eb31252..178144444 100644 --- a/ui/packages/consul-ui/app/components/list-collection/index.hbs +++ b/ui/packages/consul-ui/app/components/list-collection/index.hbs @@ -22,7 +22,7 @@
  • {{yield cell.item cell.index}}
    {{yield cell.item cell.index}}
    diff --git a/ui/packages/consul-ui/app/components/list-row/layout.scss b/ui/packages/consul-ui/app/components/list-row/layout.scss index 8440596fa..e14d32045 100644 --- a/ui/packages/consul-ui/app/components/list-row/layout.scss +++ b/ui/packages/consul-ui/app/components/list-row/layout.scss @@ -1,8 +1,16 @@ %list-row { - padding-top: 10px; - padding-bottom: 10px; + /* this can be reused by internal components */ + /* for positioning if required */ + --horizontal-padding: 12px; + --vertical-padding: 10px; + padding: var(--vertical-padding) 0; /* whilst this isn't in the designs this makes our temporary rollover look better */ - padding-left: 12px; + /* it doesn't happen on the right as we use a larger hit area with our */ + /* meatball menu which would overlap this and the meatball is the most */ + /* right hand 'action' button */ + padding-left: var(--horizontal-padding); + /* once we have our scroll pane refresh we no longer need a padding for */ + /* shadowing/rollover purposes so a lot of that ^ can go */ } %list-row-detail, %list-row-header-icon { diff --git a/ui/packages/consul-ui/app/components/list-row/skin.scss b/ui/packages/consul-ui/app/components/list-row/skin.scss index 0aacf59bf..654e6e894 100644 --- a/ui/packages/consul-ui/app/components/list-row/skin.scss +++ b/ui/packages/consul-ui/app/components/list-row/skin.scss @@ -8,7 +8,8 @@ } %list-row-intent { border-color: rgb(var(--tone-gray-200)); - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + /*TODO: This should use a shared/CSS prop shadow*/ + box-shadow: 0 2px 4px rgb(var(--black) / 10%); border-top-color: var(--transparent); cursor: pointer; } diff --git a/ui/packages/consul-ui/app/routes/dc/nodes/show/sessions.js b/ui/packages/consul-ui/app/routes/dc/nodes/show/sessions.js deleted file mode 100644 index ed951db9f..000000000 --- a/ui/packages/consul-ui/app/routes/dc/nodes/show/sessions.js +++ /dev/null @@ -1,20 +0,0 @@ -import Route from 'consul-ui/routing/route'; -import { inject as service } from '@ember/service'; -import { action } from '@ember/object'; - -import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; - -export default class SessionsRoute extends Route.extend(WithBlockingActions) { - @service('repository/session') sessionRepo; - @service('feedback') feedback; - - @action - invalidateSession(item) { - const route = this; - return this.feedback.execute(() => { - return this.sessionRepo.remove(item).then(() => { - route.refresh(); - }); - }, 'delete'); - } -} diff --git a/ui/packages/consul-ui/app/serializers/kv.js b/ui/packages/consul-ui/app/serializers/kv.js index 82436601d..b7dd2eaf9 100644 --- a/ui/packages/consul-ui/app/serializers/kv.js +++ b/ui/packages/consul-ui/app/serializers/kv.js @@ -16,7 +16,18 @@ export default class KvSerializer extends Serializer { respondForQueryRecord(respond, query) { return super.respondForQueryRecord( - cb => respond((headers, body) => cb(headers, body[0])), + cb => + respond((headers, body) => { + // If item.Session is not set make sure we overwrite any existing one. + // Using @replace, defaultValue or similar model apporaches does not work + // as if a property is undefined ember-data just ignores it instead of + // deleting the value of the existing property. + if (typeof body[0].Session === 'undefined') { + body[0].Session = ''; + } + // + return cb(headers, body[0]); + }), query ); } diff --git a/ui/packages/consul-ui/app/serializers/session.js b/ui/packages/consul-ui/app/serializers/session.js index 119619cea..b37fe6ff2 100644 --- a/ui/packages/consul-ui/app/serializers/session.js +++ b/ui/packages/consul-ui/app/serializers/session.js @@ -7,7 +7,20 @@ export default class SessionSerializer extends Serializer { respondForQueryRecord(respond, query) { return super.respondForQueryRecord( - cb => respond((headers, body) => cb(headers, body[0])), + cb => + respond((headers, body) => { + if (body.length === 0) { + const e = new Error(); + e.errors = [ + { + status: '404', + title: 'Not found', + }, + ]; + throw e; + } + return cb(headers, body[0]); + }), query ); } diff --git a/ui/packages/consul-ui/app/styles/layout.scss b/ui/packages/consul-ui/app/styles/layout.scss index 6c689ec61..1fe6db81f 100644 --- a/ui/packages/consul-ui/app/styles/layout.scss +++ b/ui/packages/consul-ui/app/styles/layout.scss @@ -53,8 +53,18 @@ html[data-route$='edit'] .app-view > header + div > *:first-child { %app-view-content .container { margin-top: 1.25em; } -.consul-upstream-instance-list, -.consul-lock-session-list { + +%list-after-secondary-nav { + margin-top: 0 !important; +} +%list-after-secondary-nav ul { + border-top-width: 0 !important; +} +%list-after-filter-bar { + border-top-width: 0 !important; +} + +.consul-upstream-instance-list { margin-top: 0 !important; } /* turn off top borders for things flush up to a filter bar */ @@ -62,12 +72,11 @@ html[data-route='dc.services.index'] .consul-service-list ul, .consul-nspace-list ul, .consul-service-instance-list ul, .consul-node-list ul, -.consul-lock-session-list ul, .consul-role-list ul, .consul-policy-list ul, .consul-token-list ul, .consul-auth-method-list ul { - border-top-width: 0 !important; + @extend %list-after-filter-bar; } .notice + .consul-token-list ul { border-top-width: 1px !important; diff --git a/ui/packages/consul-ui/app/styles/routes/dc/kv/index.scss b/ui/packages/consul-ui/app/styles/routes/dc/kv/index.scss index e55f58ebd..47f238569 100644 --- a/ui/packages/consul-ui/app/styles/routes/dc/kv/index.scss +++ b/ui/packages/consul-ui/app/styles/routes/dc/kv/index.scss @@ -2,3 +2,10 @@ html[data-route^='dc.kv'] .type-toggle { float: right; margin-bottom: 0 !important; } +html[data-route^='dc.kv.edit'] h2 { + @extend %h200; + border-bottom: var(--decor-border-200); + border-color: rgb(var(--tone-gray-200)); + padding-bottom: 0.2em; + margin-bottom: 0.5em; +} diff --git a/ui/packages/consul-ui/app/styles/routes/dc/nodes/index.scss b/ui/packages/consul-ui/app/styles/routes/dc/nodes/index.scss index 09c09f9f5..aa433dc90 100644 --- a/ui/packages/consul-ui/app/styles/routes/dc/nodes/index.scss +++ b/ui/packages/consul-ui/app/styles/routes/dc/nodes/index.scss @@ -1,3 +1,6 @@ html[data-route^='dc.nodes.show.metadata'] table tr { cursor: default; } +html[data-route^='dc.nodes.show.sessions'] .consul-lock-session-list { + @extend %list-after-secondary-nav; +} diff --git a/ui/packages/consul-ui/app/styles/typography.scss b/ui/packages/consul-ui/app/styles/typography.scss index c3e5a7420..2e9bd6370 100644 --- a/ui/packages/consul-ui/app/styles/typography.scss +++ b/ui/packages/consul-ui/app/styles/typography.scss @@ -11,6 +11,9 @@ fieldset > header, %form-element > span { @extend %h400; } +%definition-table dt { + line-height: var(--typo-lead-700); +} %internal-button, %breadcrumbs li > *, %tab-nav { diff --git a/ui/packages/consul-ui/app/templates/dc/kv/edit.hbs b/ui/packages/consul-ui/app/templates/dc/kv/edit.hbs index a375e575f..b84750d09 100644 --- a/ui/packages/consul-ui/app/templates/dc/kv/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/kv/edit.hbs @@ -39,11 +39,17 @@ as |parentKey|}} as |dc partition nspace item|}} +
      -
    1. - Key / Values -
    2. +
    3. + + Key / Values + +
    4. {{#if (not-eq parentKey separator)}} {{#let @@ -56,8 +62,8 @@ as |parts|}} {{! to make the correct href. 'Enough' is the current index plus 1.}} {{! We push on a '' here so make sure we get a trailing slash/separator }}
    5. - {{breadcrumb}} - +
    6. {{/if}} {{/each}} @@ -75,18 +81,21 @@ as |parts|}} {{/if}}
    +

    - {{#if (and item.Key (not-eq item.Key parentKey))}} +{{#if (and item.Key (not-eq item.Key parentKey))}} {{left-trim item.Key parentKey}} - {{else}} +{{else}} - {{/if}} +{{/if}}

    + - {{! if a KV has a session `Session` will always be populated despite any specific session permissions }} + +{{! if a KV has a session `Session` will always be populated despite any specific session permissions }} {{#if item.Session}} {{/if}} + + {{! `session` is slightly different to `item.Session` as we only have `session` }} {{! if you have `session:read perms` whereas you can get the sessions ID from }} {{! `item.Session` without any session perms }} @@ -123,17 +134,21 @@ as |parts|}} }} @onchange={{action (mut session) value="data"}} /> - {{#if session}} - {{!FIXME}} +

    + + Lock Session + +

    + {{#if session.ID}} {{/if}} - {{/if}}
    diff --git a/ui/packages/consul-ui/app/templates/dc/nodes/show/sessions.hbs b/ui/packages/consul-ui/app/templates/dc/nodes/show/sessions.hbs index 72dcb360c..b868871f7 100644 --- a/ui/packages/consul-ui/app/templates/dc/nodes/show/sessions.hbs +++ b/ui/packages/consul-ui/app/templates/dc/nodes/show/sessions.hbs @@ -18,38 +18,97 @@ as |route|> -{{#let api.data as |sessions|}} -
    - {{#if (gt sessions.length 0)}} - - {{else}} - - -

    - Welcome to Lock Sessions -

    +{{#let api.data as |items|}} +
    + + + + - -

    - Consul provides a session mechanism which can be used to build distributed locks. Sessions act as a binding layer between nodes, health checks, and key/value data. There are currently no lock sessions present, or you may not have permission to view lock sessions. -

    + + + - -
  • - + + + + + + + + + + + + +

    + Welcome to Lock Sessions +

    +
    + + +

    + Consul provides a session mechanism which can be used to build distributed locks. Sessions act as a binding layer between nodes, health checks, and key/value data. There are currently no lock sessions present, or you may not have permission to view lock sessions. +

    +
    + + + + + + +
    +
    + +
    +
    - - {{/if}} - + + {{/let}} diff --git a/ui/packages/consul-ui/mock-api/v1/session/info/_ b/ui/packages/consul-ui/mock-api/v1/session/info/_ index 77a1f99e4..99effb6be 100644 --- a/ui/packages/consul-ui/mock-api/v1/session/info/_ +++ b/ui/packages/consul-ui/mock-api/v1/session/info/_ @@ -6,6 +6,10 @@ typeof location.search.ns !== 'undefined' ? location.search.ns : typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default' }", + "Partition": "${ + typeof location.search.partition !== 'undefined' ? location.search.partition : + typeof http.body.Partition !== 'undefined' ? http.body.Partition : 'default' + }", "Node":"node-1", "NodeChecks":["serfHealth"], "ServiceChecks": [ diff --git a/ui/packages/consul-ui/tests/acceptance/dc/kvs/sessions/invalidate.feature b/ui/packages/consul-ui/tests/acceptance/dc/kvs/sessions/invalidate.feature index 1b3672dc0..6959dba8b 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/kvs/sessions/invalidate.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/kvs/sessions/invalidate.feature @@ -28,5 +28,5 @@ Feature: dc / kvs / sessions / invalidate: Invalidate Lock Sessions And I click delete on the session And I click confirmDelete on the session Then the url should be /datacenter/kv/key/edit - And "[data-notification]" has the "notification-update" class + And "[data-notification]" has the "notification-delete" class And "[data-notification]" has the "error" class