CB-3300 feat: dataset editing (#1614)

* CB-3300 feat: dataset editing

* CB-3300 chore: remove unused styles

---------

Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com>
This commit is contained in:
Alexey
2023-04-19 19:01:44 +03:00
committed by GitHub
co-authored by mr-anton-t
parent 200105f692
commit 736fd39d08
34 changed files with 304 additions and 64 deletions
@@ -40,9 +40,10 @@ export abstract class BaseSqlDataSource implements ISqlDataSource {
}
get features(): ESqlDataSourceFeatures[] {
return [ESqlDataSourceFeatures.script];
return [ESqlDataSourceFeatures.script, ESqlDataSourceFeatures.query, ESqlDataSourceFeatures.executable];
}
protected saved: boolean;
readonly history: ISqlDataSourceHistory;
readonly onUpdate: ISyncExecutor;
readonly onSetScript: ISyncExecutor<ISetScriptData>;
@@ -57,6 +58,7 @@ export abstract class BaseSqlDataSource implements ISqlDataSource {
this.message = undefined;
this.outdated = true;
this.editing = true;
this.saved = true;
this.history = new SqlDataSourceHistory();
this.onUpdate = new SyncExecutor();
this.onSetScript = new SyncExecutor();
@@ -83,17 +85,24 @@ export abstract class BaseSqlDataSource implements ISqlDataSource {
}
setScript(script: string, source?: string): void {
this.saved = false;
this.onSetScript.execute({ script, source });
}
abstract canRename(name: string | null): boolean;
setName(name: string | null): void {
this.onUpdate.execute();
}
setExecutionContext(executionContext?: IConnectionExecutionContextInfo | undefined): void {
this.onUpdate.execute();
}
isSaved(): boolean {
return this.saved;
}
isError(): boolean {
return isContainsException(this.exception);
}
@@ -146,6 +155,10 @@ export abstract class BaseSqlDataSource implements ISqlDataSource {
this.onUpdate.execute();
}
save(): Promise<void> | void { }
load(): Promise<void> | void { }
reset(): Promise<void> | void {
this.saved = true;
}
dispose(): void | Promise<void> { }
}
@@ -8,6 +8,8 @@
export enum ESqlDataSourceFeatures {
script,
query,
executable,
setName,
setProject
}
@@ -40,6 +40,7 @@ export interface ISqlDataSource extends ILoadableState {
readonly features: ESqlDataSourceFeatures[];
readonly history: ISqlDataSourceHistory;
isSaved(): boolean;
isReadonly(): boolean;
isEditing(): boolean;
isOutdated(): boolean;
@@ -52,6 +53,8 @@ export interface ISqlDataSource extends ILoadableState {
setScript(script: string, source?: string): void;
setEditing(state: boolean): void;
setExecutionContext(executionContext?: IConnectionExecutionContextInfo): void;
save(): Promise<void> | void;
load(): Promise<void> | void;
reset(): Promise<void> | void;
dispose(): Promise<void> | void;
}
@@ -30,7 +30,12 @@ export class LocalStorageSqlDataSource extends BaseSqlDataSource {
}
get features(): ESqlDataSourceFeatures[] {
return [ESqlDataSourceFeatures.script, ESqlDataSourceFeatures.setName];
return [
ESqlDataSourceFeatures.script,
ESqlDataSourceFeatures.query,
ESqlDataSourceFeatures.executable,
ESqlDataSourceFeatures.setName,
];
}
private readonly state: ILocalStorageSqlDataSourceState;
@@ -47,6 +52,10 @@ export class LocalStorageSqlDataSource extends BaseSqlDataSource {
});
}
isSaved(): boolean {
return true;
}
isReadonly(): boolean {
return false;
}
@@ -29,7 +29,12 @@ export class MemorySqlDataSource extends BaseSqlDataSource {
}
get features(): ESqlDataSourceFeatures[] {
return [ESqlDataSourceFeatures.script, ESqlDataSourceFeatures.setName];
return [
ESqlDataSourceFeatures.script,
ESqlDataSourceFeatures.query,
ESqlDataSourceFeatures.executable,
ESqlDataSourceFeatures.setName,
];
}
private _name: string | null;
@@ -55,6 +60,10 @@ export class MemorySqlDataSource extends BaseSqlDataSource {
});
}
isSaved(): boolean {
return true;
}
isReadonly(): boolean {
return false;
}