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

[Flexible Layouts] Flexible Layout styling fixes #7319

Merged
merged 39 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
39f30c0
Add css class to flexible layouts to allow them to be styled, reset s…
khalidadil Nov 9, 2023
30b34a2
Add tests
khalidadil Dec 20, 2023
ad290cb
Merge branch 'master' into bugfix/issue-6693
khalidadil Dec 20, 2023
5889376
Add tests
khalidadil Dec 20, 2023
6ab76ba
Remove accidental commit
khalidadil Dec 20, 2023
e28abcb
first pass
unlikelyzero Dec 22, 2023
b462c6d
drive-by to improve flex layout git blame
unlikelyzero Dec 22, 2023
3aaf74b
drive-by to improve watch mode
unlikelyzero Dec 22, 2023
aef2432
fix flexlayout toolbar options
unlikelyzero Dec 22, 2023
8bd5757
fix roles for flexlayout to be a grid instead of group
unlikelyzero Dec 22, 2023
3b56b67
driveby git blame ignore
unlikelyzero Dec 23, 2023
8190388
Some more testability improvements
unlikelyzero Dec 26, 2023
8165117
Improving the tests
unlikelyzero Dec 26, 2023
742e8e0
fixes
unlikelyzero Dec 26, 2023
c4a7292
Merge branch 'master' into bugfix/issue-6693
ozyx Dec 27, 2023
5f5c07e
test(e2e): fix styling tests
ozyx Dec 28, 2023
08ed4be
Merge branch 'master' into bugfix/issue-6693
khalidadil Dec 28, 2023
70ad074
test(e2e): fix flex layout toolbar test
ozyx Dec 28, 2023
a8ac603
test(e2e): fix row/column layout test
ozyx Dec 28, 2023
877b54a
a11y: "More options" -> "More actions"
ozyx Dec 29, 2023
3e16f0f
Change name of computed property for options label from getLabel to o…
khalidadil Dec 30, 2023
9945814
split up tests and work on stackedPlotStyling
unlikelyzero Jan 2, 2024
de1f511
Merge branch 'bugfix/issue-6693' of https://github.com/nasa/openmct i…
unlikelyzero Jan 2, 2024
3644534
add border styling
unlikelyzero Jan 2, 2024
72320b2
break out conditional and style inspector
unlikelyzero Jan 2, 2024
5001f66
update flexlayout tests and add stackedplot (wip)
unlikelyzero Jan 2, 2024
2aa76b0
Merge branch 'master' of https://github.com/nasa/openmct into bugfix/…
unlikelyzero Jan 2, 2024
d0fadd3
fix imports
unlikelyzero Jan 3, 2024
ffdba24
Add visual test
unlikelyzero Jan 3, 2024
46d4a29
update stackedplot test
unlikelyzero Jan 3, 2024
8eb5856
Add a11y label
unlikelyzero Jan 3, 2024
f3409b3
add font styles checks
unlikelyzero Jan 3, 2024
5371591
add font checking
unlikelyzero Jan 3, 2024
1b7f0b3
add visual tests
unlikelyzero Jan 3, 2024
cf2681e
Update toolbar to use aria
unlikelyzero Jan 3, 2024
4971bce
linting and comments
unlikelyzero Jan 3, 2024
1df1f72
lint fix
unlikelyzero Jan 3, 2024
6e5fd05
update comments
unlikelyzero Jan 3, 2024
8cf081d
skip test for bug
unlikelyzero Jan 4, 2024
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
283 changes: 283 additions & 0 deletions e2e/tests/functional/styling.e2e.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/

/**
* This test is dedicated to test styling of various plugins
*/

const { test, expect } = require('../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../appActions');

test.describe('Flexible Layout styling', () => {
let sineWaveObject;
let sineWaveObject2;
let treePane;
let sineWaveGeneratorTreeItem;
let sineWaveGeneratorTreeItem2;
let stackedPlotTreeItem;
let stackedPlot;
let flexibleLayout;
test.beforeEach(async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });

// Create a Flexible Layout and attach to the Stacked Plot
flexibleLayout = await createDomainObjectWithDefaults(page, {
type: 'Flexible Layout',
name: 'Flexible Layout'
});
console.log('flexibleLayout', flexibleLayout.uuid);

// Create a Stacked Plot and attach to the Flexible Layout
stackedPlot = await createDomainObjectWithDefaults(page, {
type: 'Stacked Plot',
name: 'Stacked Plot',
parent: flexibleLayout.uuid
});
console.log('stackedplot', stackedPlot.uuid);

// Create two SWGs and attach them to the Stacked Plot
sineWaveObject = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: 'Sine Wave Generator 1',
parent: stackedPlot.uuid
});
console.log('sineWaveObject', sineWaveObject.uuid);

