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

Plot legends expand by default when enabled #7453

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
"WCAG",
"stackedplot",
"Andale",
"unnnormalized",
"unnormalized",
"checksnapshots",
"specced",
"countup"
Expand Down
54 changes: 54 additions & 0 deletions e2e/tests/functional/plugins/plot/overlayPlot.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,60 @@ test.describe('Overlay Plot', () => {
await expect(seriesColorSwatch).toHaveCSS('background-color', 'rgb(255, 166, 61)');
});

test('Plot legend expands by default', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/7403'
});
const overlayPlot = await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot'
});

await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});

await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});

await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});

await page.goto(overlayPlot.url);

await page.getByRole('tab', { name: 'Config' }).click();

// Assert that the legend is collapsed by default
await expect(page.getByLabel('Plot Legend Collapsed')).toBeVisible();
await expect(page.getByLabel('Plot Legend Expanded')).toBeHidden();
let expandDefaultValue = await page.getByLabel('Expand by Default').textContent();
expect(expandDefaultValue).toBe('No');

expect(await page.getByLabel('Plot Legend Item').count()).toBe(3);

// Change the legend to expand by default
await page.getByLabel('Edit Object').click();
await page.getByLabel('Expand By Default').check();
await page.getByLabel('Save').click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
await page.reload();

