mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
[My Items] Make folder name customizable (#4627)
* making my items folder name customizable Co-authored-by: Nikhil <nikhil.k.mandlik@nasa.gov> Co-authored-by: John Hill <john.c.hill@nasa.gov>
This commit is contained in:
parent
6a8f4b5d9c
commit
23ead2ceaa
@ -22,14 +22,14 @@
|
||||
|
||||
import { MY_ITEMS_KEY } from "./createMyItemsIdentifier";
|
||||
|
||||
function myItemsInterceptor(identifierObject, openmct) {
|
||||
function myItemsInterceptor(openmct, identifierObject, name) {
|
||||
|
||||
const myItemsModel = {
|
||||
identifier: identifierObject,
|
||||
"name": "My Items",
|
||||
"type": "folder",
|
||||
"composition": [],
|
||||
"location": "ROOT"
|
||||
name,
|
||||
type: "folder",
|
||||
composition: [],
|
||||
location: "ROOT"
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -23,11 +23,13 @@
|
||||
import { createMyItemsIdentifier } from "./createMyItemsIdentifier";
|
||||
import myItemsInterceptor from "./myItemsInterceptor";
|
||||
|
||||
export default function MyItemsPlugin(namespace = '') {
|
||||
const MY_ITEMS_DEFAULT_NAME = 'My Items';
|
||||
|
||||
export default function MyItemsPlugin(name = MY_ITEMS_DEFAULT_NAME, namespace = '') {
|
||||
return function install(openmct) {
|
||||
const identifier = createMyItemsIdentifier(namespace);
|
||||
|
||||
openmct.objects.addGetInterceptor(myItemsInterceptor(identifier, openmct));
|
||||
openmct.objects.addGetInterceptor(myItemsInterceptor(openmct, identifier, name));
|
||||
openmct.objects.addRoot(identifier);
|
||||
};
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ import {
|
||||
} from './createMyItemsIdentifier';
|
||||
|
||||
const MISSING_NAME = `Missing: ${MY_ITEMS_KEY}`;
|
||||
const DEFAULT_NAME = 'My Items';
|
||||
const FANCY_NAME = 'Fancy Items';
|
||||
const myItemsIdentifier = createMyItemsIdentifier();
|
||||
|
||||
describe("the plugin", () => {
|
||||
@ -40,9 +42,10 @@ describe("the plugin", () => {
|
||||
name: MISSING_NAME
|
||||
};
|
||||
|
||||
describe('with no arguments passed in', () => {
|
||||
|
||||
beforeEach((done) => {
|
||||
openmct = createOpenMct();
|
||||
|
||||
openmct.install(openmct.plugins.MyItems());
|
||||
|
||||
openmct.on('start', done);
|
||||
@ -61,6 +64,7 @@ describe("the plugin", () => {
|
||||
return openmct.objects.areIdsEqual(domainObject.identifier, myItemsIdentifier);
|
||||
})[0];
|
||||
|
||||
expect(myItems.name).toBe(DEFAULT_NAME);
|
||||
expect(myItems).toBeDefined();
|
||||
});
|
||||
|
||||
@ -89,4 +93,31 @@ describe("the plugin", () => {
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('with a name argument passed in', () => {
|
||||
|
||||
beforeEach((done) => {
|
||||
openmct = createOpenMct();
|
||||
openmct.install(openmct.plugins.MyItems(FANCY_NAME));
|
||||
|
||||
spyOn(openmct.objects, 'isMissing').and.returnValue(true);
|
||||
|
||||
openmct.on('start', done);
|
||||
openmct.startHeadless();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
return resetApplicationState(openmct);
|
||||
});
|
||||
|
||||
it('when installed, uses the passed in name', async () => {
|
||||
let myItems = await openmct.objects.get(myItemsIdentifier);
|
||||
|
||||
expect(myItems.name).toBe(FANCY_NAME);
|
||||
expect(myItems).toBeDefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user