Merge pull request #197 from mathuo/196-make-dockview-panel-title-optional

feat: dockview title to be optional
This commit is contained in:
mathuo 2023-02-27 16:01:06 +08:00 committed by GitHub
commit 722152c80c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 13 deletions

View File

@ -79,7 +79,8 @@ export class DefaultTab extends CompositeDisposable implements ITabRenderer {
public init(params: GroupPanelPartInitParameters) {
this.params = params;
this._content.textContent = params.title;
this._content.textContent =
typeof params.title === 'string' ? params.title : this.id;
addDisposableListener(this.action, 'click', (ev) => {
ev.preventDefault(); //
@ -106,7 +107,10 @@ export class DefaultTab extends CompositeDisposable implements ITabRenderer {
private render() {
if (this._content.textContent !== this.params.title) {
this._content.textContent = this.params.title;
this._content.textContent =
typeof this.params.title === 'string'
? this.params.title
: this.id;
}
}
}

View File

@ -9,11 +9,7 @@ import {
IGroupPanelInitParameters,
} from '../groupview/types';
import { GroupPanel } from '../groupview/groupviewPanel';
import {
CompositeDisposable,
IDisposable,
MutableDisposable,
} from '../lifecycle';
import { CompositeDisposable, IDisposable } from '../lifecycle';
import { IPanel, Parameters } from '../panel/types';
import { IGroupPanelView } from './defaultGroupPanelView';
import { DockviewComponent } from './dockviewComponent';
@ -34,8 +30,6 @@ export class DockviewPanel
extends CompositeDisposable
implements IDockviewPanel
{
private readonly mutableDisposable = new MutableDisposable();
readonly api: DockviewPanelApiImpl;
private _group: GroupPanel;
private _params?: Parameters;
@ -88,7 +82,9 @@ export class DockviewPanel
this._params = params.params;
this._view = params.view;
this.setTitle(params.title);
if (typeof params.title === 'string') {
this.setTitle(params.title);
}
this.view?.init({
...params,
@ -183,7 +179,6 @@ export class DockviewPanel
public dispose(): void {
this.api.dispose();
this.mutableDisposable.dispose();
this.view?.dispose();
}

View File

@ -19,7 +19,7 @@ export interface IRenderable {
}
export interface HeaderPartInitParameters {
title: string;
title?: string;
}
export interface GroupPanelPartInitParameters
@ -88,6 +88,6 @@ export type GroupPanelUpdateEvent = PanelUpdateEvent<{
export interface GroupviewPanelState {
id: string;
view?: any;
title: string;
title?: string;
params?: { [key: string]: any };
}