// Assert that the legend is expanded on page load
await expect(page.getByLabel('Plot Legend Collapsed')).toBeHidden();
await expect(page.getByLabel('Plot Legend Expanded')).toBeVisible();
await expect(page.getByRole('cell', { name: 'Name' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Value' })).toBeVisible();
expandDefaultValue = await page.getByLabel('Expand by Default').textContent();
expect(expandDefaultValue).toBe('Yes');
expect(await page.getByLabel('Plot Legend Item').count()).toBe(3);
});

test('Limit lines persist when series is moved to another Y Axis and on refresh', async ({
page
}) => {
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/persistence/couch/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
const LEGACY_SPACE = 'mct';

export default function CouchPlugin(options) {
function normalizeOptions(unnnormalizedOptions) {
function normalizeOptions(unnormalizedOptions) {
const normalizedOptions = {};
if (typeof unnnormalizedOptions === 'string') {
if (typeof unnormalizedOptions === 'string') {
normalizedOptions.databases = [
{
url: options,
Expand All @@ -41,19 +41,19 @@
indicator: true
}
];
} else if (!unnnormalizedOptions.databases) {
} else if (!unnormalizedOptions.databases) {
normalizedOptions.databases = [
{
url: unnnormalizedOptions.url,
url: unnormalizedOptions.url,
namespace: DEFAULT_NAMESPACE,
additionalNamespaces: [LEGACY_SPACE],
readOnly: false,
useDesignDocuments: unnnormalizedOptions.useDesignDocuments,
useDesignDocuments: unnormalizedOptions.useDesignDocuments,
indicator: true
}
];
} else {
normalizedOptions.databases = unnnormalizedOptions.databases;
normalizedOptions.databases = unnormalizedOptions.databases;

Check warning on line 56 in src/plugins/persistence/couch/plugin.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/persistence/couch/plugin.js#L56

Added line #L56 was not covered by tests
}

// final sanity check, ensure we have all options
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plot/configuration/XAxisModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class XAxisModel extends Model {
*/
defaultModel(options) {
const bounds = options.openmct.time.bounds();
const timeSystem = options.openmct.time.timeSystem();
const timeSystem = options.openmct.time.getTimeSystem();
const format = options.openmct.telemetry.getFormatter(timeSystem.timeFormat);

/** @type {XAxisModelType} */
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/plot/inspector/PlotOptionsBrowse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@
<div class="grid-cell label" title="Show the legend expanded by default">
Expand by Default
</div>
<div class="grid-cell value">{{ expandByDefault ? 'Yes' : 'No' }}</div>
<div aria-label="Expand by Default" class="grid-cell value">
{{ expandByDefault ? 'Yes' : 'No' }}
</div>
</li>
<li class="grid-row">
<div class="grid-cell label" title="What to display in the legend when it's collapsed.">
Expand Down Expand Up @@ -174,9 +176,8 @@ export default {
if (!this.isStackedPlotObject) {
this.initYAxesConfiguration();
this.registerListeners();
} else {
this.initLegendConfiguration();
}
this.initLegendConfiguration();

this.loaded = true;
},
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/plot/inspector/PlotOptionsItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export default {
},
data() {
return {
expanded: false
expanded: false,
status: null
};
},
computed: {
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/plot/inspector/forms/LegendForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@
Expand by default
</div>
<div class="grid-cell value">
<input v-model="expandByDefault" type="checkbox" @change="updateForm('expandByDefault')" />
<input
v-model="expandByDefault"
aria-label="Expand By Default"
type="checkbox"
@change="updateForm('expandByDefault')"
/>
</div>
</li>
<li class="grid-row">
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/plot/inspector/forms/SeriesForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export default {
limitLines: this.series.get('limitLines'),
markerSize: this.series.get('markerSize'),
validation: {},
swatchActive: false
swatchActive: false,
status: null
};
},
computed: {
Expand Down
15 changes: 13 additions & 2 deletions src/plugins/plot/legend/PlotLegend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@

<div class="c-plot-legend__wrapper" :class="{ 'is-cursor-locked': cursorLocked }">
<!-- COLLAPSED PLOT LEGEND -->
<div class="plot-wrapper-collapsed-legend" :class="{ 'is-cursor-locked': cursorLocked }">
<div
v-if="!isLegendExpanded"
class="plot-wrapper-collapsed-legend"
aria-label="Plot Legend Collapsed"
:class="{ 'is-cursor-locked': cursorLocked }"
>
<div
class="c-state-indicator__alert-cursor-lock icon-cursor-lock"
title="Cursor is point locked. Click anywhere in the plot to unlock."
Expand All @@ -50,7 +55,12 @@
/>
</div>
<!-- EXPANDED PLOT LEGEND -->
<div class="plot-wrapper-expanded-legend" :class="{ 'is-cursor-locked': cursorLocked }">
<div
v-else
class="plot-wrapper-expanded-legend"
aria-label="Plot Legend Expanded"
:class="{ 'is-cursor-locked': cursorLocked }"
>
<div
class="c-state-indicator__alert-cursor-lock--verbose icon-cursor-lock"
title="Click anywhere in the plot to unlock."
Expand Down Expand Up @@ -150,6 +160,7 @@ export default {
mounted() {
this.loaded = true;
this.isLegendExpanded = this.legend.get('expanded') === true;
this.$emit('expanded', this.isLegendExpanded);
this.updatePosition();
},
beforeUnmount() {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/plot/legend/PlotLegendItemCollapsed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<template>
<div
class="plot-legend-item"
aria-label="Plot Legend Item"
:class="{
'is-stale': isStale,
'is-status--missing': isMissing
Expand Down
1 change: 1 addition & 0 deletions src/plugins/plot/legend/PlotLegendItemExpanded.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<template>
<tr
class="plot-legend-item"
aria-label="Plot Legend Item"
:class="{
'is-stale': isStale,
'is-status--missing': isMissing
Expand Down
1 change: 1 addition & 0 deletions src/plugins/plot/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ describe('the plugin', function () {
const clickEvent = createMouseEvent('click');

legendControl.dispatchEvent(clickEvent);
await nextTick();

let legend = element.querySelectorAll('.plot-wrapper-expanded-legend .plot-legend-item td');
expect(legend.length).toBe(6);
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/plot/stackedPlot/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,16 @@ describe('the plugin', function () {
expect(legend[0].innerHTML).toEqual('Test Object');
});

it('Renders an expanded legend for every telemetry', () => {
it('Renders an expanded legend for every telemetry', async () => {
let legendControl = element.querySelector(
'.c-plot-legend__view-control.gl-plot-legend__view-control.c-disclosure-triangle'
);
const clickEvent = createMouseEvent('click');

legendControl.dispatchEvent(clickEvent);

await nextTick();

let legend = element.querySelectorAll('.plot-wrapper-expanded-legend .plot-legend-item td');
expect(legend.length).toBe(6);
});
Expand Down
7 changes: 0 additions & 7 deletions src/styles/_legacy-plots.scss
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,6 @@ mct-plot {

.gl-plot,
.c-plot {
&.plot-legend-collapsed .plot-wrapper-expanded-legend {
display: none;
}
&.plot-legend-expanded .plot-wrapper-collapsed-legend {
display: none;
}

&.plot-legend-collapsed .icon-cursor-lock::before {
padding-right: 5px;
}
Expand Down
Loading