chore: adjust public method names

This commit is contained in:
mathuo 2025-06-13 22:56:29 +01:00
parent b76e41bd92
commit 87c2fd517d
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
5 changed files with 17 additions and 15 deletions

View File

@ -5823,9 +5823,9 @@ describe('dockviewComponent', () => {
}); });
}); });
test('onDidBlockPopout event is emitted', async () => { test('onDidOpenPoputWindowFail event is emitted', async () => {
const onDidBlockPopoutHandler = jest.fn(); const onDidBlockPopoutHandler = jest.fn();
dockview.onDidBlockPopout(onDidBlockPopoutHandler); dockview.onDidOpenPopoutWindowFail(onDidBlockPopoutHandler);
await dockview.addPopoutGroup(panel.group); await dockview.addPopoutGroup(panel.group);

View File

@ -749,8 +749,8 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
return this.component.onDidPopoutGroupPositionChange; return this.component.onDidPopoutGroupPositionChange;
} }
get onDidBlockPopout(): Event<void> { get onDidOpenPopoutWindowFail(): Event<void> {
return this.component.onDidBlockPopout; return this.component.onDidOpenPopoutWindowFail;
} }
/** /**

View File

@ -251,9 +251,6 @@ export class Tabs extends CompositeDisposable {
delete(id: string): void { delete(id: string): void {
const index = this.indexOf(id); const index = this.indexOf(id);
const tabToRemove = this._tabs.splice(index, 1)[0]; const tabToRemove = this._tabs.splice(index, 1)[0];
if (!tabToRemove) {
return;
}
const { value, disposable } = tabToRemove; const { value, disposable } = tabToRemove;

View File

@ -226,7 +226,7 @@ export interface IDockviewComponent extends IBaseGrid<DockviewGroupPanel> {
readonly onDidMaximizedGroupChange: Event<DockviewMaximizedGroupChanged>; readonly onDidMaximizedGroupChange: Event<DockviewMaximizedGroupChanged>;
readonly onDidPopoutGroupSizeChange: Event<PopoutGroupChangeSizeEvent>; readonly onDidPopoutGroupSizeChange: Event<PopoutGroupChangeSizeEvent>;
readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent>; readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent>;
readonly onDidBlockPopout: Event<void>; readonly onDidOpenPopoutWindowFail: Event<void>;
readonly options: DockviewComponentOptions; readonly options: DockviewComponentOptions;
updateOptions(options: DockviewOptions): void; updateOptions(options: DockviewOptions): void;
moveGroupOrPanel(options: MoveGroupOrPanelOptions): void; moveGroupOrPanel(options: MoveGroupOrPanelOptions): void;
@ -320,8 +320,9 @@ export class DockviewComponent
readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent> = readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent> =
this._onDidPopoutGroupPositionChange.event; this._onDidPopoutGroupPositionChange.event;
private readonly _onDidBlockPopout = new Emitter<void>(); private readonly _onDidOpenPopoutWindowFail = new Emitter<void>();
readonly onDidBlockPopout: Event<void> = this._onDidBlockPopout.event; readonly onDidOpenPopoutWindowFail: Event<void> =
this._onDidOpenPopoutWindowFail.event;
private readonly _onDidLayoutFromJSON = new Emitter<void>(); private readonly _onDidLayoutFromJSON = new Emitter<void>();
readonly onDidLayoutFromJSON: Event<void> = this._onDidLayoutFromJSON.event; readonly onDidLayoutFromJSON: Event<void> = this._onDidLayoutFromJSON.event;
@ -509,7 +510,7 @@ export class DockviewComponent
this._onDidOptionsChange, this._onDidOptionsChange,
this._onDidPopoutGroupSizeChange, this._onDidPopoutGroupSizeChange,
this._onDidPopoutGroupPositionChange, this._onDidPopoutGroupPositionChange,
this._onDidBlockPopout, this._onDidOpenPopoutWindowFail,
this.onDidViewVisibilityChangeMicroTaskQueue(() => { this.onDidViewVisibilityChangeMicroTaskQueue(() => {
this.updateWatermark(); this.updateWatermark();
}), }),
@ -739,13 +740,17 @@ export class DockviewComponent
} else { } else {
group = this.createGroup({ id: groupId }); group = this.createGroup({ id: groupId });
if (popoutContainer) { if (popoutContainer) {
this._onDidAddGroup.fire(group); this._onDidAddGroup.fire(group);
} }
} }
if (popoutContainer === null) { if (popoutContainer === null) {
console.error(
'dockview: failed to create popout. perhaps you need to allow pop-ups for this website'
);
popoutWindowDisposable.dispose(); popoutWindowDisposable.dispose();
this._onDidBlockPopout.fire(); this._onDidOpenPopoutWindowFail.fire();
// if the popout window was blocked, we need to move the group back to the reference group // if the popout window was blocked, we need to move the group back to the reference group
// and set it to visible // and set it to visible
@ -988,7 +993,7 @@ export class DockviewComponent
return true; return true;
}) })
.catch((err) => { .catch((err) => {
console.error('dockview: failed to create popout window', err); console.error('dockview: failed to create popout.', err);
return false; return false;
}); });
} }

View File

@ -143,7 +143,7 @@ export const App = (props: { theme?: string }) => {
const load = (api: DockviewApi) => { const load = (api: DockviewApi) => {
api.clear(); api.clear();
api.onDidBlockPopout(() => { api.onDidOpenPopoutWindowFail(() => {
console.log('Popout blocked'); console.log('Popout blocked');
}); });
if (layout) { if (layout) {