diff --git a/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts b/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts index ffe65a1797..df4b8496e7 100644 --- a/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts +++ b/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts @@ -79,6 +79,7 @@ export class NavTreeResource extends CachedMapResource { this.onNodeRefresh = new Executor(null, (a, b) => a === b); this.onDataOutdated.addHandler(navNodeInfoResource.markOutdated.bind(navNodeInfoResource)); + this.onDataUpdate.addHandler(navNodeInfoResource.markUpdated.bind(navNodeInfoResource)); this.sessionDataResource.onDataUpdate.addPostHandler(() => this.markOutdated()); this.connectionInfo.onItemAdd.addHandler(this.connectionUpdateHandler.bind(this)); this.connectionInfo.onItemDelete.addHandler(this.connectionRemoveHandler); @@ -106,7 +107,7 @@ export class NavTreeResource extends CachedMapResource { ResourceKeyUtils.forEach(children, key => { const metadata = this.metadata.get(key); - if (!metadata.withDetails) { + if (!metadata.withDetails && state) { metadata.outdated = true; } metadata.withDetails = state; @@ -273,7 +274,7 @@ export class NavTreeResource extends CachedMapResource { } private async connectionUpdateHandler(key: ResourceKey) { - const closedConnectionsTree: string[] = []; + const closedConnections: string[] = []; await ResourceKeyUtils.forEachAsync(key, async key => { const nodeId = NodeManagerUtils.connectionIdToConnectionNodeId(key); @@ -282,15 +283,17 @@ export class NavTreeResource extends CachedMapResource { const connectionInfo = this.connectionInfo.get(key); if (!connectionInfo?.connected) { - closedConnectionsTree.push(...this.get(nodeId) || []); + closedConnections.push(nodeId); } else { await this.markOutdated(nodeId); } } }); - if (closedConnectionsTree.length > 0) { - this.delete(resourceKeyList(closedConnectionsTree)); + if (closedConnections.length > 0) { + const key = resourceKeyList(closedConnections); + this.set(key, closedConnections.map(() => [])); + await this.markOutdated(ROOT_NODE_PATH); } } diff --git a/webapp/packages/core-blocks/src/Table/useTable.tsx b/webapp/packages/core-blocks/src/Table/useTable.tsx index b153ce94aa..9fcd74b2b5 100644 --- a/webapp/packages/core-blocks/src/Table/useTable.tsx +++ b/webapp/packages/core-blocks/src/Table/useTable.tsx @@ -36,7 +36,7 @@ export function useTable(): ITableState { return Array.from(this.selected.values()).some(v => v); }, unselect(key?: string | string[]) { - if (!key) { + if (key === undefined) { this.selected.clear(); } else { if (typeof key === 'string') { @@ -51,7 +51,7 @@ export function useTable(): ITableState { return this.selected; }, unexpand(key?: string | string[]) { - if (!key) { + if (key === undefined) { this.expanded.clear(); } else { if (typeof key === 'string') { diff --git a/webapp/packages/core-connections/src/ConnectionForm/DriverProperties/DriverProperties.tsx b/webapp/packages/core-connections/src/ConnectionForm/DriverProperties/DriverProperties.tsx index e0325c046a..c1ecfac6bf 100644 --- a/webapp/packages/core-connections/src/ConnectionForm/DriverProperties/DriverProperties.tsx +++ b/webapp/packages/core-connections/src/ConnectionForm/DriverProperties/DriverProperties.tsx @@ -49,7 +49,7 @@ export const DriverProperties: TabContainerPanelComponent key: key ?? '', defaultValue: value ?? '', keyPlaceholder: 'property', - new: !key, + new: key === undefined, }); } diff --git a/webapp/packages/core-sdk/src/Resource/CachedMapResource.ts b/webapp/packages/core-sdk/src/Resource/CachedMapResource.ts index 5529e4c31d..d556d24860 100644 --- a/webapp/packages/core-sdk/src/Resource/CachedMapResource.ts +++ b/webapp/packages/core-sdk/src/Resource/CachedMapResource.ts @@ -89,6 +89,7 @@ export abstract class CachedMapResource< makeObservable(this, { set: action, delete: action, + clear: action, values: computed, keys: computed, }); @@ -159,7 +160,7 @@ export abstract class CachedMapResource< markOutdated(): Promise markOutdated(key: ResourceKey): Promise async markOutdated(key?: ResourceKey): Promise { - if (!key) { + if (key === undefined) { key = resourceKeyList(this.keys); } else { key = this.transformParam(key); @@ -176,7 +177,7 @@ export abstract class CachedMapResource< markUpdated(): void markUpdated(key: ResourceKey): void markUpdated(key?: ResourceKey): void { - if (!key) { + if (key === undefined) { key = resourceKeyList(this.keys); } else { key = this.transformParam(key); @@ -241,6 +242,11 @@ export abstract class CachedMapResource< this.onItemDelete.execute(key); } + clear(): void { + this.data.clear(); + this.metadata.clear(); + } + async refresh = []>( key: TKey, includes?: T @@ -291,7 +297,7 @@ export abstract class CachedMapResource< } getIncludes(key?: ResourceKey): string[] { - if (!key) { + if (key === undefined) { return this.defaultIncludes; } key = this.transformParam(key);