From 64c4be1e4f975da6ea600553341415c77d7dc61e Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 29 Feb 2024 20:33:11 +0100 Subject: [PATCH 1/9] CB-4018 fix: hides chart settings if charts tab is not selected --- .../core-data-context/src/DataContext/TempDataContext.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts index 283c8cc907..4ac3f73b98 100644 --- a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts @@ -28,6 +28,7 @@ export class TempDataContext implements IDataContext { this.fallback = fallback; makeObservable(this, { + map: observable.shallow, target: observable.ref, set: action, delete: action, From 6a01192246dca54df5b56883f139579314962a54 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 09:39:31 +0100 Subject: [PATCH 2/9] CB-4018 adds to DynamicDataContext observable contexts --- .../core-data-context/src/DataContext/DynamicDataContext.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts b/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts index 5ea6c06170..6384375f9a 100644 --- a/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts @@ -24,6 +24,7 @@ export class DynamicDataContext implements IDataContext { this.contexts = new Map(); makeObservable(this, { + contexts: observable.shallow, fallback: observable.ref, set: action, clear: action, From 82be78b8508ea067fbcb1d18235543fd79ba12cf Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 10:12:25 +0100 Subject: [PATCH 3/9] Revert "CB-4018 adds to DynamicDataContext observable contexts" This reverts commit 6a01192246dca54df5b56883f139579314962a54. --- .../core-data-context/src/DataContext/DynamicDataContext.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts b/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts index 6384375f9a..5ea6c06170 100644 --- a/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/DynamicDataContext.ts @@ -24,7 +24,6 @@ export class DynamicDataContext implements IDataContext { this.contexts = new Map(); makeObservable(this, { - contexts: observable.shallow, fallback: observable.ref, set: action, clear: action, From 0718e09ba6d28b8c5519fc44980944a0565fc865 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 10:12:31 +0100 Subject: [PATCH 4/9] Revert "CB-4018 fix: hides chart settings if charts tab is not selected" This reverts commit 64c4be1e4f975da6ea600553341415c77d7dc61e. --- .../core-data-context/src/DataContext/TempDataContext.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts index 4ac3f73b98..283c8cc907 100644 --- a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts @@ -28,7 +28,6 @@ export class TempDataContext implements IDataContext { this.fallback = fallback; makeObservable(this, { - map: observable.shallow, target: observable.ref, set: action, delete: action, From e2c3705dd92687cf0428ad9f17e0a480babe0ded Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 10:26:19 +0100 Subject: [PATCH 5/9] CB-4018 fix: hides chart settings if charts tab is not selected [2] --- .../core-data-context/src/DataContext/TempDataContext.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts index 283c8cc907..be819e3205 100644 --- a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts @@ -42,7 +42,8 @@ export class TempDataContext implements IDataContext { } hasOwn(context: DataContextGetter): boolean { - return this.map.has(context) || this.target.hasOwn(context); + const isTargetHasOwn = this.target.hasOwn(context); + return this.map.has(context) || isTargetHasOwn; } has(context: DataContextGetter, nested = true): boolean { From 5501d9be406fd8c951c34d8290c63eead8217bf3 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 11:40:55 +0100 Subject: [PATCH 6/9] =?UTF-8?q?=D0=A1B-4018=20reportObserved=20for=20TempD?= =?UTF-8?q?ataContext=20hasOwn=20fn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core-data-context/src/DataContext/TempDataContext.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts index be819e3205..2caef8749b 100644 --- a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts @@ -5,7 +5,7 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { action, makeObservable, observable } from 'mobx'; +import { action, createAtom, IAtom, makeObservable, observable } from 'mobx'; import { MetadataMap } from '@cloudbeaver/core-utils'; @@ -20,12 +20,14 @@ export class TempDataContext implements IDataContext { target: IDataContext; fallback?: IDataContextProvider; private flushTimeout: any; + atom: IAtom; constructor(fallback?: IDataContextProvider) { this.map = new Map(); this.versions = new MetadataMap(() => 0); this.target = new DataContext(fallback); this.fallback = fallback; + this.atom = createAtom('TempDataContextAtom'); makeObservable(this, { target: observable.ref, @@ -42,6 +44,7 @@ export class TempDataContext implements IDataContext { } hasOwn(context: DataContextGetter): boolean { + this.atom.reportObserved(); const isTargetHasOwn = this.target.hasOwn(context); return this.map.has(context) || isTargetHasOwn; } From ba050d84651d885fa1e598731470b501d8a1e9ad Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 11:50:08 +0100 Subject: [PATCH 7/9] =?UTF-8?q?=D0=A1B-4018=20reportObserved=20for=20TempD?= =?UTF-8?q?ataContext=20getOwn=20fn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core-data-context/src/DataContext/TempDataContext.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts index 2caef8749b..98e17d2c6b 100644 --- a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts @@ -100,6 +100,7 @@ export class TempDataContext implements IDataContext { } getOwn(context: DataContextGetter): T | undefined { + this.atom.reportObserved(); if (this.map.has(context)) { return this.map.get(context); } From e1281de74a42c78ede66e9707871cdf51b4766ea Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 15:39:00 +0100 Subject: [PATCH 8/9] =?UTF-8?q?=D0=A1B-4018=20fix:=20TempDataContext=20mob?= =?UTF-8?q?x=20subscriptions=20works=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core-data-context/src/DataContext/TempDataContext.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts index 98e17d2c6b..35aae3fadf 100644 --- a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts @@ -101,11 +101,13 @@ export class TempDataContext implements IDataContext { getOwn(context: DataContextGetter): T | undefined { this.atom.reportObserved(); + const targetOwn = this.target.getOwn(context); + if (this.map.has(context)) { return this.map.get(context); } - return this.target.getOwn(context); + return targetOwn; } set(context: DataContextGetter, value: T): DeleteVersionedContextCallback { @@ -178,6 +180,8 @@ export class TempDataContext implements IDataContext { for (const [key, value] of this.map) { this.target.set(key, value); } + + this.atom.reportChanged(); } private planFlush(): void { From 61bcaa0a82102cc3569985dd07b964501d314cc6 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Fri, 1 Mar 2024 15:42:48 +0100 Subject: [PATCH 9/9] CB-4018 atom is privated --- .../core-data-context/src/DataContext/TempDataContext.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts index 35aae3fadf..99fbb002fa 100644 --- a/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts +++ b/webapp/packages/core-data-context/src/DataContext/TempDataContext.ts @@ -20,7 +20,7 @@ export class TempDataContext implements IDataContext { target: IDataContext; fallback?: IDataContextProvider; private flushTimeout: any; - atom: IAtom; + private atom: IAtom; constructor(fallback?: IDataContextProvider) { this.map = new Map();