mirror of
https://github.com/mathuo/dockview
synced 2025-05-03 10:08:24 +00:00
feat: error in duplicate id
This commit is contained in:
parent
9c75701182
commit
2f8abd0e11
@ -167,6 +167,22 @@ describe('dockviewComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('duplicate panel', () => {
|
||||||
|
dockview.layout(500, 1000);
|
||||||
|
|
||||||
|
dockview.addPanel({
|
||||||
|
id: 'panel1',
|
||||||
|
component: 'default',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
dockview.addPanel({
|
||||||
|
id: 'panel1',
|
||||||
|
component: 'default',
|
||||||
|
});
|
||||||
|
}).toThrowError('panel with id panel1 already exists');
|
||||||
|
});
|
||||||
|
|
||||||
test('set active panel', () => {
|
test('set active panel', () => {
|
||||||
dockview.layout(500, 1000);
|
dockview.layout(500, 1000);
|
||||||
|
|
||||||
|
@ -407,7 +407,11 @@ export class DockviewComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPanel(options: AddPanelOptions): IGroupPanel {
|
addPanel(options: AddPanelOptions): IGroupPanel {
|
||||||
const panel = this._addPanel(options);
|
if (this.panels.find((_) => _.id === options.id)) {
|
||||||
|
throw new Error(`panel with id ${options.id} already exists`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const panel = this.createPanel(options);
|
||||||
|
|
||||||
let referenceGroup: GroupviewPanel | undefined;
|
let referenceGroup: GroupviewPanel | undefined;
|
||||||
|
|
||||||
@ -693,7 +697,7 @@ export class DockviewComponent
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _addPanel(options: AddPanelOptions): IGroupPanel {
|
private createPanel(options: AddPanelOptions): IGroupPanel {
|
||||||
const view = new DefaultGroupPanelView({
|
const view = new DefaultGroupPanelView({
|
||||||
content: this.createContentComponent(options.id, options.component),
|
content: this.createContentComponent(options.id, options.component),
|
||||||
tab: this.createTabComponent(options.id, options.tabComponent),
|
tab: this.createTabComponent(options.id, options.tabComponent),
|
||||||
|
Loading…
Reference in New Issue
Block a user