-
Notifications
You must be signed in to change notification settings - Fork 10
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
fix: analytics chart kebab menu positioning #1785
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
<template> | ||
<div class="analytics-chart-shell"> | ||
<div | ||
class="analytics-chart-shell" | ||
:class="{ 'is-hovering': isHovering }" | ||
@mouseenter="handleMouseEnter" | ||
@mouseleave="handleMouseLeave" | ||
> | ||
<div | ||
v-if="showChartHeader" | ||
class="chart-header" | ||
> | ||
<div | ||
|
@@ -43,10 +47,17 @@ | |
class="dropdown" | ||
data-testid="chart-action-menu" | ||
> | ||
<MoreIcon | ||
:color="KUI_COLOR_TEXT_NEUTRAL" | ||
:size="KUI_ICON_SIZE_40" | ||
/> | ||
<button | ||
appearance="none" | ||
:aria-label="i18n.t('more_actions')" | ||
class="kebab-action-menu" | ||
data-testid="kebab-action-menu" | ||
> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call here. Without the button element, the nested SVG can sometimes "steal" the click action |
||
<MoreIcon | ||
:color="KUI_COLOR_TEXT_NEUTRAL" | ||
:size="KUI_ICON_SIZE_40" | ||
/> | ||
</button> | ||
<template #items> | ||
<KDropdownItem | ||
v-if="!!goToExplore" | ||
|
@@ -158,7 +169,7 @@ import { msToGranularity } from '@kong-ui-public/analytics-utilities' | |
import type { AbsoluteTimeRangeV4, ExploreAggregations, ExploreResultV4, GranularityValues } from '@kong-ui-public/analytics-utilities' | ||
import { hasMillisecondTimestamps, defaultStatusCodeColors } from '../utils' | ||
import TimeSeriesChart from './chart-types/TimeSeriesChart.vue' | ||
import { KUI_COLOR_TEXT_NEUTRAL, KUI_COLOR_TEXT_WARNING, KUI_ICON_SIZE_40 } from '@kong/design-tokens' | ||
import { KUI_COLOR_TEXT_NEUTRAL, KUI_COLOR_TEXT_WARNING, KUI_ICON_SIZE_40, KUI_SPACE_70 } from '@kong/design-tokens' | ||
import { MoreIcon, WarningIcon } from '@kong/icons' | ||
import CsvExportModal from './CsvExportModal.vue' | ||
import CsvExportButton from './CsvExportButton.vue' | ||
|
@@ -249,6 +260,8 @@ const { evaluateFeatureFlag } = composables.useEvaluateFeatureFlag() | |
const hasKebabMenuAccess = evaluateFeatureFlag('ma-3043-analytics-chart-kebab-menu', false) | ||
|
||
const rawChartData = toRef(props, 'chartData') | ||
const isHovering = ref(false) | ||
|
||
|
||
const computedChartData = computed(() => { | ||
return isTimeSeriesChart.value | ||
|
@@ -364,10 +377,6 @@ const hasValidChartData = computed(() => { | |
return props.chartData && props.chartData.meta && props.chartData.data.length | ||
}) | ||
|
||
const showChartHeader = computed(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a chart doesn't have a title and doesn't have valid data, does this behave the same way as before? (It seems like we're showing a header in that case where before we didn't.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I don't think the chart header should be hidden any longer in the case that there is no data. We may still want to show the kebab menu that could still contain valid actions a user can take, regardless of the chart having data. For example, a chart in a dashboard may not have data for whatever reason. A user may still want to "go to explore" or "edit" the tile in order to investigate why the chart has no data, or make changes to the query backing the chart/tile. So I think the old logic had to be changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that makes sense; my main concern is that this is changing outside of the feature flag. I took a look at the sandbox, and I think the change is basically invisible, so I won't worry about it. |
||
return (hasValidChartData.value && resultSetTruncated.value && maxEntitiesShown.value) || props.chartTitle || (props.allowCsvExport && hasValidChartData.value) | ||
}) | ||
|
||
const hasMenuOptions = computed(() => (props.allowCsvExport && hasValidChartData.value) || !!props.goToExplore || props.showMenu) | ||
|
||
const timeSeriesGranularity = computed<GranularityValues>(() => { | ||
|
@@ -429,6 +438,22 @@ const chartTooltipSortFn = computed(() => { | |
} | ||
}) | ||
|
||
const chartHeaderPosition = computed(() => { | ||
return props.chartTitle || !hasKebabMenuAccess || (resultSetTruncated.value && maxEntitiesShown.value) ? 'relative' : 'absolute' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember how this part of explore works, but may be this was based off an old faulty assumption. 😅 Those computed props are based off the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aaagh, I'm sorry. I dug a bit deeper and these two things are complementary -- basically, if results are truncated, you can read |
||
}) | ||
|
||
const chartHeaderWidth = computed(() => { | ||
return chartHeaderPosition.value === 'relative' ? '100%' : KUI_SPACE_70 | ||
}) | ||
|
||
const handleMouseEnter = () => { | ||
isHovering.value = true | ||
} | ||
|
||
const handleMouseLeave = () => { | ||
isHovering.value = false | ||
} | ||
|
||
provide('showLegendValues', showLegendValues) | ||
provide('legendPosition', toRef(props, 'legendPosition')) | ||
|
||
|
@@ -440,8 +465,16 @@ provide('legendPosition', toRef(props, 'legendPosition')) | |
|
||
.analytics-chart-shell { | ||
height: 100%; | ||
position: relative; | ||
width: 100%; | ||
|
||
&.is-hovering { | ||
.chart-header :deep(.popover-trigger-wrapper) { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
} | ||
|
||
.analytics-chart-parent { | ||
height: inherit; | ||
width: inherit; | ||
|
@@ -458,6 +491,15 @@ provide('legendPosition', toRef(props, 'legendPosition')) | |
display: flex; | ||
justify-content: flex-start; | ||
padding-bottom: var(--kui-space-60, $kui-space-60); | ||
position: v-bind('chartHeaderPosition'); | ||
right: 0; | ||
width: v-bind('chartHeaderWidth'); | ||
z-index: 999; | ||
|
||
&:hover :deep(.popover-trigger-wrapper) { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
|
||
.chart-header-icons-wrapper { | ||
display: flex; | ||
|
@@ -493,6 +535,21 @@ provide('legendPosition', toRef(props, 'legendPosition')) | |
margin-left: var(--kui-space-auto, $kui-space-auto); | ||
margin-right: var(--kui-space-0, $kui-space-0); | ||
|
||
:deep(.popover-trigger-wrapper) { | ||
opacity: 0; | ||
transform: fade(0, -10px); | ||
transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s; | ||
visibility: hidden; | ||
} | ||
|
||
.kebab-action-menu { | ||
background: $kui-color-background-transparent; | ||
border: none; | ||
color: inherit; | ||
cursor: pointer; | ||
height: 100%; | ||
} | ||
|
||
li.k-dropdown-item { | ||
a { | ||
text-decoration: none; | ||
|
@@ -512,5 +569,4 @@ provide('legendPosition', toRef(props, 'legendPosition')) | |
} | ||
} | ||
} | ||
|
||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
> | ||
<canvas | ||
ref="canvas" | ||
class="chart-canvas" | ||
/> | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,6 @@ const dashboardConfig: DashboardConfig = { | |
{ | ||
definition: { | ||
chart: { | ||
chartTitle: 'Timeseries line chart of mock data', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor, but please remove this change; we might still trigger a new renderer version because it depends on |
||
type: 'timeseries_line', | ||
}, | ||
query: { | ||
|
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.
Please remove the
.only
.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.
Wooops 🙈