Merge pull request #604 from mathuo/603-sonarcloud-cleanups

chore: sonarcloud requests
This commit is contained in:
mathuo 2024-05-13 21:33:27 +01:00 committed by GitHub
commit 9ee2b821ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 33 deletions

View File

@ -204,13 +204,14 @@ export class DockviewPanelApiImpl
this.groupEventsDisposable.value = new CompositeDisposable( this.groupEventsDisposable.value = new CompositeDisposable(
this.group.api.onDidVisibilityChange((event) => { this.group.api.onDidVisibilityChange((event) => {
if (!event.isVisible && this.isVisible) { const hasBecomeHidden = !event.isVisible && this.isVisible;
this._onDidVisibilityChange.fire(event); const hasBecomeVisible = event.isVisible && !this.isVisible;
} else if (
event.isVisible && const isActivePanel = this.group.model.isPanelActive(
!this.isVisible && this.panel
this.group.model.isPanelActive(this.panel) );
) {
if (hasBecomeHidden || (hasBecomeVisible && isActivePanel)) {
this._onDidVisibilityChange.fire(event); this._onDidVisibilityChange.fire(event);
} }
}), }),

View File

@ -1,4 +1,8 @@
class TransferObject {} class TransferObject {
constructor() {
// intentionally empty class
}
}
export class PanelTransfer extends TransferObject { export class PanelTransfer extends TransferObject {
constructor( constructor(

View File

@ -652,7 +652,7 @@ export class DockviewComponent
const box: Box = getBox(); const box: Box = getBox();
const groupId = const groupId =
options?.overridePopoutGroup?.id ?? this.getNextGroupId(); //item.id; options?.overridePopoutGroup?.id ?? this.getNextGroupId();
if (itemToPopout.api.location.type === 'grid') { if (itemToPopout.api.location.type === 'grid') {
itemToPopout.api.setVisible(false); itemToPopout.api.setVisible(false);
@ -811,8 +811,7 @@ export class DockviewComponent
skipPopoutAssociated: true, skipPopoutAssociated: true,
}); });
} }
} else { } else if (this.getPanel(group.id)) {
if (this.getPanel(group.id)) {
const removedGroup = this.doRemoveGroup(group, { const removedGroup = this.doRemoveGroup(group, {
skipDispose: true, skipDispose: true,
skipActive: true, skipActive: true,
@ -822,7 +821,6 @@ export class DockviewComponent
removedGroup.model.location = { type: 'grid' }; removedGroup.model.location = { type: 'grid' };
returnedGroup = removedGroup; returnedGroup = removedGroup;
} }
}
}) })
); );
@ -894,7 +892,7 @@ export class DockviewComponent
this.doRemoveGroup(item, { this.doRemoveGroup(item, {
skipDispose: true, skipDispose: true,
skipPopoutReturn: true, skipPopoutReturn: true,
skipPopoutAssociated: !!popoutReferenceGroup, skipPopoutAssociated: false,
}); });
} }
} }
@ -1372,7 +1370,6 @@ export class DockviewComponent
const groups = Array.from(this._groups.values()).map((_) => _.value); const groups = Array.from(this._groups.values()).map((_) => _.value);
const hasActiveGroup = !!this.activeGroup; const hasActiveGroup = !!this.activeGroup;
const hasActivePanel = !!this.activePanel;
for (const group of groups) { for (const group of groups) {
// remove the group will automatically remove the panels // remove the group will automatically remove the panels

View File

@ -993,7 +993,7 @@ export class DockviewGroupPanelModel
target, target,
position, position,
getPanelData, getPanelData,
this.accessor.getPanel(this.id)! this.accessor.getPanel(this.id)
); );
this._onUnhandledDragOverEvent.fire(firedEvent); this._onUnhandledDragOverEvent.fire(firedEvent);

View File

@ -63,15 +63,12 @@ export interface IDockviewReactProps extends DockviewOptions {
} }
function extractCoreOptions(props: IDockviewReactProps): DockviewOptions { function extractCoreOptions(props: IDockviewReactProps): DockviewOptions {
const coreOptions = (PROPERTY_KEYS as (keyof DockviewOptions)[]).reduce( const coreOptions = PROPERTY_KEYS.reduce((obj, key) => {
(obj, key) => {
if (key in props) { if (key in props) {
obj[key] = props[key] as any; obj[key] = props[key] as any;
} }
return obj; return obj;
}, }, {} as Partial<DockviewComponentOptions>);
{} as Partial<DockviewComponentOptions>
);
return coreOptions as DockviewOptions; return coreOptions as DockviewOptions;
} }
@ -91,7 +88,7 @@ export const DockviewReact = React.forwardRef(
const changes: Partial<DockviewOptions> = {}; const changes: Partial<DockviewOptions> = {};
PROPERTY_KEYS.forEach((propKey) => { PROPERTY_KEYS.forEach((propKey) => {
const key = propKey as keyof DockviewOptions; const key = propKey;
const propValue = props[key]; const propValue = props[key];
if (key in props && propValue !== prevProps.current[key]) { if (key in props && propValue !== prevProps.current[key]) {