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

Cc 5545: Upgrade HDS packages and modifiers #19226

Merged
merged 21 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8d38b4e
Upgrade @hashicorp/design-system-tokens to 1.9.0
WenInCode Oct 12, 2023
31fdd2d
Upgrade @hashicorp/design-system-components to 1.8.1
WenInCode Oct 12, 2023
f6f4091
Upgrade @hashicorp/design-system-components and ember-in-viewport
WenInCode Oct 12, 2023
b692379
Explicitly install ember-modifier@4.1.0
WenInCode Oct 12, 2023
1a1b951
rename copy-button
chris-hut Oct 16, 2023
13e3d1c
Fix how cleanup is done in with-copyable
WenInCode Oct 12, 2023
b7295ee
Update aria-menu modifier for new structure
WenInCode Oct 13, 2023
73089ed
Update css-prop modifier to new structure
WenInCode Oct 13, 2023
cea2ab9
Convert did-upsert to regular class modifier
WenInCode Oct 13, 2023
964ef50
Update notification modifier for new structure
WenInCode Oct 13, 2023
0fd98e7
Update on-oustside modifier for new structure
WenInCode Oct 13, 2023
0519b9b
Move destroy handler registration in with-copyable
WenInCode Oct 13, 2023
50cbd00
Update style modifier for new structure
WenInCode Oct 13, 2023
838a8a9
Update validate modifier for new structure
WenInCode Oct 13, 2023
4882490
Guard against setting on destroyed object
WenInCode Oct 13, 2023
42a9f03
Upgrade @hashicorp/design-system-components to 2.14.1
WenInCode Oct 13, 2023
bbedb3f
Remove debugger
WenInCode Oct 13, 2023
4576fbe
Guard against null in aria-menu
WenInCode Oct 13, 2023
07584fa
Fix undefined hash in validate addon
WenInCode Oct 13, 2023
ef39122
Upgrade ember-on-resize-modifier
WenInCode Oct 16, 2023
c77d8a0
Fix copy button import, missing import and array destructuring
WenInCode Oct 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ as |item index|>
{{else}}
<span>
{{item.ID}}
<CopyButton
<ConsulCopyButton
@value={{item.ID}}
@name="ID"
/>
Expand All @@ -28,7 +28,7 @@ as |item index|>
ID
</dt>
<dd>
<CopyButton
<ConsulCopyButton
@value={{item.ID}}
@name="ID"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div
class="hds-typography-display-300 text-hds-foreground-strong hds-font-weight-semibold"
>{{address}}</div>
<CopyButton
<ConsulCopyButton
@value={{address}}
@name="Address"
class="opacity-0 group-hover:opacity-100"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ A code-editor with syntax highlighting supporting multiple languages (JSON, HCL,
| Name | Description | Behaviour if empty |
| --- | --- | --- |
| `:label` | Used to define the title that's displayed on the left inside the toolbar above the CodeEditor | Nothing is displayed |
| `:tools` | Used to define tools, buttons, widgets that will be displayed on the right inside the toolbar above the CodeEditor | By default it renders a `language selector` dropdown (if `readonly`== false and `syntax` is falsy) and a `CopyButton`
| `:tools` | Used to define tools, buttons, widgets that will be displayed on the right inside the toolbar above the CodeEditor | By default it renders a `language selector` dropdown (if `readonly`== false and `syntax` is falsy) and a `ConsulCopyButton`
| `:content` | Used to display specific content such as code templates inside the CodeEditor | if the block is defined, @value will be displayed instead |


Expand Down
2 changes: 1 addition & 1 deletion ui/packages/consul-ui/app/components/code-editor/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{{mode.name}}
</PowerSelect>
<div class="toolbar-separator"></div>
<CopyButton
<ConsulCopyButton
@value={{value}}
@name="value"
/>
Expand Down
32 changes: 17 additions & 15 deletions ui/packages/consul-ui/app/components/code-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ export default Component.extend({
}
},
setMode: function (mode) {
let options = {
...DEFAULTS,
mode: mode.mime,
readOnly: this.readonly,
};
if (mode.name === 'XML') {
options.htmlMode = mode.htmlMode;
options.matchClosing = mode.matchClosing;
options.alignCDATA = mode.alignCDATA;
}
set(this, 'options', options);
if (!this.isDestroying && !this.isDestroyed) {
let options = {
...DEFAULTS,
mode: mode.mime,
readOnly: this.readonly,
};
if (mode.name === 'XML') {
options.htmlMode = mode.htmlMode;
options.matchClosing = mode.matchClosing;
options.alignCDATA = mode.alignCDATA;
}
set(this, 'options', options);

const editor = this.editor;
editor.setOption('mode', mode.mime);
this.helper.lint(editor, mode.mode);
set(this, 'mode', mode);
const editor = this.editor;
editor.setOption('mode', mode.mime);
this.helper.lint(editor, mode.mode);
set(this, 'mode', mode);
}
},
willDestroyElement: function () {
this._super(...arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CopyButton
# ConsulCopyButton

Button component used for copy-to-clipboard functionality so the user can easily copy specified text to their clipboard, along with tooltip-like notifications so the user has some sort of feedback to know the value has been copied.

Expand All @@ -10,7 +10,7 @@ Can be used inline to render only a small icon for the button with no other text
<figure>
<figcaption>Icon only</figcaption>

<CopyButton
<ConsulCopyButton
@value={{'stringToCopy'}}
@name="Thing"
/>
Expand All @@ -20,12 +20,12 @@ Can be used inline to render only a small icon for the button with no other text
<figure>
<figcaption>Icon and text</figcaption>

<CopyButton
<ConsulCopyButton
@value={{'stringToCopy'}}
@name="Thing"
>
Copy me!
</CopyButton>
</ConsulCopyButton>
</figure>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
{{#let (fn dispatch 'SUCCESS') (fn dispatch 'ERROR') (fn dispatch 'RESET') as |success error reset|}}
<button
{{with-copyable @value success=success error=error}}
aria-label={{t 'components.copy-button.title' name=@name}}
aria-label={{t 'components.consul-copy-button.title' name=@name}}
type="button"
class="copy-btn"
...attributes
{{tooltip
(if (state-matches state 'success') (t 'components.copy-button.success' name=@name) (t 'components.copy-button.error'))
(if (state-matches state 'success') (t 'components.consul-copy-button.success' name=@name) (t 'components.consul-copy-button.error'))
options=(hash
trigger='manual'
showOnCreate=(not (state-matches state 'idle'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import Component from '@glimmer/component';
import chart from './chart.xstate';

export default class CopyButton extends Component {
export default class ConsulCopyButton extends Component {
constructor() {
super(...arguments);
this.chart = chart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<span>
{{combinedAddress}}
</span>
<CopyButton
<ConsulCopyButton
@value={{combinedAddress}}
@name="Address"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<dt>Output</dt>
<dd>
<pre><code>{{item.Output}}</code></pre>
<CopyButton @value={{item.Output}} @name="output" />
<ConsulCopyButton @value={{item.Output}} @name="output" />
</dd>
</dl>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ as |item index|>
<span>Address</span>
</dt>
<dd>
<CopyButton
<ConsulCopyButton
@value={{item.Address}}
@name="Address"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ as |item|>
</BlockSlot>
<BlockSlot @name="actions" as |Actions|>
{{#if item.hasSecretID}}
<CopyButton
<ConsulCopyButton
@value={{item.SecretID}}
@name={{t "components.consul.token.secretID"}}
>
{{t "components.consul.token.secretID"}}
</CopyButton>
</ConsulCopyButton>
{{/if}}
<Actions as |Action|>
<Action data-test-edit-action @href={{href-to 'dc.acls.tokens.edit' item.AccessorID}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Local bind socket path
</dt>
<dd>
<CopyButton
<ConsulCopyButton
@value={{item.LocalBindSocketPath}}
@name="Local bind socket path"
/>
Expand All @@ -73,7 +73,7 @@
Address
</dt>
<dd>
<CopyButton
<ConsulCopyButton
@value={{combinedAddress}}
@name="Address"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ as |item index|>
Address
</dt>
<dd>
<CopyButton
<ConsulCopyButton
@value={{address}}
@name="Address"
/>
Expand Down
4 changes: 2 additions & 2 deletions ui/packages/consul-ui/app/components/copyable-code/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
</disclosure.Details>
</Disclosure>

<CopyButton
<ConsulCopyButton
@value={{@value}}
@name={{@name}}
/>

{{else}}
<pre><code
>{{@value}}</code></pre>
<CopyButton
<ConsulCopyButton
@value={{@value}}
@name={{@name}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@
}}

<@disclosure.Details as |details|>
<PagedCollection
@items={{or @items (array)}}
as |pager|>
<PagedCollection @items={{or @items (array)}} as |pager|>
<div
{{on-outside 'click' @disclosure.close}}
{{did-insert pager.viewport}}
{{on-resize pager.resize}}
{{css-prop '--paged-row-height' returns=pager.rowHeight}}
{{css-prop 'max-height' returns=pager.maxHeight}}
class={{class-map
(array 'paged-collection-scroll' (includes pager.type (array 'virtual-scroll' 'native-scroll')))
(array
'paged-collection-scroll' (includes pager.type (array 'virtual-scroll' 'native-scroll'))
)
}}
...attributes
>
{{yield (hash
Menu=(component 'menu'
disclosure=@disclosure
pager=pager
)
)}}
{{yield (hash Menu=(component 'menu' disclosure=@disclosure pager=pager))}}
</div>
</PagedCollection>
</@disclosure.Details>

</@disclosure.Details>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ to provide a textual tooltip for the icon. Using the `{{tooltip}}` modifier
with no arguments will make it use the text/DOM content of the DOM element it
is attached to, see below for a full usage example.

`<CopyButton />` components are commonly added to the value, and can be added
`<ConsulCopyButton />` components are commonly added to the value, and can be added
to the left or right of the value.

```hbs preview-template
Expand Down Expand Up @@ -49,7 +49,7 @@ to the left or right of the value.
TTL
</dt>
<dd>
<CopyButton
<ConsulCopyButton
@value={{"1m30s10ms"}}
@name="TTL"
/>
Expand Down Expand Up @@ -96,7 +96,7 @@ to the left or right of the value.
</dt>
<dd>
1m30s10ms
<CopyButton
<ConsulCopyButton
@value={{"1m30s10ms"}}
@name="TTL"
/>
Expand Down Expand Up @@ -147,7 +147,7 @@ to the left or right of the value.
TTL
</dt>
<dd>
<CopyButton
<ConsulCopyButton
@value={{"1m30s10ms"}}
@name="TTL"
/>
Expand Down
25 changes: 13 additions & 12 deletions ui/packages/consul-ui/app/components/menu/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
}}

<ul
role="menu"
role='menu'
style={{{style-map
(array 'height' (if (and @pager (not-eq @pager.type 'native-scroll')) @pager.totalHeight) 'px')
(array '--paged-start' (if (and @pager (not-eq @pager.type 'native-scroll')) @pager.startHeight) 'px')
(array
'--paged-start' (if (and @pager (not-eq @pager.type 'native-scroll')) @pager.startHeight) 'px'
)
}}}
{{did-insert (optional @pager.pane)}}
{{aria-menu
onclose=(or @onclose @disclosure.close)
openEvent=(or @event @disclosure.event)
}}
{{aria-menu onclose=(or @onclose @disclosure.close) openEvent=(or @event @disclosure.event)}}
>
{{yield (hash
Action=(component 'menu/action' disclosure=@disclosure)
Item=(component 'menu/item')
Separator=(component 'menu/separator')
items=@pager.items
)}}
{{yield
(hash
Action=(component 'menu/action' disclosure=@disclosure)
Item=(component 'menu/item')
Separator=(component 'menu/separator')
items=@pager.items
)
}}
</ul>