mirror of
https://github.com/nasa/openmct.git
synced 2025-06-22 17:08:57 +00:00
For an existing View in a Preview, ensure we pull the same ActionCollection
(#7632)
* ensure action collection returned is the cached one from the same view * add test * use async await
This commit is contained in:
@ -69,5 +69,9 @@ test.describe('Preview mode', () => {
|
|||||||
await page.getByLabel('Overlay').getByLabel('More actions').click();
|
await page.getByLabel('Overlay').getByLabel('More actions').click();
|
||||||
await expect(page.getByLabel('Export Table Data')).toBeVisible();
|
await expect(page.getByLabel('Export Table Data')).toBeVisible();
|
||||||
await expect(page.getByLabel('Export Marked Rows')).toBeVisible();
|
await expect(page.getByLabel('Export Marked Rows')).toBeVisible();
|
||||||
|
await expect(page.getByLabel('Export Marked Rows')).toBeDisabled();
|
||||||
|
await page.getByLabel('Pause').click();
|
||||||
|
const tableWrapper = page.getByLabel('Preview Container').locator('div.c-table-wrapper');
|
||||||
|
await expect(tableWrapper).toHaveClass(/is-paused/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,8 +23,7 @@
|
|||||||
<div role="dialog" aria-label="Preview Container" class="l-preview-window js-preview-window">
|
<div role="dialog" aria-label="Preview Container" class="l-preview-window js-preview-window">
|
||||||
<PreviewHeader
|
<PreviewHeader
|
||||||
ref="previewHeader"
|
ref="previewHeader"
|
||||||
:current-view="currentViewProvider"
|
:current-view="view"
|
||||||
:action-collection="actionCollection"
|
|
||||||
:domain-object="domainObject"
|
:domain-object="domainObject"
|
||||||
:views="viewProviders"
|
:views="viewProviders"
|
||||||
/>
|
/>
|
||||||
@ -35,8 +34,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { nextTick } from 'vue';
|
|
||||||
|
|
||||||
import StyleRuleManager from '@/plugins/condition/StyleRuleManager';
|
import StyleRuleManager from '@/plugins/condition/StyleRuleManager';
|
||||||
import { STYLE_CONSTANTS } from '@/plugins/condition/utils/constants';
|
import { STYLE_CONSTANTS } from '@/plugins/condition/utils/constants';
|
||||||
|
|
||||||
@ -66,10 +63,10 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
domainObject: domainObject,
|
domainObject: domainObject,
|
||||||
viewKey: undefined,
|
viewKey: null,
|
||||||
|
view: null,
|
||||||
viewProviders: [],
|
viewProviders: [],
|
||||||
currentViewProvider: {},
|
currentViewProvider: {},
|
||||||
actionCollection: undefined,
|
|
||||||
existingViewIndex: 0
|
existingViewIndex: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -96,10 +93,6 @@ export default {
|
|||||||
this.styleRuleManager.destroy();
|
this.styleRuleManager.destroy();
|
||||||
delete this.styleRuleManager;
|
delete this.styleRuleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.actionCollection) {
|
|
||||||
this.actionCollection.destroy();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
if (!this.existingView) {
|
if (!this.existingView) {
|
||||||
@ -157,10 +150,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.initObjectStyles();
|
this.initObjectStyles();
|
||||||
|
|
||||||
nextTick(() => {
|
|
||||||
this.getActionsCollection(this.view);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
addExistingViewBackToParent() {
|
addExistingViewBackToParent() {
|
||||||
this.existingView.parentElement.appendChild(this.existingViewElement);
|
this.existingView.parentElement.appendChild(this.existingViewElement);
|
||||||
@ -169,13 +158,6 @@ export default {
|
|||||||
initializeViewContainer() {
|
initializeViewContainer() {
|
||||||
this.viewContainer = this.$refs.objectView;
|
this.viewContainer = this.$refs.objectView;
|
||||||
},
|
},
|
||||||
getActionsCollection(view) {
|
|
||||||
if (this.actionCollection) {
|
|
||||||
this.actionCollection.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.actionCollection = this.openmct.actions.getActionsCollection(this.objectPath, view);
|
|
||||||
},
|
|
||||||
initObjectStyles() {
|
initObjectStyles() {
|
||||||
if (!this.styleRuleManager) {
|
if (!this.styleRuleManager) {
|
||||||
this.styleRuleManager = new StyleRuleManager(
|
this.styleRuleManager = new StyleRuleManager(
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { nextTick, toRaw } from 'vue';
|
||||||
|
|
||||||
import NotebookMenuSwitcher from '@/plugins/notebook/components/NotebookMenuSwitcher.vue';
|
import NotebookMenuSwitcher from '@/plugins/notebook/components/NotebookMenuSwitcher.vue';
|
||||||
|
|
||||||
import ViewSwitcher from '../layout/ViewSwitcher.vue';
|
import ViewSwitcher from '../layout/ViewSwitcher.vue';
|
||||||
@ -94,12 +96,6 @@ export default {
|
|||||||
default: () => {
|
default: () => {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
|
||||||
actionCollection: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['set-view'],
|
emits: ['set-view'],
|
||||||
@ -111,17 +107,18 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
actionCollection(actionCollection) {
|
async currentView() {
|
||||||
|
// wait for view to render with next tick
|
||||||
|
await nextTick();
|
||||||
if (this.actionCollection) {
|
if (this.actionCollection) {
|
||||||
this.unlistenToActionCollection();
|
this.unlistenToActionCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.actionCollection.on('update', this.updateActionItems);
|
this.actionCollection = this.openmct.actions.getActionsCollection(
|
||||||
this.updateActionItems(this.actionCollection.getActionsObject());
|
toRaw(this.objectPath),
|
||||||
}
|
toRaw(this.currentView)
|
||||||
},
|
);
|
||||||
mounted() {
|
|
||||||
if (this.actionCollection) {
|
|
||||||
this.actionCollection.on('update', this.updateActionItems);
|
this.actionCollection.on('update', this.updateActionItems);
|
||||||
this.updateActionItems(this.actionCollection.getActionsObject());
|
this.updateActionItems(this.actionCollection.getActionsObject());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user