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

[MctPlot, Overlay] add suppression option to overlay dialog #7989

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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
44 changes: 28 additions & 16 deletions src/api/overlays/components/OverlayComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,27 @@
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 v-model="suppress" type="checkbox" class="l-composite-control l-checkbox" />
<label>{{ suppressionText }}</label>
</div>
</div>
<div v-if="buttons" class="c-overlay__button-bar">
<button
v-for="(button, index) in buttons"
Copy link
Contributor

Choose a reason for hiding this comment

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

buttonIndex to make the section explicit and readable

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>
</div>
</div>
</div>
Expand All @@ -56,11 +64,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 +87,10 @@
}
},
buttonClickHandler(method) {
method();
let callbackData = {

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

View check run for this annotation

Codecov / codecov/patch

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

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L93 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 @@ -1795,7 +1795,9 @@

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 1799 in src/plugins/plot/MctPlot.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plot/MctPlot.vue#L1798-L1799

Added lines #L1798 - L1799 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 @@ -1806,12 +1808,16 @@
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 1819 in src/plugins/plot/MctPlot.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plot/MctPlot.vue#L1819

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