-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release' into test/appimport
- Loading branch information
Showing
42 changed files
with
1,158 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { convertPathToString } from "@appsmith/workers/Evaluation/evaluationUtils"; | ||
import type { Diff } from "deep-diff"; | ||
import type { DataTree } from "entities/DataTree/dataTreeFactory"; | ||
import { get, set, unset } from "lodash"; | ||
|
||
export type TDataStore = Record<string, Record<string, unknown>>; | ||
export default class DataStore { | ||
private static store: TDataStore = {}; | ||
|
||
static setActionData(fullPath: string, value: unknown) { | ||
set(this.store, fullPath, value); | ||
} | ||
|
||
static getActionData(fullPath: string): unknown | undefined { | ||
return get(this.store, fullPath, undefined); | ||
} | ||
static getDataStore() { | ||
return this.store; | ||
} | ||
static deleteActionData(fullPath: string) { | ||
unset(this.store, fullPath); | ||
} | ||
static clear() { | ||
this.store = {}; | ||
} | ||
static update(dataTreeDiff: Diff<DataTree, DataTree>[]) { | ||
const deleteDiffs = dataTreeDiff.filter((diff) => diff.kind === "D"); | ||
deleteDiffs.forEach((diff) => { | ||
const deletedPath = diff.path || []; | ||
const deletedPathString = convertPathToString(deletedPath); | ||
this.deleteActionData(deletedPathString); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { DataTree } from "entities/DataTree/dataTreeFactory"; | ||
import type { TDataStore } from "."; | ||
import { | ||
isAction, | ||
isJSAction, | ||
} from "@appsmith/workers/Evaluation/evaluationUtils"; | ||
import { get, isEmpty, set } from "lodash"; | ||
|
||
export function updateTreeWithData(tree: DataTree, dataStore: TDataStore) { | ||
if (isEmpty(dataStore)) return; | ||
for (const entityName of Object.keys(tree)) { | ||
const entity = tree[entityName]; | ||
if (!dataStore.hasOwnProperty(entityName)) continue; | ||
if (isAction(entity)) { | ||
set(entity, "data", get(dataStore, `${entityName}.data`)); | ||
} | ||
if (isJSAction(entity)) { | ||
const allFunctionsInStore = Object.keys(dataStore[entityName]); | ||
allFunctionsInStore.forEach((functionName) => { | ||
set( | ||
entity[functionName], | ||
`data`, | ||
get(dataStore, `${entityName}.${functionName}.data`), | ||
); | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.