Skip to content

Commit

Permalink
feat: gready render mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mathuo committed Dec 25, 2023
1 parent b17aa24 commit a2a4e68
Show file tree
Hide file tree
Showing 32 changed files with 1,066 additions and 236 deletions.
3 changes: 2 additions & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"/packages/docs/sandboxes/nativeapp-dockview",
"/packages/docs/sandboxes/nested-dockview",
"/packages/docs/sandboxes/rendering-dockview",
"/packages/docs/sandboxes/rendermode-dockview",
"/packages/docs/sandboxes/resize-dockview",
"/packages/docs/sandboxes/resizecontainer-dockview",
"/packages/docs/sandboxes/simple-dockview",
Expand All @@ -37,4 +38,4 @@
"/packages/docs/sandboxes/javascript/vanilla-dockview"
],
"node": "18"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('groupPanelApi', () => {
});

test('updateParameters', () => {
const groupPanel: Partial<IDockviewPanel> = {
const groupPanel: Partial<DockviewPanel> = {
id: 'test_id',
update: jest.fn(),
};
Expand All @@ -53,7 +53,7 @@ describe('groupPanelApi', () => {
);

const cut = new DockviewPanelApiImpl(
<IDockviewPanel>groupPanel,
<DockviewPanel>groupPanel,
<DockviewGroupPanel>groupViewPanel,
<DockviewComponent>accessor
);
Expand All @@ -67,7 +67,7 @@ describe('groupPanelApi', () => {
});

test('onDidGroupChange', () => {
const groupPanel: Partial<IDockviewPanel> = {
const groupPanel: Partial<DockviewPanel> = {
id: 'test_id',
};

Expand All @@ -83,7 +83,7 @@ describe('groupPanelApi', () => {
);

const cut = new DockviewPanelApiImpl(
<IDockviewPanel>groupPanel,
<DockviewPanel>groupPanel,
<DockviewGroupPanel>groupViewPanel,
<DockviewComponent>accessor
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CompositeDisposable } from '../../../../lifecycle';
import { PanelUpdateEvent } from '../../../../panel/types';
import { IDockviewPanel } from '../../../../dockview/dockviewPanel';
import { IDockviewPanelModel } from '../../../../dockview/dockviewPanelModel';
import { DockviewComponent } from '../../../../dockview/dockviewComponent';

class TestContentRenderer
extends CompositeDisposable
Expand Down Expand Up @@ -56,7 +57,14 @@ describe('contentContainer', () => {
let blur = 0;

const disposable = new CompositeDisposable();
const cut = new ContentContainer();

const dockviewComponent = jest.fn<DockviewComponent, []>(() => {
return {
renderer: 'destructive',
} as DockviewComponent;
});

const cut = new ContentContainer(dockviewComponent(), jest.fn() as any);

disposable.addDisposables(
cut.onDidFocus(() => {
Expand All @@ -73,6 +81,7 @@ describe('contentContainer', () => {
view: {
content: contentRenderer,
} as Partial<IDockviewPanelModel>,
api: { renderer: 'destructive' },
} as Partial<IDockviewPanel>;

cut.openPanel(panel as IDockviewPanel);
Expand Down Expand Up @@ -107,6 +116,7 @@ describe('contentContainer', () => {
view: {
content: contentRenderer2,
} as Partial<IDockviewPanelModel>,
api: { renderer: 'destructive' },
} as Partial<IDockviewPanel>;

cut.openPanel(panel2 as IDockviewPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,15 @@ describe('groupview', () => {
});

test('panel events are captured during de-serialization', () => {
const panel1 = new TestPanel('panel1', jest.fn() as any);
const panel2 = new TestPanel('panel2', jest.fn() as any);
const panel3 = new TestPanel('panel3', jest.fn() as any);
const panel1 = new TestPanel('panel1', {
renderer: 'destructive',
} as any);
const panel2 = new TestPanel('panel2', {
renderer: 'destructive',
} as any);
const panel3 = new TestPanel('panel3', {
renderer: 'destructive',
} as any);

const groupview2 = new DockviewGroupPanel(dockview, 'groupview-2', {
panels: [panel1, panel2, panel3],
Expand Down Expand Up @@ -343,9 +349,15 @@ describe('groupview', () => {
})
);

const panel1 = new TestPanel('panel1', jest.fn() as any);
const panel2 = new TestPanel('panel2', jest.fn() as any);
const panel3 = new TestPanel('panel3', jest.fn() as any);
const panel1 = new TestPanel('panel1', {
renderer: 'destructive',
} as any);
const panel2 = new TestPanel('panel2', {
renderer: 'destructive',
} as any);
const panel3 = new TestPanel('panel3', {
renderer: 'destructive',
} as any);

expect(events.length).toBe(0);

Expand Down Expand Up @@ -423,9 +435,15 @@ describe('groupview', () => {
});

test('moveToPrevious and moveToNext', () => {
const panel1 = new TestPanel('panel1', jest.fn() as any);
const panel2 = new TestPanel('panel2', jest.fn() as any);
const panel3 = new TestPanel('panel3', jest.fn() as any);
const panel1 = new TestPanel('panel1', {
renderer: 'destructive',
} as any);
const panel2 = new TestPanel('panel2', {
renderer: 'destructive',
} as any);
const panel3 = new TestPanel('panel3', {
renderer: 'destructive',
} as any);

groupview.model.openPanel(panel1);
groupview.model.openPanel(panel2);
Expand Down Expand Up @@ -469,9 +487,15 @@ describe('groupview', () => {
});

test('closeAllPanels with panels', () => {
const panel1 = new TestPanel('panel1', jest.fn() as any);
const panel2 = new TestPanel('panel2', jest.fn() as any);
const panel3 = new TestPanel('panel3', jest.fn() as any);
const panel1 = new TestPanel('panel1', {
renderer: 'destructive',
} as any);
const panel2 = new TestPanel('panel2', {
renderer: 'destructive',
} as any);
const panel3 = new TestPanel('panel3', {
renderer: 'destructive',
} as any);

groupview.model.openPanel(panel1);
groupview.model.openPanel(panel2);
Expand Down Expand Up @@ -576,19 +600,25 @@ describe('groupview', () => {
.getElementsByClassName('content-container')
.item(0)!.childNodes;

const panel1 = new TestPanel('id_1', null as any);
const panel1 = new TestPanel('id_1', {
renderer: 'destructive',
} as any);

cut.openPanel(panel1);
expect(contentContainer.length).toBe(1);
expect(contentContainer.item(0)).toBe(panel1.view.content.element);

const panel2 = new TestPanel('id_2', null as any);
const panel2 = new TestPanel('id_2', {
renderer: 'destructive',
} as any);

cut.openPanel(panel2);
expect(contentContainer.length).toBe(1);
expect(contentContainer.item(0)).toBe(panel2.view.content.element);

const panel3 = new TestPanel('id_2', null as any);
const panel3 = new TestPanel('id_2', {
renderer: 'destructive',
} as any);

cut.openPanel(panel3, { skipSetPanelActive: true });
expect(contentContainer.length).toBe(1);
Expand Down Expand Up @@ -790,7 +820,11 @@ describe('groupview', () => {
new groupPanelMock() as DockviewGroupPanel
);

cut.openPanel(new TestPanel('panel1', jest.fn() as any));
cut.openPanel(
new TestPanel('panel1', {
renderer: 'destructive',
} as any)
);

const element = container
.getElementsByClassName('content-container')
Expand Down Expand Up @@ -856,8 +890,16 @@ describe('groupview', () => {
new groupPanelMock() as DockviewGroupPanel
);

cut.openPanel(new TestPanel('panel1', jest.fn() as any));
cut.openPanel(new TestPanel('panel2', jest.fn() as any));
cut.openPanel(
new TestPanel('panel1', {
renderer: 'destructive',
} as any)
);
cut.openPanel(
new TestPanel('panel2', {
renderer: 'destructive',
} as any)
);

const element = container
.getElementsByClassName('content-container')
Expand Down Expand Up @@ -923,8 +965,16 @@ describe('groupview', () => {
new groupPanelMock() as DockviewGroupPanel
);

cut.openPanel(new TestPanel('panel1', jest.fn() as any));
cut.openPanel(new TestPanel('panel2', jest.fn() as any));
cut.openPanel(
new TestPanel('panel1', {
renderer: 'destructive',
} as any)
);
cut.openPanel(
new TestPanel('panel2', {
renderer: 'destructive',
} as any)
);

const element = container
.getElementsByClassName('content-container')
Expand Down Expand Up @@ -1025,7 +1075,11 @@ describe('groupview', () => {
container.getElementsByClassName('watermark-test-container').length
).toBe(1);

cut.openPanel(new TestPanel('panel1', jest.fn() as any));
cut.openPanel(
new TestPanel('panel1', {
renderer: 'destructive',
} as any)
);

expect(
container.getElementsByClassName('watermark-test-container').length
Expand All @@ -1035,7 +1089,11 @@ describe('groupview', () => {
.length
).toBe(1);

cut.openPanel(new TestPanel('panel2', jest.fn() as any));
cut.openPanel(
new TestPanel('panel2', {
renderer: 'destructive',
} as any)
);

expect(
container.getElementsByClassName('watermark-test-container').length
Expand All @@ -1053,7 +1111,11 @@ describe('groupview', () => {
container.getElementsByClassName('watermark-test-container').length
).toBe(1);

cut.openPanel(new TestPanel('panel1', jest.fn() as any));
cut.openPanel(
new TestPanel('panel1', {
renderer: 'destructive',
} as any)
);

expect(
container.getElementsByClassName('watermark-test-container').length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe('dockviewPanel', () => {
const group = new groupMock();
const model = <IDockviewPanelModel>new panelModelMock();

const cut = new DockviewPanel('fake-id', accessor, api, group, model);
const cut = new DockviewPanel('fake-id', accessor, api, group, model, {
renderer: 'destructive',
});

let latestTitle: string | undefined = undefined;

Expand Down Expand Up @@ -74,7 +76,9 @@ describe('dockviewPanel', () => {
const group = new groupMock();
const model = <IDockviewPanelModel>new panelModelMock();

const cut = new DockviewPanel('fake-id', accessor, api, group, model);
const cut = new DockviewPanel('fake-id', accessor, api, group, model, {
renderer: 'destructive',
});

cut.init({ title: 'myTitle', params: {} });
expect(cut.title).toBe('myTitle');
Expand Down Expand Up @@ -109,7 +113,9 @@ describe('dockviewPanel', () => {
const group = new groupMock();
const model = <IDockviewPanelModel>new panelModelMock();

const cut = new DockviewPanel('fake-id', accessor, api, group, model);
const cut = new DockviewPanel('fake-id', accessor, api, group, model, {
renderer: 'destructive',
});

cut.init({ params: {}, title: 'title' });

Expand Down Expand Up @@ -141,7 +147,9 @@ describe('dockviewPanel', () => {
const group = new groupMock();
const model = <IDockviewPanelModel>new panelModelMock();

const cut = new DockviewPanel('fake-id', accessor, api, group, model);
const cut = new DockviewPanel('fake-id', accessor, api, group, model, {
renderer: 'destructive',
});

expect(cut.params).toEqual(undefined);

Expand Down Expand Up @@ -177,7 +185,9 @@ describe('dockviewPanel', () => {
const group = new groupMock();
const model = <IDockviewPanelModel>new panelModelMock();

const cut = new DockviewPanel('fake-id', accessor, api, group, model);
const cut = new DockviewPanel('fake-id', accessor, api, group, model, {
renderer: 'destructive',
});

cut.api.setSize({ height: 123, width: 456 });

Expand Down Expand Up @@ -208,7 +218,9 @@ describe('dockviewPanel', () => {
const group = new groupMock();
const model = <IDockviewPanelModel>new panelModelMock();

const cut = new DockviewPanel('fake-id', accessor, api, group, model);
const cut = new DockviewPanel('fake-id', accessor, api, group, model, {
renderer: 'destructive',
});

cut.init({ params: { a: '1', b: '2' }, title: 'A title' });
expect(cut.params).toEqual({ a: '1', b: '2' });
Expand Down
Loading

0 comments on commit a2a4e68

Please sign in to comment.