mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 13:48:12 +00:00
Button to clear the recent objects list (#6327)
This commit is contained in:
@ -191,7 +191,7 @@ test.describe('Recent Objects', () => {
|
|||||||
expect(await clockBreadcrumbs.count()).toBe(2);
|
expect(await clockBreadcrumbs.count()).toBe(2);
|
||||||
expect(await clockBreadcrumbs.nth(0).innerText()).not.toEqual(await clockBreadcrumbs.nth(1).innerText());
|
expect(await clockBreadcrumbs.nth(0).innerText()).not.toEqual(await clockBreadcrumbs.nth(1).innerText());
|
||||||
});
|
});
|
||||||
test("Enforces a limit of 20 recent objects", async ({ page }) => {
|
test("Enforces a limit of 20 recent objects and clears the recent objects", async ({ page }) => {
|
||||||
// Creating 21 objects takes a while, so increase the timeout
|
// Creating 21 objects takes a while, so increase the timeout
|
||||||
test.slow();
|
test.slow();
|
||||||
|
|
||||||
@ -242,6 +242,15 @@ test.describe('Recent Objects', () => {
|
|||||||
|
|
||||||
// Assert that the Clock treeitem is no longer highlighted
|
// Assert that the Clock treeitem is no longer highlighted
|
||||||
await expect(lastClockTreeItem.locator('.c-tree__item')).not.toHaveClass(/is-targeted-item/);
|
await expect(lastClockTreeItem.locator('.c-tree__item')).not.toHaveClass(/is-targeted-item/);
|
||||||
|
|
||||||
|
// Click the aria-label="Clear Recently Viewed" button
|
||||||
|
await page.getByRole('button', { name: 'Clear Recently Viewed' }).click();
|
||||||
|
|
||||||
|
// Click on the "OK" button in the confirmation dialog
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
|
||||||
|
// Assert that the list is empty
|
||||||
|
expect(await recentObjectsList.locator('.c-recentobjects-listitem').count()).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
function assertInitialRecentObjectsListState() {
|
function assertInitialRecentObjectsListState() {
|
||||||
|
@ -93,9 +93,18 @@
|
|||||||
:persist-position="true"
|
:persist-position="true"
|
||||||
>
|
>
|
||||||
<RecentObjectsList
|
<RecentObjectsList
|
||||||
|
ref="recentObjectsList"
|
||||||
class="l-shell__tree"
|
class="l-shell__tree"
|
||||||
@openAndScrollTo="openAndScrollTo($event)"
|
@openAndScrollTo="openAndScrollTo($event)"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
slot="controls"
|
||||||
|
class="c-icon-button icon-clear-data"
|
||||||
|
aria-label="Clear Recently Viewed"
|
||||||
|
title="Clear Recently Viewed"
|
||||||
|
@click="handleClearRecentObjects"
|
||||||
|
>
|
||||||
|
</button>
|
||||||
</pane>
|
</pane>
|
||||||
</multipane>
|
</multipane>
|
||||||
</pane>
|
</pane>
|
||||||
@ -279,6 +288,9 @@ export default {
|
|||||||
handleTreeReset() {
|
handleTreeReset() {
|
||||||
this.triggerReset = !this.triggerReset;
|
this.triggerReset = !this.triggerReset;
|
||||||
},
|
},
|
||||||
|
handleClearRecentObjects() {
|
||||||
|
this.$refs.recentObjectsList.clearRecentObjects();
|
||||||
|
},
|
||||||
onStartResizing() {
|
onStartResizing() {
|
||||||
this.isResizing = true;
|
this.isResizing = true;
|
||||||
},
|
},
|
||||||
|
@ -191,6 +191,33 @@ export default {
|
|||||||
shouldTrackCompositionFor(domainObject, navigationPath) {
|
shouldTrackCompositionFor(domainObject, navigationPath) {
|
||||||
return this.compositionCollections[navigationPath] === undefined
|
return this.compositionCollections[navigationPath] === undefined
|
||||||
&& this.openmct.composition.supportsComposition(domainObject);
|
&& this.openmct.composition.supportsComposition(domainObject);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Clears the Recent Objects list in localStorage and in the component.
|
||||||
|
* Before clearing, prompts the user to confirm the action with a dialog.
|
||||||
|
*/
|
||||||
|
clearRecentObjects() {
|
||||||
|
const dialog = this.openmct.overlays.dialog({
|
||||||
|
title: 'Clear Recently Viewed Objects',
|
||||||
|
iconClass: 'alert',
|
||||||
|
message: 'This action will clear the Recently Viewed Objects list. Are you sure you want to continue?',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
label: 'OK',
|
||||||
|
callback: () => {
|
||||||
|
localStorage.removeItem(LOCAL_STORAGE_KEY__RECENT_OBJECTS);
|
||||||
|
this.recents = [];
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Cancel',
|
||||||
|
callback: () => {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user