sineWaveObject2 = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: 'Sine Wave Generator 2',
parent: stackedPlot.uuid
});
console.log('sineWaveObject2', sineWaveObject2.uuid);
});

test.only('selecting a flexible layout column hides the styles tab', async ({ page }) => {
await page.goto(flexibleLayout.url, { waitUntil: 'domcontentloaded' });

// Edit Flexible Layout
await page.getByLabel('Edit').click();

// Expect to find styles tab
await expect(page.getByRole('tab', { name: 'Styles' })).toBeVisible();

// Select flexible layout column
// await page.getByLabel('Stacked Plot Frame').click();
await page.getByRole('group', { name: /Container \b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/ }).click();

// Expect to find no styles tab
await expect(page.getByRole('tab', { name: 'Styles' })).toBeHidden();
});

test('styling the flexible layout properly applies the styles to the container', async ({
page
}) => {
const backgroundColor = 'rgb(91, 15, 0)';
const fontColor = 'rgb(230, 184, 175)';
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Select styles tab
await page.locator('.c-inspector__tab[title="Styles"]').click();
// Set background color
await page.locator('.c-icon-button.icon-paint-bucket').click();
await page.locator(`.c-palette__item[style="background: ${backgroundColor};"]`).click();
// Set font color
await page.locator('.c-icon-button.icon-font').click();
await page.locator(`.c-palette__item[style="background: ${fontColor};"]`).click();

// Find Flexible Layout container
let flexibleLayoutContainer = await page.locator('.c-fl__container-holder');
let layoutStyles = await flexibleLayoutContainer.evaluate((el) => {
return {
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});

// Verify styles match set styles
expect(layoutStyles.background).toBe(backgroundColor);
expect(layoutStyles.fontColor).toBe(fontColor);

// Save Flexible Layout
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();

// Reload page and check styles again
await page.goto(flexibleLayout.url);
flexibleLayoutContainer = await page.locator('.c-fl__container-holder');
layoutStyles = await flexibleLayoutContainer.evaluate((el) => {
return {
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});

// Verify styles match set styles
expect(layoutStyles.background).toBe(backgroundColor);
expect(layoutStyles.fontColor).toBe(fontColor);
});

test('styling a child object of the flexible layout properly applies that style to only that child', async ({
page
}) => {
const backgroundColor = 'rgb(91, 15, 0)';
const fontColor = 'rgb(230, 184, 175)';
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Select Stacked Plot
let stackedPlotContainer = await page.locator('.c-plot--stacked');
// eslint-disable-next-line playwright/no-force-option
stackedPlotContainer.click({ force: true });

// Select styles tab
await page.locator('.c-inspector__tab[title="Styles"]').click();
// Set background color
await page.locator('.c-icon-button.icon-paint-bucket').click();
await page.locator(`.c-palette__item[style="background: ${backgroundColor};"]`).click();
// Set font color
await page.locator('.c-icon-button.icon-font[title="Set text color"]').click();
await page.locator(`.c-palette__item[style="background: ${fontColor};"]`).click();

// Get Stacked Plot styles
let stackedPlotStyles = await stackedPlotContainer.evaluate((el) => {
return {
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});

// Verify styles match set styles
expect(stackedPlotStyles.background).toBe(backgroundColor);
expect(stackedPlotStyles.fontColor).toBe(fontColor);

// Save Flexible Layout
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();

// Reload page and check styles again
await page.goto(flexibleLayout.url);
stackedPlotContainer = await page.locator('.c-plot--stacked');
stackedPlotStyles = await stackedPlotContainer.evaluate((el) => {
return {
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});

// Verify styles match set styles
expect(stackedPlotStyles.background).toBe(backgroundColor);
expect(stackedPlotStyles.fontColor).toBe(fontColor);
});

test('When the "no style" option is selected, background and text should be reset to inherited styles', async ({
page
}) => {
// Set background and font color on Stacked Plot object
const backgroundColor = 'rgb(91, 15, 0)';
const fontColor = 'rgb(230, 184, 175)';
const inheritedBackgroundColor = 'rgba(0, 0, 0, 0)'; // inherited from the theme
const inheritedFontColor = 'rgb(170, 170, 170)'; // inherited from the body style
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Select Stacked Plot
let stackedPlotContainer = await page.locator('.c-plot--stacked');
// eslint-disable-next-line playwright/no-force-option
stackedPlotContainer.click({ force: true });

// Select styles tab
await page.locator('.c-inspector__tab[title="Styles"]').click();
// Set background color
await page.locator('.c-icon-button.icon-paint-bucket').click();
await page.locator(`.c-palette__item[style="background: ${backgroundColor};"]`).click();
// Set font color
await page.locator('.c-icon-button.icon-font[title="Set text color"]').click();
await page.locator(`.c-palette__item[style="background: ${fontColor};"]`).click();

// Get Stacked Plot styles
let stackedPlotStyles = await stackedPlotContainer.evaluate((el) => {
return {
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});

// Verify styles match set styles
expect(stackedPlotStyles.background).toBe(backgroundColor);
expect(stackedPlotStyles.fontColor).toBe(fontColor);

// Save Flexible Layout
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();

// Reload page and set styles to "None"
await page.goto(flexibleLayout.url);

// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Select Stacked Plot
stackedPlotContainer = await page.locator('.c-plot--stacked');
// eslint-disable-next-line playwright/no-force-option
stackedPlotContainer.click({ force: true });

// Select styles tab
await page.locator('.c-inspector__tab[title="Styles"]').click();
// Set background color
await page.locator('.c-icon-button.icon-paint-bucket').click();
await page.locator(`.c-palette__item-none`).click();
// Set font color
await page.locator('.c-icon-button.icon-font[title="Set text color"]').click();
await page.locator(`.c-palette__item-none`).click();

// Get Stacked Plot styles
stackedPlotStyles = await stackedPlotContainer.evaluate((el) => {
return {
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});

// Verify styles match inherited styles
expect(stackedPlotStyles.background).toBe(inheritedBackgroundColor);
expect(stackedPlotStyles.fontColor).toBe(inheritedFontColor);

// Save Flexible Layout
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();

// Reload page and check styles again after resetting styles to "None"
await page.goto(flexibleLayout.url);

// Select Stacked Plot
stackedPlotContainer = await page.locator('.c-plot--stacked');

// Get Stacked Plot styles
stackedPlotStyles = await stackedPlotContainer.evaluate((el) => {
return {
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});

// Verify styles match inherited styles
expect(stackedPlotStyles.background).toBe(inheritedBackgroundColor);
expect(stackedPlotStyles.fontColor).toBe(inheritedFontColor);
});
});
2 changes: 1 addition & 1 deletion src/plugins/flexibleLayout/components/FlexibleLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>

<div
class="c-fl__container-holder"
class="c-fl__container-holder u-style-receiver js-style-receiver"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to fix styles not being applied properly

:class="{
'c-fl--rows': rowsLayout === true
}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ export default function StylesInspectorViewProvider(openmct) {
glyph: 'icon-paint-bucket',
canView: function (selection) {
const objectSelection = selection?.[0];
const layoutItem = objectSelection?.[0]?.context?.layoutItem;
const domainObject = objectSelection?.[0]?.context?.item;
const objectContext = objectSelection?.[0]?.context;
const layoutItem = objectContext?.layoutItem;
const domainObject = objectContext?.item;
const isFlexibleLayoutContainer =
domainObject?.type === 'flexible-layout' && objectContext.type === 'container';

if (layoutItem) {
return true;
}

if (!domainObject) {
if (!domainObject || isFlexibleLayoutContainer) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to disable the styles tab on flexible layout containers

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plot/stackedPlot/StackedPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<template>
<div
v-if="loaded"
class="c-plot c-plot--stacked holder holder-plot has-control-bar"
class="c-plot c-plot--stacked holder holder-plot has-control-bar u-style-receiver js-style-receiver"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to fix the styles landing on the plot instead of the container. This created an issue where removing styles wasn't working properly since the add and remove targeted different elements.

:class="[plotLegendExpandedStateClass, plotLegendPositionClass]"
>
<plot-legend
Expand Down
6 changes: 5 additions & 1 deletion src/ui/components/ObjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ export default {
if (elemToStyle) {
if (typeof styleObj[key] === 'string' && styleObj[key].indexOf('__no_value') > -1) {
if (elemToStyle.style[key]) {
elemToStyle.style[key] = '';
if (key === 'background-color') {
elemToStyle.style[key] = 'transparent';
} else {
elemToStyle.style[key] = '';
}
}
} else {
if (
Expand Down
4 changes: 4 additions & 0 deletions src/ui/layout/BrowseBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ export default {
title: 'Saving'
});

const currentSelection = this.openmct.selection.selected[0];
const parentObject = currentSelection[currentSelection.length - 1];
this.openmct.selection.select(parentObject);

return this.openmct.editor
.save()
.then(() => {
Expand Down