Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4018 fix: hides chart settings if charts tab is not selected #2433

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -20,12 +20,14 @@ export class TempDataContext implements IDataContext {
target: IDataContext;
fallback?: IDataContextProvider;
private flushTimeout: any;
private 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>(this, {
target: observable.ref,
Expand All @@ -42,7 +44,9 @@ export class TempDataContext implements IDataContext {
}

hasOwn(context: DataContextGetter<any>): boolean {
return this.map.has(context) || this.target.hasOwn(context);
this.atom.reportObserved();
const isTargetHasOwn = this.target.hasOwn(context);
return this.map.has(context) || isTargetHasOwn;
}

has(context: DataContextGetter<any>, nested = true): boolean {
Expand Down Expand Up @@ -96,11 +100,14 @@ export class TempDataContext implements IDataContext {
}

getOwn<T>(context: DataContextGetter<T>): 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<T>(context: DataContextGetter<T>, value: T): DeleteVersionedContextCallback {
Expand Down Expand Up @@ -173,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 {
Expand Down
Loading