Skip to content

Commit

Permalink
[Overlay] add suppression option to overlay dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
johnriedel committed Jan 19, 2025
1 parent 1fde0d9 commit 609ec4b
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 18 deletions.
52 changes: 52 additions & 0 deletions e2e/tests/functional/plugins/plot/plotRendering.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,58 @@ test.describe('Plot Rendering', () => {
await expect(page.getByLabel('Time Conductor Mode')).toHaveText('Fixed Timespan');
});

test('Time conductor synchronization confirmation dialog can be suppressed', async ({ page }) => {
// Navigate to Sine Wave Generator
await page.goto(sineWaveGeneratorObject.url);
// Switch to real-time mode
await setRealTimeMode(page);

// hover over plot for plot controls
await page.getByLabel('Plot Canvas').hover();
// click on pause control
await page.getByTitle('Pause incoming real-time data').click();

// expect plot to be paused
await expect(page.getByTitle('Resume displaying real-time data')).toBeVisible();

// hover over plot for plot controls
await page.getByLabel('Plot Canvas').hover();

// click on synchronize with time conductor
await page.getByTitle('Synchronize Time Conductor').click();

await expect(page.locator('.c-message__action-text')).toContainText(
'This action will change the Time Conductor to Fixed Timespan mode'
);

await page.getByLabel('Checkbox to Suppress Dialog').click();

await page.getByRole('button', { name: 'Ok', exact: true }).click();

//confirm that you're now in fixed mode with the correct range
await expect(page.getByLabel('Time Conductor Mode')).toHaveText('Fixed Timespan');

await page.getByLabel('Zoom in').click();

await page.getByTitle('Synchronize Time Conductor').click();

await expect(page.locator('.c-message-banner__message')).toHaveText(
'Time conductor bounds have changed.'
);

await expect(page.locator('.c-message__action-text')).toBeHidden();

const suppressionVal = await page.evaluate(() =>
window.localStorage.getItem('sync-time-conductor-modal-suppression')
);

await expect(suppressionVal).toBe('true');

await page.evaluate(() =>
window.localStorage.removeItem('sync-time-conductor-modal-suppression')
);
});

test('Plot is rendered when infinity values exist', async ({ page }) => {
// Edit Plot
await editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject);
Expand Down
4 changes: 4 additions & 0 deletions src/api/overlays/Overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Overlay extends EventEmitter {
element,
onDestroy,
onDismiss,
showSuppressOption = false,
suppressionText = "Don't ask again",
size
} = {}) {
super();
Expand All @@ -38,6 +40,8 @@ class Overlay extends EventEmitter {
dismiss: this.notifyAndDismiss.bind(this),
element,
buttons,
showSuppressOption,
suppressionText,
dismissible: this.dismissible
},
template: '<overlay-component></overlay-component>'
Expand Down
50 changes: 34 additions & 16 deletions src/api/overlays/components/OverlayComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,33 @@
class="c-overlay__contents js-notebook-snapshot-item-wrapper"
tabindex="0"
></div>
<div v-if="buttons" class="c-overlay__button-bar">
<button
v-for="(button, index) in buttons"
ref="buttons"
:key="index"
class="c-button js-overlay__button"
tabindex="0"
:class="{ 'c-button--major': focusIndex === index }"
@focus="focusIndex = index"
@click="buttonClickHandler(button.callback)"
>
{{ button.label }}
</button>
<div v-if="buttons || showSuppressOption" class="c-overlay__footer">
<div class="c-overlay__suppress-option">
<div v-if="showSuppressOption">
<input
id="suppressCheckbox"
v-model="suppress"
type="checkbox"
class="l-composite-control l-checkbox"
aria-label="Checkbox to Suppress Dialog"
/>
<label for="suppressCheckbox">{{ suppressionText }}</label>
</div>
</div>
<div v-if="buttons" class="c-overlay__button-bar">
<button
v-for="(button, buttonIndex) in buttons"
ref="buttons"
:key="buttonIndex"
class="c-button js-overlay__button"
tabindex="0"
:class="{ 'c-button--major': focusIndex === buttonIndex }"
@focus="focusIndex = buttonIndex"
@click="buttonClickHandler(button.callback)"
>
{{ button.label }}
</button>
</div>
</div>
</div>
</div>
Expand All @@ -56,11 +70,12 @@

<script>
export default {
inject: ['dismiss', 'element', 'buttons', 'dismissible'],
inject: ['dismiss', 'element', 'buttons', 'dismissible', 'showSuppressOption', 'suppressionText'],
emits: ['destroy'],
data() {
return {
focusIndex: -1
focusIndex: -1,
suppress: false
};
},
mounted() {
Expand All @@ -78,7 +93,10 @@ export default {
}
},
buttonClickHandler(method) {
method();
let callbackData = {

Check warning on line 96 in src/api/overlays/components/OverlayComponent.vue

View check run for this annotation

Codecov / codecov/patch

src/api/overlays/components/OverlayComponent.vue#L96

Added line #L96 was not covered by tests
suppress: this.suppress
};
method(callbackData);

Check warning on line 99 in src/api/overlays/components/OverlayComponent.vue

View check run for this annotation

Codecov / codecov/patch

src/api/overlays/components/OverlayComponent.vue#L99

Added line #L99 was not covered by tests
this.$emit('destroy');
},
getElementForFocus() {
Expand Down
13 changes: 13 additions & 0 deletions src/api/overlays/components/overlay-component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@
padding-right: $interiorMargin; // fend off scroll bar
}

&__footer {
margin-top: $interiorMargin;
display: flex;
justify-content: space-between;
width: 100%;
}

&__suppress-option {
justify-items: start;
align-self: center;
padding-left: $interiorMargin;
}

&__button-bar {
flex: 0 0 auto;
display: flex;
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/plot/MctPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,9 @@ export default {

showSynchronizeDialog() {
const isFixedTimespanMode = this.timeContext.isFixed();
if (!isFixedTimespanMode) {
const SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY = 'sync-time-conductor-modal-suppression';
let isSuppressed = localStorage.getItem(SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY);

Check warning on line 1805 in src/plugins/plot/MctPlot.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plot/MctPlot.vue#L1804-L1805

Added lines #L1804 - L1805 were not covered by tests
if (!isFixedTimespanMode && !isSuppressed) {
const message = `
This action will change the Time Conductor to Fixed Timespan mode with this plot view's current time bounds.
Do you want to continue?
Expand All @@ -1812,12 +1814,16 @@ export default {
iconClass: 'alert',
size: 'fit',
message: message,
showSuppressOption: true,
buttons: [
{
label: 'Ok',
callback: () => {
callback: (data) => {
dialog.dismiss();
this.synchronizeTimeConductor();
if (data && data.suppress) {
localStorage.setItem(SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY, true);

Check warning on line 1825 in src/plugins/plot/MctPlot.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plot/MctPlot.vue#L1825

Added line #L1825 was not covered by tests
}
}
},
{
Expand Down

0 comments on commit 609ec4b

Please sign in to comment.