From bfc6467e55fb906c4bd78689f09f4cab63e23531 Mon Sep 17 00:00:00 2001 From: claire bontempo <68122737+hellobontempo@users.noreply.github.com> Date: Thu, 4 Nov 2021 16:57:08 -0700 Subject: [PATCH] UI/Truncate long secret names (#13032) * small bar chart attr fix * truncates and adds ellipsis of label is long * adds tooltip for long labels * updates storybook * adds changelog * only calculate overflow if query selectors grab elements * moves tooltip pointer to left --- changelog/13032.txt | 3 +++ ui/app/styles/components/info-table-row.scss | 14 ++++++++++++++ ui/app/styles/components/tool-tip.scss | 6 ++++++ ui/lib/core/addon/components/bar-chart.js | 2 +- ui/lib/core/addon/components/info-table-row.js | 13 +++++++++++++ .../templates/components/info-table-row.hbs | 18 +++++++++++++++++- ui/lib/core/stories/info-table-row.md | 1 + ui/lib/core/stories/info-table-row.stories.js | 6 +++++- 8 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 changelog/13032.txt diff --git a/changelog/13032.txt b/changelog/13032.txt new file mode 100644 index 000000000..b3ea4cd01 --- /dev/null +++ b/changelog/13032.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixes long secret key names overlapping masked values +``` diff --git a/ui/app/styles/components/info-table-row.scss b/ui/app/styles/components/info-table-row.scss index 9b7e3de2e..1203af224 100644 --- a/ui/app/styles/components/info-table-row.scss +++ b/ui/app/styles/components/info-table-row.scss @@ -90,3 +90,17 @@ padding-left: 0; } } + +.label-overflow { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + + // inline display necessary for nested elements so ellipsis shows + > div { + display: inline; + } + > div > span { + display: inline; + } +} diff --git a/ui/app/styles/components/tool-tip.scss b/ui/app/styles/components/tool-tip.scss index 392f898da..3f3bf5d3e 100644 --- a/ui/app/styles/components/tool-tip.scss +++ b/ui/app/styles/components/tool-tip.scss @@ -2,6 +2,7 @@ font-size: $size-7; text-transform: none; margin: 8px 0px 0 -4px; + .box { position: relative; color: $white; @@ -10,6 +11,11 @@ padding: 0.5rem; line-height: 1.4; } + + .fit-content { + max-width: fit-content; + } + @include css-top-arrow(8px, $grey, 1px, $grey-dark, 20px); &.ember-basic-dropdown-content--below.ember-basic-dropdown--transitioning-in { animation: drop-fade-above 0.15s; diff --git a/ui/lib/core/addon/components/bar-chart.js b/ui/lib/core/addon/components/bar-chart.js index bcc49e074..aba5c929b 100644 --- a/ui/lib/core/addon/components/bar-chart.js +++ b/ui/lib/core/addon/components/bar-chart.js @@ -19,7 +19,7 @@ * @param {string} title - title of the chart * @param {array} mapLegend - array of objects with key names 'key' and 'label' for the map legend * @param {object} dataset - dataset for the chart - * @param {array} tooltipData - misc. information needed to display tooltip (i.e. total clients from query params) + * @param {any} tooltipData - misc. information needed to display tooltip (i.e. total clients from query params) * @param {string} [description] - description of the chart * @param {string} [labelKey=label] - labelKey is the key name in the dataset passed in that corresponds to the value labeling the y-axis * @param {function} [onClick] - takes function from parent and passes it to click event on data bars diff --git a/ui/lib/core/addon/components/info-table-row.js b/ui/lib/core/addon/components/info-table-row.js index ae66657b0..7dfb7cc36 100644 --- a/ui/lib/core/addon/components/info-table-row.js +++ b/ui/lib/core/addon/components/info-table-row.js @@ -42,6 +42,7 @@ export default Component.extend({ tooltipText: '', isTooltipCopyable: false, defaultShown: '', + hasLabelOverflow: false, // is calculated and set in didInsertElement valueIsBoolean: computed('value', function() { return typeOf(this.value) === 'boolean'; @@ -63,4 +64,16 @@ export default Component.extend({ return false; } }), + + didInsertElement() { + this._super(...arguments); + const labelDiv = this.element.querySelector('div'); + const labelText = this.element.querySelector('.is-label'); + if (labelDiv && labelText) { + if (labelText.offsetWidth > labelDiv.offsetWidth) { + labelDiv.classList.add('label-overflow'); + this.set('hasLabelOverflow', true); + } + } + }, }); diff --git a/ui/lib/core/addon/templates/components/info-table-row.hbs b/ui/lib/core/addon/templates/components/info-table-row.hbs index 24fed394d..07455f776 100644 --- a/ui/lib/core/addon/templates/components/info-table-row.hbs +++ b/ui/lib/core/addon/templates/components/info-table-row.hbs @@ -1,7 +1,23 @@ {{#if (or alwaysRender value)}}
String
| | Passed through to InfoTableItemArray. To specify secrets backend to point link to Ex: transformation |
| [viewAll] | String
| | Passed through to InfoTableItemArray. Specify the word at the end of the link View all. |
| [tooltipText] | String
| | Text if a tooltip should display over the value. |
+| [isTooltipCopyable] | Boolean
| | Allows tooltip click to copy |
| [defaultShown] | String
| | Text that renders as value if alwaysRender=true. Eg. "Vault default" |
**Example**
diff --git a/ui/lib/core/stories/info-table-row.stories.js b/ui/lib/core/stories/info-table-row.stories.js
index b19b836a3..63178d0fb 100644
--- a/ui/lib/core/stories/info-table-row.stories.js
+++ b/ui/lib/core/stories/info-table-row.stories.js
@@ -16,14 +16,18 @@ storiesOf('InfoTable/InfoTableRow', module)
@label={{label}}
@helperText={{helperText}}
@alwaysRender={{alwaysRender}}
- @tooltipText={{tooltipText}} />
+ @defaultShown={{defaultShown}}
+ @tooltipText={{tooltipText}}
+ @isTooltipCopyable={{isTooltipCopyable}} />
`,
context: {
label: text('Label', 'TTL'),
value: text('Value', '30m (hover to see the tooltip!)'),
helperText: text('helperText', 'This is helperText - for a short description'),
alwaysRender: boolean('Always render?', false),
+ defaultShown: text('Default value', 'Some default value'),
tooltipText: text('tooltipText', 'This is tooltipText'),
+ isTooltipCopyable: boolean('Allow tooltip to be copied', true),
},
}),
{ notes }