UI: prep for running button codemod (#23628)

* replace buttons with tabs

* update console buttons

* update ssh role item buttons

* remove tracked variable

* more tab cleanup

* remove unwrapActiveTab variable

* fix button control

* fix search select with modal test
This commit is contained in:
claire bontempo
2023-10-11 22:44:28 -07:00
committed by GitHub
parent f1554425c3
commit 9c1898578f
17 changed files with 81 additions and 168 deletions

View File

@@ -4,35 +4,21 @@
~}} ~}}
{{#if this.policy.policyType}} {{#if this.policy.policyType}}
<nav class="tabs has-bottom-margin-l"> <Hds::Tabs as |T|>
<ul> <T.Tab data-test-tab-your-policy>
<li class={{unless this.showExamplePolicy "active"}}>
<button
data-test-tab-your-policy
type="button"
name="form"
class="link link-plain tab has-text-weight-semibold {{unless this.showExamplePolicy ' is-active'}}"
{{on "click" (fn (mut this.showExamplePolicy) false)}}
>
Your Policy Your Policy
</button> </T.Tab>
</li> <T.Tab Tab data-test-tab-example-policy>
<li class={{if this.showExamplePolicy "active"}}>
<button
data-test-tab-example-policy
type="button"
name="form"
class="link link-plain tab has-text-weight-semibold {{if this.showExamplePolicy ' is-active'}}"
{{on "click" (fn (mut this.showExamplePolicy) true)}}
>
Example Policy Example Policy
</button> </T.Tab>
</li>
</ul> <T.Panel>
</nav> <PolicyForm @onSave={{this.onSave}} @model={{this.policy}} @onCancel={{@onCancel}} />
{{/if}} </T.Panel>
{{#if this.showExamplePolicy}} <T.Panel class="has-top-padding-m">
<PolicyExample @policyType={{this.policy.policyType}} @container="#search-select-modal" /> <PolicyExample @policyType={{this.policy.policyType}} @container="#search-select-modal" />
</T.Panel>
</Hds::Tabs>
{{else}} {{else}}
<Select <Select
@name="policyType" @name="policyType"
@@ -43,9 +29,5 @@
@onChange={{this.setPolicyType}} @onChange={{this.setPolicyType}}
@noDefault={{true}} @noDefault={{true}}
/> />
{{#if this.policy.policyType}}
<PolicyForm @onSave={{this.onSave}} @model={{this.policy}} @onCancel={{@onCancel}} />
{{else}}
<EmptyState @title="No policy type selected" @message="Select a policy type to continue creating." /> <EmptyState @title="No policy type selected" @message="Select a policy type to continue creating." />
{{/if}}
{{/if}} {{/if}}

View File

@@ -29,7 +29,6 @@ export default class PolicyTemplate extends Component {
@service version; @service version;
@tracked policy = null; // model record passed to policy-form @tracked policy = null; // model record passed to policy-form
@tracked showExamplePolicy = false;
get policyOptions() { get policyOptions() {
return [ return [

View File

@@ -4,7 +4,7 @@
~}} ~}}
<form {{on "submit" (perform this.save)}} data-test-policy-form> <form {{on "submit" (perform this.save)}} data-test-policy-form>
<div class="box is-bottomless is-fullwidth is-marginless"> <div class="box is-shadowless is-fullwidth is-marginless">
<MessageError @errorMessage={{this.errorBanner}} /> <MessageError @errorMessage={{this.errorBanner}} />
<NamespaceReminder @mode={{if @model.isNew "create" "edit"}} @noun="policy" /> <NamespaceReminder @mode={{if @model.isNew "create" "edit"}} @noun="policy" />
{{#if @model.isNew}} {{#if @model.isNew}}

View File

@@ -39,7 +39,6 @@ export default Component.extend(DEFAULTS, {
algorithm: 'sha2-256', algorithm: 'sha2-256',
tagName: '', tagName: '',
unwrapActiveTab: 'data',
didReceiveAttrs() { didReceiveAttrs() {
this._super(...arguments); this._super(...arguments);

View File

@@ -16,14 +16,12 @@ import { action } from '@ember/object';
* @onClear={{action "onClear"}} * @onClear={{action "onClear"}}
* @token={{token}} * @token={{token}}
* @unwrap_data={{unwrap_data}} * @unwrap_data={{unwrap_data}}
* @unwrapActiveTab={{unwrapActiveTab}}
* @details={{details}} * @details={{details}}
* @errors={{errors}}/> * @errors={{errors}}/>
* ``` * ```
* @param onClear {Function} - parent action that is passed through. Must be passed as {{action "onClear"}} * @param onClear {Function} - parent action that is passed through. Must be passed as {{action "onClear"}}
* @param token=null {String} - property passed from parent to child and then passed back up to parent * @param token=null {String} - property passed from parent to child and then passed back up to parent
* @param unwrap_data {String} - property returned from parent. * @param unwrap_data {String} - property returned from parent.
* @param unwrapActiveTab {String} - property returned from parent.
* @param details {String} - property returned from parent. * @param details {String} - property returned from parent.
* @param error=null {Object} - errors passed from parent as default then from child back to parent. * @param error=null {Object} - errors passed from parent as default then from child back to parent.
*/ */

View File

@@ -18,20 +18,6 @@ $console-close-height: 35px;
will-change: transform, min-height; will-change: transform, min-height;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
z-index: 199; z-index: 199;
.button {
background: transparent;
border: none;
color: $white;
min-width: 0;
padding: 0 $size-8;
&.active,
&:hover {
background: $blue;
color: $white;
}
}
} }
.console-ui-panel-content { .console-ui-panel-content {
@@ -73,7 +59,7 @@ $console-close-height: 35px;
input { input {
background-color: rgba($black, 0.5); background-color: rgba($black, 0.5);
border: 1px solid var(--token-color-palette-neutral-500); border: 1px solid var(--token-color-palette-neutral-500);
border-radius: 2px; border-radius: var(--token-side-nav-body-list-item-border-radius);
caret-color: $white; caret-color: $white;
color: $white; color: $white;
flex: 1 1 auto; flex: 1 1 auto;

View File

@@ -29,8 +29,7 @@
&:focus { &:focus {
box-shadow: none; box-shadow: none;
} }
&.active, &.active {
&.active .tab {
border-color: $blue; border-color: $blue;
color: $blue; color: $blue;
} }
@@ -40,10 +39,6 @@
&.is-active { &.is-active {
border-bottom: 2px solid $blue; border-bottom: 2px solid $blue;
color: $blue; color: $blue;
> button {
color: $blue;
}
} }
// solves for tabs on auth mounts & secrets engines // solves for tabs on auth mounts & secrets engines
> a { > a {
@@ -61,8 +56,7 @@
box-shadow: none; box-shadow: none;
} }
&.active a, &.active a,
&.is-active a, &.is-active a {
&.active .tab {
border-color: $blue; border-color: $blue;
color: $blue; color: $blue;
} }
@@ -73,10 +67,6 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
vertical-align: top; vertical-align: top;
}
a,
.tab {
border-bottom: 2px solid transparent; border-bottom: 2px solid transparent;
color: $grey; color: $grey;
font-weight: $font-weight-semibold; font-weight: $font-weight-semibold;

View File

@@ -391,7 +391,6 @@ a.button.disabled {
box-shadow: none; box-shadow: none;
&:hover:not(.disabled) { &:hover:not(.disabled) {
background-color: $ui-gray-100; background-color: $ui-gray-100;
border: 0;
color: $blue; color: $blue;
} }
} }

View File

@@ -18,6 +18,10 @@
background-color: $ui-gray-200; background-color: $ui-gray-200;
} }
.has-background-gray-300 {
background-color: $ui-gray-300;
}
.has-background-gray-900 { .has-background-gray-900 {
background-color: $ui-gray-900; background-color: $ui-gray-900;
} }

View File

@@ -12,17 +12,14 @@
<input onkeyup={{action "handleKeyUp"}} value={{this.value}} autocomplete="off" spellcheck="false" /> <input onkeyup={{action "handleKeyUp"}} value={{this.value}} autocomplete="off" spellcheck="false" />
<ToolTip @horizontalPosition="auto-right" @verticalPosition="above" as |d|> <ToolTip @horizontalPosition="auto-right" @verticalPosition="above" as |d|>
<d.Trigger> <d.Trigger>
<button <Hds::Button
type="button" class="hds-side-nav__icon-button"
class={{concat "button is-compact" (if this.isFullscreen " active")}}
{{on "click" (action "fullscreen")}} {{on "click" (action "fullscreen")}}
data-test-tool-tip-trigger data-test-tool-tip-trigger
> @icon={{if this.isFullscreen "minimize" "maximize"}}
<Icon @text={{if this.isFullscreen "Minimize" "Maximize"}}
@name={{if this.isFullscreen "minimize" "maximize"}} @isIconOnly={{true}}
aria-label={{if this.isFullscreen "Minimize" "Maximize"}}
/> />
</button>
</d.Trigger> </d.Trigger>
<d.Content @defaultClass="tool-tip"> <d.Content @defaultClass="tool-tip">
<div class="box"> <div class="box">

View File

@@ -4,9 +4,14 @@
~}} ~}}
<div class="console-close-button"> <div class="console-close-button">
<button type="button" class="button is-ghost" {{action "closeConsole"}} data-test-console-panel-close> <Hds::Button
<Icon @name="x" aria-label="Close console" /> class="hds-side-nav__icon-button"
</button> {{on "click" (action "closeConsole")}}
data-test-console-panel-close
@text="Close console"
@icon="x"
@isIconOnly={{true}}
/>
</div> </div>
<div class="console-ui-panel-content"> <div class="console-ui-panel-content">
<div class="content has-bottom-margin-l"> <div class="content has-bottom-margin-l">

View File

@@ -43,9 +43,7 @@
{{#if (eq @item.keyType "otp")}} {{#if (eq @item.keyType "otp")}}
{{#if @item.generatePath.isPending}} {{#if @item.generatePath.isPending}}
<li class="action"> <li class="action">
<button disabled type="button" class="link button is-loading is-transparent"> <Hds::Button disabled @color="tertiary" @icon="loading" @text="loading" @isIconOnly={{true}} />
loading
</button>
</li> </li>
{{else if @item.canGenerate}} {{else if @item.canGenerate}}
<li class="action"> <li class="action">
@@ -61,9 +59,9 @@
{{else if (eq @item.keyType "ca")}} {{else if (eq @item.keyType "ca")}}
{{#if @item.signPath.isPending}} {{#if @item.signPath.isPending}}
<li class="action"> <li class="action">
<button disabled type="button" class="link button is-loading is-transparent"> <li class="action">
loading <Hds::Button disabled @color="tertiary" @icon="loading" @text="loading" @isIconOnly={{true}} />
</button> </li>
</li> </li>
{{else if @item.canGenerate}} {{else if @item.canGenerate}}
<li class="action"> <li class="action">
@@ -78,40 +76,21 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if @item.canEditZeroAddress}} {{#if @item.canEditZeroAddress}}
{{#if @item.zeroAddress}}
<li class="action"> <li class="action">
<button <Hds::Button
type="button" disabled={{@loadingToggleZeroAddress}}
disabled={{get this (concat "loading-" @item.id)}} class="link"
class="link button is-transparent {{if (get this (concat 'loading-' @item.id)) 'is-loading'}} " @icon={{if @loadingToggleZeroAddress "loading"}}
@isIconOnly={{@loadingToggleZeroAddress}}
{{on "click" @toggleZeroAddress}} {{on "click" @toggleZeroAddress}}
> @text={{if @item.zeroAddress "Disable Zero Address" "Enable Zero Address"}}
Disable Zero Address />
</button>
</li> </li>
{{else}}
<li class="action">
<button
type="button"
disabled={{get this (concat "loading-" @item.id)}}
class="link button is-transparent {{if (get this (concat 'loading-' @item.id)) 'is-loading'}}"
{{on "click" @toggleZeroAddress}}
>
Enable Zero Address
</button>
</li>
{{/if}}
{{/if}} {{/if}}
{{#if @item.updatePath.isPending}} {{#if @item.updatePath.isPending}}
<li class="action"> <li class="action">
<button disabled type="button" class="link button is-loading is-transparent"> <Hds::Button disabled @color="tertiary" @icon="loading" @text="loading" @isIconOnly={{true}} />
loading <Hds::Button disabled @color="tertiary" @icon="loading" @text="loading" @isIconOnly={{true}} />
</button>
</li>
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li> </li>
{{else}} {{else}}
{{#if @item.canRead}} {{#if @item.canRead}}

View File

@@ -36,7 +36,6 @@
<ToolUnwrap <ToolUnwrap
@onClear={{action "onClear"}} @onClear={{action "onClear"}}
@unwrap_data={{this.unwrap_data}} @unwrap_data={{this.unwrap_data}}
@unwrapActiveTab={{this.unwrapActiveTab}}
@details={{this.details}} @details={{this.details}}
@errors={{this.errors}} @errors={{this.errors}}
@token={{this.token}} @token={{this.token}}

View File

@@ -12,41 +12,20 @@
</PageHeader> </PageHeader>
{{#if @unwrap_data}} {{#if @unwrap_data}}
<div class="box is-sideless is-fullwidth is-marginless"> <Hds::Tabs as |T|>
<nav class="tabs has-bottom-margin-l"> <T.Tab data-test-button-data>Data</T.Tab>
<ul> <T.Tab data-test-button-details>Wrap Details</T.Tab>
{{! template-lint-configure no-nested-interactive "warn" }} <T.Panel>
<li class={{if (eq @unwrapActiveTab "data") "is-active"}}> <JsonEditor
<button class="has-top-padding-m"
type="button" @title="Unwrapped Data"
class="link link-plain tab has-text-weight-semibold" @value={{stringify @unwrap_data}}
{{action (mut @unwrapActiveTab) "data"}} @readOnly={{true}}
data-test-button-data @container=".toolbar-actions"
> />
Data </T.Panel>
</button> <T.Panel>
</li> <div class="has-top-padding-m">
<li class={{if (eq @unwrapActiveTab "details") "is-active"}}>
<button
type="button"
class="link link-plain tab has-text-weight-semibold"
{{action (mut @unwrapActiveTab) "details"}}
data-test-button-details
>
Wrap Details
</button>
</li>
{{! template-lint-configure no-nested-interactive "on" }}
</ul>
</nav>
{{#if (eq @unwrapActiveTab "data")}}
<div class="field">
<div class="control">
<JsonEditor @title="Unwrapped Data" @value={{stringify @unwrap_data}} @readOnly={{true}} />
</div>
</div>
{{else}}
<div class="field box is-fullwidth is-shadowless is-paddingless is-marginless">
{{#each-in @details as |key detail|}} {{#each-in @details as |key detail|}}
<InfoTableRow @label={{key}} @value={{key}}> <InfoTableRow @label={{key}} @value={{key}}>
{{#if (or (eq detail "No") (eq detail "None"))}} {{#if (or (eq detail "No") (eq detail "None"))}}
@@ -61,18 +40,12 @@
</InfoTableRow> </InfoTableRow>
{{/each-in}} {{/each-in}}
</div> </div>
{{/if}} </T.Panel>
</div> </Hds::Tabs>
<div class="field is-grouped box is-fullwidth is-bottomless"> <Hds::ButtonSet class="has-top-padding-m">
<div class="control"> <Hds::Copy::Button @text="Copy unwrapped data" @textToCopy={{stringify @unwrap_data}} class="primary" />
<Hds::Copy::Button @text="Copy" @textToCopy={{stringify @unwrap_data}} class="primary" /> <Hds::Button {{on "click" this.onClear}} type="button" class="button" @text="Back" />
</div> </Hds::ButtonSet>
<div class="control">
<button {{on "click" this.onClear}} type="button" class="button">
Back
</button>
</div>
</div>
{{else}} {{else}}
<div class="box is-sideless is-fullwidth is-marginless"> <div class="box is-sideless is-fullwidth is-marginless">
<NamespaceReminder @mode="perform" @noun={{@selectedAction}} /> <NamespaceReminder @mode="perform" @noun={{@selectedAction}} />

View File

@@ -22,6 +22,8 @@
</p.levelLeft> </p.levelLeft>
</PageHeader> </PageHeader>
<hr class="has-background-gray-300 is-marginless" />
<PolicyForm <PolicyForm
@model={{this.model}} @model={{this.model}}
@onSave={{transition-to "vault.cluster.policy.show" this.model.policyType this.model.name}} @onSave={{transition-to "vault.cluster.policy.show" this.model.policyType this.model.name}}

View File

@@ -75,6 +75,7 @@
@modelType={{@modelType}} @modelType={{@modelType}}
@options={{options}} @options={{options}}
@toggleZeroAddress={{action "toggleZeroAddress" item this.backendModel}} @toggleZeroAddress={{action "toggleZeroAddress" item this.backendModel}}
@loadingToggleZeroAddress={{get this (concat "loading-" item.id)}}
/> />
{{/let}} {{/let}}
{{else}} {{else}}

View File

@@ -185,10 +185,10 @@ module('Integration | Component | search select with modal', function (hooks) {
assert.dom('[data-test-empty-state-title]').hasText('No policy type selected'); assert.dom('[data-test-empty-state-title]').hasText('No policy type selected');
await fillIn('[data-test-select="policyType"]', 'acl'); await fillIn('[data-test-select="policyType"]', 'acl');
assert.dom('[data-test-policy-form]').exists('policy form renders after type is selected'); assert.dom('[data-test-policy-form]').exists('policy form renders after type is selected');
await click('[data-test-tab-example-policy]'); await click('[data-test-tab-example-policy] button');
assert.dom('[data-test-tab-example-policy]').hasClass('is-active'); assert.dom('[data-test-tab-example-policy] button').hasAttribute('aria-selected', 'true');
await click('[data-test-tab-your-policy]'); await click('[data-test-tab-your-policy] button');
assert.dom('[data-test-tab-your-policy]').hasClass('is-active'); assert.dom('[data-test-tab-your-policy] button').hasAttribute('aria-selected', 'true');
await fillIn( await fillIn(
'[data-test-component="code-mirror-modifier"] textarea', '[data-test-component="code-mirror-modifier"] textarea',
'path "secret/super-secret" { capabilities = ["deny"] }' 'path "secret/super-secret" { capabilities = ["deny"] }'