Skip to content
Merged
Show file tree
Hide file tree
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 @@ -279,33 +279,38 @@ export const QueryInputSettings = observer(

if (variable.type === "query") {
const q = state.getQuery(variable.to);
for (const f in q._exposed) {
pathMap[`${alias}.${f}`] = {
id: `${alias}.${f}`,
path: `${alias}.${f}`,
type: typeof q[f], // TODO: get value
display: `${alias}.${f}`,
blockType: "query-prop",
variabilized: true,
groupAlias: groupAliasMapper("query-prop"),
};
if(q) {
for (const f in q._exposed) {
pathMap[`${alias}.${f}`] = {
id: `${alias}.${f}`,
path: `${alias}.${f}`,
type: typeof q[f], // TODO: get value
display: `${alias}.${f}`,
blockType: "query-prop",
variabilized: true,
groupAlias: groupAliasMapper("query-prop"),
};
}
}
}

if (variable.type === "cell") {
const q = state.getQuery(variable.to);
const c = q.getCell(variable.cellId);

for (const f in c._exposed) {
pathMap[`${alias}.${f}`] = {
id: `${alias}.${f}`,
path: `${alias}.${f}`,
type: typeof c[f], // TODO: get value
display: `${alias}.${f}`,
blockType: "cell-prop",
variabilized: true,
groupAlias: groupAliasMapper("cell-prop"),
};
if(q) {
const c = q.getCell(variable.cellId);

for (const f in c._exposed) {
pathMap[`${alias}.${f}`] = {
id: `${alias}.${f}`,
path: `${alias}.${f}`,
type: typeof c[f], // TODO: get value
display: `${alias}.${f}`,
blockType: "cell-prop",
variabilized: true,
groupAlias: groupAliasMapper("cell-prop"),
};
}
}
}
},
Expand Down
28 changes: 28 additions & 0 deletions libs/renderer/src/store/state/state.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,36 @@ export class StateStore {
this,
);

// TODO: Do we want this to be done here

// Automate variable creation for notebook and new cell
this.dispatch({
message: ActionMessages.ADD_VARIABLE,
payload: {
id: queryId,
type: "query",
to: queryId,
isOutput: true
}
})

Object.entries(this._store.queries[queryId].cells).forEach((c) => {
// Automate variable creation for notebook and new cell
const cId = c[0]
this.dispatch({
message: ActionMessages.ADD_VARIABLE,
payload: {
id: `${queryId}--${cId}`,
type: "cell",
to: queryId,
cellId: cId
}
})
})

this._store.executionOrder.push(queryId);


return queryId;
};

Expand Down
16 changes: 15 additions & 1 deletion packages/client/src/components/designer/AddBlocksMenuCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';
import { observer } from 'mobx-react-lite';
import { ReportRounded } from '@mui/icons-material';

import { ActionMessages, useBlocks } from '@semoss/renderer';
import { ActionMessages, INPUT_BLOCK_TYPES, useBlocks } from '@semoss/renderer';
import {
styled,
Card,
Expand Down Expand Up @@ -182,6 +182,20 @@ export const AddBlocksMenuCard = observer((props: AddBlocksMenuItemProps) => {
}
}

// TODO: REFACTOR
// Add variables for all blocks that are inputs from user
if (INPUT_BLOCK_TYPES.indexOf(item.json.widget) > -1) {
state.dispatch({
message: ActionMessages.ADD_VARIABLE,
payload: {
id: id,
type: 'block',
to: id,
isInput: true,
},
});
}

// clear the drag
designer.deactivateDrag();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import { ContentCopy, Delete, DeleteOutline } from '@mui/icons-material';
import { getRelativeSize, getBlockElement } from '@/stores';

import { useDesigner } from '@/hooks';
import { BlockJSON, ActionMessages, useBlocks } from '@semoss/renderer';
import {
BlockJSON,
ActionMessages,
useBlocks,
INPUT_BLOCK_TYPES,
} from '@semoss/renderer';

const STYLED_BUTTON_GROUP_ICON_BUTTON_WIDTH = 48;
const STYLED_BUTTON_GROUP_ICON_BUTTON_HEIGHT = 32;
Expand Down Expand Up @@ -236,6 +241,21 @@ export const DeleteDuplicateMask = observer(
},
});

// TODO: REFACTOR
// Add variables for all blocks that are inputs from user
// TODO: What about grouping of inputs
if (INPUT_BLOCK_TYPES.indexOf(block.widget) > -1) {
state.dispatch({
message: ActionMessages.ADD_VARIABLE,
payload: {
id: id as string,
type: 'block',
to: id as string,
isInput: true,
},
});
}

designer.setSelected(id ? (id as string) : '');
};

Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/notebook/NewQueryOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const NewQueryOverlay = observer(
if (!data.ID) {
setError('ID', {
type: 'manual',
message: `Query Id is required`,
message: `Notebook Id is required`,
});
return;
}
Expand All @@ -67,7 +67,7 @@ export const NewQueryOverlay = observer(
if (state.queries[data.ID] || state.blocks[data.ID]) {
setError('ID', {
type: 'manual',
message: `Query Id ${data.ID} already exists`,
message: `Notebook Id ${data.ID} already exists`,
});
return;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/client/src/components/notebook/NotebookAddCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ export const NotebookAddCell = observer(
config: config as Omit<CellStateConfig, 'id'>,
},
});

state.dispatch({
message: ActionMessages.ADD_VARIABLE,
payload: {
id: `${query.id}--${newCellId}`,
type: 'cell',
to: query.id,
cellId: newCellId,
},
});

notebook.selectCell(query.id, newCellId);
} catch (e) {
console.error(e);
Expand Down