From d174b24db1087d4d23c279a0fd8b8a30af845bf6 Mon Sep 17 00:00:00 2001 From: Gleb Kanterov Date: Wed, 11 Nov 2020 23:13:12 +0100 Subject: [PATCH] fix: handle null LiteralMap in RemoteLiteralMapViewer (#117) flyteidl generated JS code uses null as a default value for non-primitive objects. --- .../ExecutionDetails/test/RelaunchExecutionForm.test.tsx | 4 +++- .../Tables/__stories__/NodeExecutionsTable.stories.tsx | 8 +++++++- .../Launch/LaunchForm/__stories__/LaunchForm.stories.tsx | 4 +++- src/components/Literals/RemoteLiteralMapViewer.tsx | 4 ++-- .../Literals/test/RemoteLiteralMapViewer.test.tsx | 6 +++--- src/models/Execution/api.ts | 4 +++- src/models/Execution/types.ts | 4 ++-- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx b/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx index 32dcee7b3..a9930e343 100644 --- a/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx +++ b/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx @@ -84,7 +84,9 @@ describe('RelaunchExecutionForm', () => { task = createMockTask('MyTask'); executionData = { inputs: { url: 'http://somePath', bytes: long(1000) }, - outputs: {} + outputs: {}, + fullInputs: null, + fullOutputs: null }; mockGetWorkflow = jest.fn().mockResolvedValue(workflow); diff --git a/src/components/Executions/Tables/__stories__/NodeExecutionsTable.stories.tsx b/src/components/Executions/Tables/__stories__/NodeExecutionsTable.stories.tsx index 54ff71bfb..b2a389bcd 100644 --- a/src/components/Executions/Tables/__stories__/NodeExecutionsTable.stories.tsx +++ b/src/components/Executions/Tables/__stories__/NodeExecutionsTable.stories.tsx @@ -47,7 +47,13 @@ const nodeRetryAttempts = { const apiContext = mockAPIContextValue({ getExecution: () => Promise.resolve(workflowExecution), - getNodeExecutionData: () => Promise.resolve({ inputs: {}, outputs: {} }), + getNodeExecutionData: () => + Promise.resolve({ + inputs: {}, + outputs: {}, + fullInputs: null, + fullOutputs: null + }), listTaskExecutions: nodeExecutionId => { const length = nodeRetryAttempts[nodeExecutionId.nodeId] || 1; const entities = Array.from({ length }, (_, retryAttempt) => diff --git a/src/components/Launch/LaunchForm/__stories__/LaunchForm.stories.tsx b/src/components/Launch/LaunchForm/__stories__/LaunchForm.stories.tsx index 658a8eae3..858681dc4 100644 --- a/src/components/Launch/LaunchForm/__stories__/LaunchForm.stories.tsx +++ b/src/components/Launch/LaunchForm/__stories__/LaunchForm.stories.tsx @@ -67,7 +67,9 @@ const generateMocks = (variables: Record) => { const mockExecutionData: ExecutionData = { inputs: { url: 'inputsUrl', bytes: Long.fromNumber(1000) }, - outputs: { url: 'outputsUrl', bytes: Long.fromNumber(1000) } + outputs: { url: 'outputsUrl', bytes: Long.fromNumber(1000) }, + fullInputs: null, + fullOutputs: null }; const mockExecutionInputs: LiteralMap = Object.keys( diff --git a/src/components/Literals/RemoteLiteralMapViewer.tsx b/src/components/Literals/RemoteLiteralMapViewer.tsx index b4c1e19cd..341a62c88 100644 --- a/src/components/Literals/RemoteLiteralMapViewer.tsx +++ b/src/components/Literals/RemoteLiteralMapViewer.tsx @@ -28,7 +28,7 @@ const BlobTooLarge: React.FC<{ url: string }> = ({ url }) => ( */ export const RemoteLiteralMapViewer: React.FC<{ blob: UrlBlob; - map?: LiteralMap; + map: LiteralMap | null; }> = ({ blob, map }) => { if (!blob.url || !blob.bytes) { return ( @@ -38,7 +38,7 @@ export const RemoteLiteralMapViewer: React.FC<{ ); } - if (map !== undefined) { + if (map != null) { return ; } diff --git a/src/components/Literals/test/RemoteLiteralMapViewer.test.tsx b/src/components/Literals/test/RemoteLiteralMapViewer.test.tsx index 4de9e509f..c7b09215b 100644 --- a/src/components/Literals/test/RemoteLiteralMapViewer.test.tsx +++ b/src/components/Literals/test/RemoteLiteralMapViewer.test.tsx @@ -18,7 +18,7 @@ describe('RemoteLiteralMapViewer', () => { }; const { getAllByText } = render( - + ); const items = getAllByText('No data is available.'); @@ -45,7 +45,7 @@ describe('RemoteLiteralMapViewer', () => { expect(items.length).toBe(1); }); - it('fetches blob if map is undefined', () => { + it('fetches blob if map is null', () => { const map: LiteralMap = { literals: { input1: {} @@ -65,7 +65,7 @@ describe('RemoteLiteralMapViewer', () => { }; const { getAllByText } = render( - + ); const items = getAllByText('input1:'); diff --git a/src/models/Execution/api.ts b/src/models/Execution/api.ts index 0786ae03e..a79a356d4 100644 --- a/src/models/Execution/api.ts +++ b/src/models/Execution/api.ts @@ -65,7 +65,9 @@ export const getExecution = ( const emptyExecutionData: ExecutionData = { inputs: {}, - outputs: {} + outputs: {}, + fullInputs: null, + fullOutputs: null }; /** Fetches data URLs for an `Execution` record */ export const getExecutionData = ( diff --git a/src/models/Execution/types.ts b/src/models/Execution/types.ts index 0ad9046f6..6fc76b000 100644 --- a/src/models/Execution/types.ts +++ b/src/models/Execution/types.ts @@ -132,6 +132,6 @@ export interface TaskExecutionClosure extends Admin.ITaskExecutionClosure { export interface ExecutionData { inputs: UrlBlob; outputs: UrlBlob; - fullInputs?: LiteralMap; - fullOutputs?: LiteralMap; + fullInputs: LiteralMap | null; + fullOutputs: LiteralMap | null; }