Skip to content

Commit

Permalink
Merge pull request #68 from mathuo/51-expose-params-item-on-panel-int…
Browse files Browse the repository at this point in the history
…erfaces

chore: fix demo
  • Loading branch information
mathuo authored Apr 23, 2022
2 parents 7071cf7 + 3c7781d commit a2c269d
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/dockview-demo/src/layout-grid/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const Application = () => {
});
}

event.api.onGridEvent(() => {
event.api.onDidLayoutChange(() => {
localStorage.setItem(
'dockview-layout',
JSON.stringify(event.api.toJSON())
Expand Down
8 changes: 2 additions & 6 deletions packages/dockview-demo/src/layout-grid/layoutGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {
IDockviewPanelProps,
GroupChangeKind,
IGridviewPanelProps,
TabContextMenuEvent,
DockviewReadyEvent,
Expand Down Expand Up @@ -161,11 +160,8 @@ export const TestGrid = (props: IGridviewPanelProps) => {
const state = api.toJSON();
localStorage.setItem('dockview', JSON.stringify(state));
}),
api.onGridEvent((e) => {
console.log(e);
if (e.kind === GroupChangeKind.PANEL_ACTIVE) {
setSelectedPanel(e.panel?.id || '');
}
api.onDidActivePanelChange((e) => {
setSelectedPanel(e?.id || '');
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const components: PanelCollection<IDockviewPanelProps> = {
};

export const Iframe = (props: {
onEvent: (name: string) => void;
theme: string;
hideBorders: boolean;
disableAutoResizing: boolean;
Expand All @@ -61,8 +60,6 @@ export const Iframe = (props: {
const onReady = (event: DockviewReadyEvent) => {
api.current = event.api;

event.api.onGridEvent((e) => props.onEvent(e.kind));

event.api.addPanel({
id: 'panel1',
title: 'Standard Panel',
Expand Down Expand Up @@ -107,6 +104,5 @@ export default {
options: ['dockview-theme-dark', 'dockview-theme-light'],
},
},
onEvent: { action: 'onEvent' },
},
} as Meta;
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const components: PanelCollection<IDockviewPanelProps<any>> = {
};

export const Params = (props: {
onEvent: (name: string) => void;
theme: string;
hideBorders: boolean;
disableAutoResizing: boolean;
Expand Down Expand Up @@ -93,8 +92,6 @@ export const Params = (props: {
const onReady = (event: DockviewReadyEvent) => {
api.current = event.api;

event.api.onGridEvent((e) => props.onEvent(e.kind));

event.api.addPanel({
id: 'panel1',
component: 'ticker',
Expand Down Expand Up @@ -152,6 +149,5 @@ export default {
options: ['dockview-theme-dark', 'dockview-theme-light'],
},
},
onEvent: { action: 'onEvent' },
},
} as Meta;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const components: PanelCollection<IDockviewPanelProps> = {
};

export const Simple = (props: {
onEvent: (name: string) => void;
theme: string;
hideBorders: boolean;
disableAutoResizing: boolean;
Expand All @@ -36,8 +35,6 @@ export const Simple = (props: {
const onReady = (event: DockviewReadyEvent) => {
api.current = event.api;

event.api.onGridEvent((e) => props.onEvent(e.kind));

event.api.addPanel({
id: 'panel1',
component: 'default',
Expand Down Expand Up @@ -92,6 +89,5 @@ export default {
options: ['dockview-theme-dark', 'dockview-theme-light'],
},
},
onEvent: { action: 'onEvent' },
},
} as Meta;
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const components: PanelCollection<IDockviewPanelProps> = {
};

export const Tab = (props: {
onEvent: (name: string) => void;
theme: string;
hideBorders: boolean;
disableAutoResizing: boolean;
Expand All @@ -57,8 +56,6 @@ export const Tab = (props: {
const onReady = (event: DockviewReadyEvent) => {
api.current = event.api;

event.api.onGridEvent((e) => props.onEvent(e.kind));

event.api.addPanel({
id: 'panel1',
component: 'default',
Expand Down Expand Up @@ -113,6 +110,5 @@ export default {
options: ['dockview-theme-dark', 'dockview-theme-light'],
},
},
onEvent: { action: 'onEvent' },
},
} as Meta;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
DockviewApi,
DockviewReact,
DockviewReadyEvent,
GroupChangeKind,
IDockviewPanelProps,
IWatermarkPanelProps,
PanelCollection,
Expand Down Expand Up @@ -36,16 +35,17 @@ const WatermarkPanel = (props: IWatermarkPanelProps) => {

React.useEffect(() => {
const disposables = new CompositeDisposable(
props.containerApi.onGridEvent((event) => {
switch (event.kind) {
case GroupChangeKind.ADD_GROUP:
case GroupChangeKind.REMOVE_GROUP:
case GroupChangeKind.ADD_PANEL:
case GroupChangeKind.REMOVE_PANEL:
setSize(props.containerApi.size);
setPanels(props.containerApi.totalPanels);
break;
}
props.containerApi.onDidAddGroup((event) => {
setSize(props.containerApi.size);
}),
props.containerApi.onDidRemoveGroup((event) => {
setSize(props.containerApi.size);
}),
props.containerApi.onDidAddPanel((event) => {
setPanels(props.containerApi.totalPanels);
}),
props.containerApi.onDidRemovePanel((event) => {
setPanels(props.containerApi.totalPanels);
})
);

Expand Down Expand Up @@ -96,7 +96,6 @@ const WatermarkPanel = (props: IWatermarkPanelProps) => {
};

export const Watermark = (props: {
onEvent: (name: string) => void;
theme: string;
hideBorders: boolean;
disableAutoResizing: boolean;
Expand All @@ -106,8 +105,6 @@ export const Watermark = (props: {
const onReady = (event: DockviewReadyEvent) => {
api.current = event.api;

event.api.onGridEvent((e) => props.onEvent(e.kind));

event.api.addEmptyGroup();
};

Expand Down Expand Up @@ -144,6 +141,5 @@ export default {
options: ['dockview-theme-dark', 'dockview-theme-light'],
},
},
onEvent: { action: 'onEvent' },
},
} as Meta;
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const components: PanelCollection<IGridviewPanelProps<any>> = {
};

export const Params = (props: {
onEvent: (name: string) => void;
theme: string;
hideBorders: boolean;
disableAutoResizing: boolean;
Expand Down Expand Up @@ -54,8 +53,6 @@ export const Params = (props: {
const onReady = (event: GridviewReadyEvent) => {
api.current = event.api;

event.api.onGridEvent((e) => props.onEvent(e.kind));

event.api.addPanel({
id: 'panel1',
component: 'ticker',
Expand Down Expand Up @@ -106,6 +103,5 @@ export default {
options: ['dockview-theme-dark', 'dockview-theme-light'],
},
},
onEvent: { action: 'onEvent' },
},
} as Meta;
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const components: PanelCollection<ISplitviewPanelProps<any>> = {
};

export const Params = (props: {
onEvent: (name: string) => void;
theme: string;
hideBorders: boolean;
disableAutoResizing: boolean;
Expand Down Expand Up @@ -104,6 +103,5 @@ export default {
options: ['dockview-theme-dark', 'dockview-theme-light'],
},
},
onEvent: { action: 'onEvent' },
},
} as Meta;

0 comments on commit a2c269d

Please sign in to comment.