TODO: Move parentIndex into localMetaAttributes
parent
2782a3e517
commit
eb231231c7
|
@ -51,7 +51,11 @@ const FOLDERS: FolderNode[] = [
|
|||
{ id: 18, parent_id: 16, color: "blue", name: "Eighteen" }
|
||||
];
|
||||
|
||||
const GRAPH = ingest({ folders: FOLDERS, parentIndex: {} });
|
||||
const GRAPH = ingest({
|
||||
folders: FOLDERS,
|
||||
parentIndex: {},
|
||||
localMetaAttributes: {}
|
||||
});
|
||||
|
||||
const randomNode = () => {
|
||||
const node = sample(FOLDERS);
|
||||
|
|
|
@ -9,7 +9,11 @@ const FOLDERS: FolderNode[] = [
|
|||
{ id: 4, color: "gray", name: "tests", parent_id: undefined },
|
||||
{ id: 5, color: "pink", name: "deeply nested directory", parent_id: 3 }
|
||||
];
|
||||
const TREE = ingest({ folders: FOLDERS, parentIndex: {} });
|
||||
const TREE = ingest({
|
||||
folders: FOLDERS,
|
||||
parentIndex: {},
|
||||
localMetaAttributes: {}
|
||||
});
|
||||
|
||||
describe("climb()", () => {
|
||||
it("traverses through the nodes", () => {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Color } from "farmbot/dist/corpus";
|
||||
|
||||
export interface FolderMeta {
|
||||
open?: boolean;
|
||||
editing?: boolean;
|
||||
open: boolean;
|
||||
editing: boolean;
|
||||
sequences: string[];
|
||||
}
|
||||
|
||||
interface FolderUI {
|
||||
|
|
|
@ -3,6 +3,7 @@ import {
|
|||
FolderNodeMedial,
|
||||
FolderNodeTerminal,
|
||||
RootFolderNode,
|
||||
FolderMeta,
|
||||
} from "./constants";
|
||||
import { sortBy } from "lodash";
|
||||
|
||||
|
@ -34,8 +35,10 @@ interface IngestFnProps {
|
|||
/** "Which sequences are using this folder as their parent?"
|
||||
* Key is a number, representing a folder ID.
|
||||
* Value is a string, representing sequence UUIDs
|
||||
* (sequences that are embedded in the folders) */
|
||||
* (sequences that are embedded in the folders)
|
||||
* TODO: Maybe this can be merged into `localMetaAttributes`?*/
|
||||
parentIndex: Record<number, string[] | undefined>;
|
||||
localMetaAttributes: Record<number, FolderMeta>;
|
||||
}
|
||||
|
||||
export const ingest: IngestFn = ({ folders, parentIndex }) => {
|
||||
|
|
|
@ -68,9 +68,10 @@ export const folderIndexer: IndexerCallback = (r, i) => {
|
|||
a[s.body.folder_id || -1]?.push(s.uuid);
|
||||
return a;
|
||||
}, {} as SequenceIndexedByParentId);
|
||||
const { localMetaAttributes } = i.sequenceFolders;
|
||||
i.sequenceFolders = {
|
||||
folders: ingest({ folders, parentIndex }),
|
||||
localMetaAttributes: i.sequenceFolders.localMetaAttributes
|
||||
folders: ingest({ folders, parentIndex, localMetaAttributes }),
|
||||
localMetaAttributes
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue