feat(xod-client): make a custom look and behavior for table-log node

This commit is contained in:
Kirill Shumilov
2021-01-27 17:00:49 +03:00
parent edf293c889
commit 66112c52c2
3 changed files with 50 additions and 21 deletions

View File

@@ -102,6 +102,11 @@ export const getWatchNodeValues = R.compose(
getDebuggerState
);
export const geTableLogValues = R.compose(
R.prop('tableLogValues'),
getDebuggerState
);
export const getUploadProgress = R.compose(
Maybe,
R.prop('uploadProgress'),
@@ -128,14 +133,38 @@ export const getCurrentChunksPath = createSelector(
}, maybeTabId)
);
export const getWatchNodeValuesForCurrentPatch = createSelector(
// :: Number -> NodeId -> Map NodeId Any -> Map NodeId Any
const filterOutValuesForCurrentPatch = R.curry(
(activeIndex, nodeIdPath, nodeIdValuesMap) =>
R.compose(
R.fromPairs,
R.when(
() => activeIndex !== 0,
R.map(R.over(R.lensIndex(0), R.replace(nodeIdPath, '')))
),
R.filter(
R.compose(
R.ifElse(
() => activeIndex === 0,
R.complement(R.contains('~')),
R.startsWith(nodeIdPath)
),
R.nth(0)
)
),
R.toPairs
)(nodeIdValuesMap)
);
export const getInteractiveNodeValuesForCurrentPatch = createSelector(
[
getCurrentTabId,
getWatchNodeValues,
geTableLogValues,
getBreadcrumbChunks,
getBreadcrumbActiveIndex,
],
(maybeTabId, nodeMap, chunks, activeIndex) =>
(maybeTabId, nodeMap, tableLogs, chunks, activeIndex) =>
foldMaybe(
{},
tabId => {
@@ -143,24 +172,23 @@ export const getWatchNodeValuesForCurrentPatch = createSelector(
const nodeIdPath = getChunksPath(activeIndex, chunks);
return R.compose(
R.fromPairs,
R.when(
() => activeIndex !== 0,
R.map(R.over(R.lensIndex(0), R.replace(nodeIdPath, '')))
),
R.filter(
R.compose(
R.ifElse(
() => activeIndex === 0,
R.complement(R.contains('~')),
R.startsWith(nodeIdPath)
),
R.nth(0)
)
),
R.toPairs
)(nodeMap);
const watchNodeValues = filterOutValuesForCurrentPatch(
activeIndex,
nodeIdPath,
nodeMap
);
const tableLogValues = R.compose(
R.map(sheets => {
const lastSheetIndex = sheets.length > 0 ? sheets.length - 1 : 0;
return `Sheet #${sheets.length}, Row #${
sheets[lastSheetIndex].length
}`;
}),
filterOutValuesForCurrentPatch(activeIndex, nodeIdPath)
)(tableLogs);
return R.merge(watchNodeValues, tableLogValues);
},
maybeTabId
)

View File

@@ -345,7 +345,7 @@ const mapStateToProps = R.applySpec({
focusedArea: EditorSelectors.getFocusedArea,
draggedPreviewSize: EditorSelectors.getDraggedPreviewSize,
isDebugSession: DebugSelectors.isDebugSession,
nodeValues: DebugSelectors.getWatchNodeValuesForCurrentPatch,
nodeValues: DebugSelectors.getInteractiveNodeValuesForCurrentPatch,
});
const mapDispatchToProps = dispatch => ({

View File

@@ -115,6 +115,7 @@ class Node extends React.Component {
return R.cond([
[XP.isTerminalPatchPath, () => <TerminalNodeBody {...this.props} />],
[XP.isWatchPatchPath, () => <WatchNodeBody {...this.props} />],
[XP.isTableLogPatchPath, () => <WatchNodeBody {...this.props} />],
[XP.isConstantNodeType, () => <ConstantNodeBody {...this.props} />],
[XP.isBindableCustomType, () => <ConstantNodeBody {...this.props} />],
[XP.isTweakPath, () => <TweakNodeBody {...this.props} />],