Skip to content

Commit 609ec4b

Browse files
committed
[Overlay] add suppression option to overlay dialog
1 parent 1fde0d9 commit 609ec4b

File tree

5 files changed

+111
-18
lines changed

5 files changed

+111
-18
lines changed

e2e/tests/functional/plugins/plot/plotRendering.e2e.spec.js

+52
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,58 @@ test.describe('Plot Rendering', () => {
8484
await expect(page.getByLabel('Time Conductor Mode')).toHaveText('Fixed Timespan');
8585
});
8686

87+
test('Time conductor synchronization confirmation dialog can be suppressed', async ({ page }) => {
88+
// Navigate to Sine Wave Generator
89+
await page.goto(sineWaveGeneratorObject.url);
90+
// Switch to real-time mode
91+
await setRealTimeMode(page);
92+
93+
// hover over plot for plot controls
94+
await page.getByLabel('Plot Canvas').hover();
95+
// click on pause control
96+
await page.getByTitle('Pause incoming real-time data').click();
97+
98+
// expect plot to be paused
99+
await expect(page.getByTitle('Resume displaying real-time data')).toBeVisible();
100+
101+
// hover over plot for plot controls
102+
await page.getByLabel('Plot Canvas').hover();
103+
104+
// click on synchronize with time conductor
105+
await page.getByTitle('Synchronize Time Conductor').click();
106+
107+
await expect(page.locator('.c-message__action-text')).toContainText(
108+
'This action will change the Time Conductor to Fixed Timespan mode'
109+
);
110+
111+
await page.getByLabel('Checkbox to Suppress Dialog').click();
112+
113+
await page.getByRole('button', { name: 'Ok', exact: true }).click();
114+
115+
//confirm that you're now in fixed mode with the correct range
116+
await expect(page.getByLabel('Time Conductor Mode')).toHaveText('Fixed Timespan');
117+
118+
await page.getByLabel('Zoom in').click();
119+
120+
await page.getByTitle('Synchronize Time Conductor').click();
121+
122+
await expect(page.locator('.c-message-banner__message')).toHaveText(
123+
'Time conductor bounds have changed.'
124+
);
125+
126+
await expect(page.locator('.c-message__action-text')).toBeHidden();
127+
128+
const suppressionVal = await page.evaluate(() =>
129+
window.localStorage.getItem('sync-time-conductor-modal-suppression')
130+
);
131+
132+
await expect(suppressionVal).toBe('true');
133+
134+
await page.evaluate(() =>
135+
window.localStorage.removeItem('sync-time-conductor-modal-suppression')
136+
);
137+
});
138+
87139
test('Plot is rendered when infinity values exist', async ({ page }) => {
88140
// Edit Plot
89141
await editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject);

src/api/overlays/Overlay.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Overlay extends EventEmitter {
1919
element,
2020
onDestroy,
2121
onDismiss,
22+
showSuppressOption = false,
23+
suppressionText = "Don't ask again",
2224
size
2325
} = {}) {
2426
super();
@@ -38,6 +40,8 @@ class Overlay extends EventEmitter {
3840
dismiss: this.notifyAndDismiss.bind(this),
3941
element,
4042
buttons,
43+
showSuppressOption,
44+
suppressionText,
4145
dismissible: this.dismissible
4246
},
4347
template: '<overlay-component></overlay-component>'

src/api/overlays/components/OverlayComponent.vue

+34-16
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,33 @@
3535
class="c-overlay__contents js-notebook-snapshot-item-wrapper"
3636
tabindex="0"
3737
></div>
38-
<div v-if="buttons" class="c-overlay__button-bar">
39-
<button
40-
v-for="(button, index) in buttons"
41-
ref="buttons"
42-
:key="index"
43-
class="c-button js-overlay__button"
44-
tabindex="0"
45-
:class="{ 'c-button--major': focusIndex === index }"
46-
@focus="focusIndex = index"
47-
@click="buttonClickHandler(button.callback)"
48-
>
49-
{{ button.label }}
50-
</button>
38+
<div v-if="buttons || showSuppressOption" class="c-overlay__footer">
39+
<div class="c-overlay__suppress-option">
40+
<div v-if="showSuppressOption">
41+
<input
42+
id="suppressCheckbox"
43+
v-model="suppress"
44+
type="checkbox"
45+
class="l-composite-control l-checkbox"
46+
aria-label="Checkbox to Suppress Dialog"
47+
/>
48+
<label for="suppressCheckbox">{{ suppressionText }}</label>
49+
</div>
50+
</div>
51+
<div v-if="buttons" class="c-overlay__button-bar">
52+
<button
53+
v-for="(button, buttonIndex) in buttons"
54+
ref="buttons"
55+
:key="buttonIndex"
56+
class="c-button js-overlay__button"
57+
tabindex="0"
58+
:class="{ 'c-button--major': focusIndex === buttonIndex }"
59+
@focus="focusIndex = buttonIndex"
60+
@click="buttonClickHandler(button.callback)"
61+
>
62+
{{ button.label }}
63+
</button>
64+
</div>
5165
</div>
5266
</div>
5367
</div>
@@ -56,11 +70,12 @@
5670

5771
<script>
5872
export default {
59-
inject: ['dismiss', 'element', 'buttons', 'dismissible'],
73+
inject: ['dismiss', 'element', 'buttons', 'dismissible', 'showSuppressOption', 'suppressionText'],
6074
emits: ['destroy'],
6175
data() {
6276
return {
63-
focusIndex: -1
77+
focusIndex: -1,
78+
suppress: false
6479
};
6580
},
6681
mounted() {
@@ -78,7 +93,10 @@ export default {
7893
}
7994
},
8095
buttonClickHandler(method) {
81-
method();
96+
let callbackData = {
97+
suppress: this.suppress
98+
};
99+
method(callbackData);
82100
this.$emit('destroy');
83101
},
84102
getElementForFocus() {

src/api/overlays/components/overlay-component.scss

+13
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@
101101
padding-right: $interiorMargin; // fend off scroll bar
102102
}
103103

104+
&__footer {
105+
margin-top: $interiorMargin;
106+
display: flex;
107+
justify-content: space-between;
108+
width: 100%;
109+
}
110+
111+
&__suppress-option {
112+
justify-items: start;
113+
align-self: center;
114+
padding-left: $interiorMargin;
115+
}
116+
104117
&__button-bar {
105118
flex: 0 0 auto;
106119
display: flex;

src/plugins/plot/MctPlot.vue

+8-2
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,9 @@ export default {
18011801

18021802
showSynchronizeDialog() {
18031803
const isFixedTimespanMode = this.timeContext.isFixed();
1804-
if (!isFixedTimespanMode) {
1804+
const SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY = 'sync-time-conductor-modal-suppression';
1805+
let isSuppressed = localStorage.getItem(SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY);
1806+
if (!isFixedTimespanMode && !isSuppressed) {
18051807
const message = `
18061808
This action will change the Time Conductor to Fixed Timespan mode with this plot view's current time bounds.
18071809
Do you want to continue?
@@ -1812,12 +1814,16 @@ export default {
18121814
iconClass: 'alert',
18131815
size: 'fit',
18141816
message: message,
1817+
showSuppressOption: true,
18151818
buttons: [
18161819
{
18171820
label: 'Ok',
1818-
callback: () => {
1821+
callback: (data) => {
18191822
dialog.dismiss();
18201823
this.synchronizeTimeConductor();
1824+
if (data && data.suppress) {
1825+
localStorage.setItem(SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY, true);
1826+
}
18211827
}
18221828
},
18231829
{

0 commit comments

Comments
 (0)