Skip to content

Commit

Permalink
chore: feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Carina Ursu <[email protected]>
  • Loading branch information
ursucarina committed Mar 21, 2023
1 parent 1406bd8 commit 549a234
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export const NodeExecutionDetailsPanelContent: React.FC<
phase={taskPhase}
taskTemplate={details?.taskTemplate}
onTaskSelected={setSelectedTaskExecution}
taskIndex={selectedTaskExecution?.taskIndex || undefined}
taskIndex={selectedTaskExecution?.taskIndex!}
/>
) : null;

Expand Down
13 changes: 2 additions & 11 deletions packages/console/src/components/Literals/LiteralMapViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ export const LiteralMapViewer: React.FC<{
return <NoneTypeValue />;
}

const transformedLiterals = transformLiterals(literals);
const transformedLiterals = transformLiterals(literals, mapTaskIndex);

let transformedLiteralsFinal = {};
if (!isNaN(mapTaskIndex as number)) {
const keys = Object.keys(transformedLiterals);
transformedLiteralsFinal[keys?.[0]] =
transformedLiterals?.[keys?.[0]]?.[mapTaskIndex as number];
} else {
transformedLiteralsFinal = transformedLiterals;
}

return <ReactJsonViewWrapper src={transformedLiteralsFinal} />;
return <ReactJsonViewWrapper src={transformedLiterals} />;
};
33 changes: 23 additions & 10 deletions packages/console/src/components/Literals/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,27 +351,37 @@ function processScalar(
}
}

function processCollection(collection?: Core.ILiteralCollection | null) {
const literals = collection?.literals;
function processCollection(
collection?: Core.ILiteralCollection | null,
mapTaskIndex?: number,
) {
let literals = collection?.literals;

if (!literals) {
return 'invalid collection';
}

return literals?.map(literal => processLiteral(literal));
if (!isNaN(mapTaskIndex!)) {
literals = (literals || []).splice(mapTaskIndex!, 1);
}

return literals?.map(literal => processLiteral(literal, mapTaskIndex));
}

function processMap(map?: Core.ILiteralMap | null) {
function processMap(map?: Core.ILiteralMap | null, mapTaskIndex?: number) {
const literals = map?.literals;

if (!literals) {
return 'invalid map';
}

return transformLiterals(literals);
return transformLiterals(literals, mapTaskIndex);
}

function processLiteral(literal?: Core.ILiteral & Pick<Core.Literal, 'value'>) {
function processLiteral(
literal?: Core.ILiteral & Pick<Core.Literal, 'value'>,
mapTaskIndex?: number,
) {
const type = literal?.value;

if (!literal) {
Expand All @@ -382,18 +392,21 @@ function processLiteral(literal?: Core.ILiteral & Pick<Core.Literal, 'value'>) {
case 'scalar':
return processScalar(literal.scalar);
case 'collection':
return processCollection(literal.collection);
return processCollection(literal.collection, mapTaskIndex);
case 'map':
return processMap(literal.map);
return processMap(literal.map, mapTaskIndex);
default:
return DEFAULT_UNSUPPORTED;
}
}

export function transformLiterals(json: { [k: string]: Core.ILiteral }) {
export function transformLiterals(
json: { [k: string]: Core.ILiteral },
mapTaskIndex?: number,
) {
const obj = Object.entries(json)
.map(([key, literal]) => ({
[key]: processLiteral(literal),
[key]: processLiteral(literal, mapTaskIndex),
}))
.reduce(
(acc, cur) => ({
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@flyteorg/common": "^0.0.3",
"@flyteorg/console": "^0.0.14",
"@flyteorg/console": "^0.0.15",
"long": "^4.0.0",
"protobufjs": "~6.11.3",
"react-ga4": "^1.4.1",
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,7 @@ __metadata:
resolution: "@flyteconsole/client-app@workspace:website"
dependencies:
"@flyteorg/common": ^0.0.3
"@flyteorg/console": ^0.0.14
"@flyteorg/console": ^0.0.15
"@types/long": ^3.0.32
long: ^4.0.0
protobufjs: ~6.11.3
Expand Down Expand Up @@ -2034,7 +2034,7 @@ __metadata:
languageName: unknown
linkType: soft

"@flyteorg/console@^0.0.14, @flyteorg/console@workspace:packages/console":
"@flyteorg/console@^0.0.15, @flyteorg/console@workspace:packages/console":
version: 0.0.0-use.local
resolution: "@flyteorg/console@workspace:packages/console"
dependencies:
Expand Down

0 comments on commit 549a234

Please sign in to comment.