Skip to content

Commit

Permalink
chore: fix
Browse files Browse the repository at this point in the history
Signed-off-by: Carina Ursu <[email protected]>
  • Loading branch information
ursucarina committed May 5, 2022
1 parent 5d94284 commit 22c4f1d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const NoDataIsAvailable = () => {
};

/** Renders a LiteralMap as a formatted object */
export const LiteralMapViewer: React.FC<{
export const DeprecatedLiteralMapViewer: React.FC<{
className?: string;
map: LiteralMap | null;
showBrackets?: boolean;
Expand Down
27 changes: 19 additions & 8 deletions packages/zapp/console/src/components/Literals/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ import {
SchemaColumnType,
} from 'models/Common/types';

const DEFAULT_UNSUPPORTED = 'This type is not yet supported';

// PRIMITIVE
function processPrimitive(primitive: Core.IPrimitive) {
const type = (primitive as Core.Primitive).value!;
const type = (primitive as Core.Primitive).value;
if (!type) {
return DEFAULT_UNSUPPORTED;
}

switch (type) {
case 'datetime':
return formatDateUTC(timestampToDate(primitive.datetime!));
Expand All @@ -24,7 +30,6 @@ function processPrimitive(primitive: Core.IPrimitive) {
case 'boolean':
case 'floatValue':
return primitive[type];
case 'stringValue':
default:
return `${primitive[type]}`;
}
Expand All @@ -38,16 +43,22 @@ const dimensionalityStrings: Record<BlobDimensionality, string> = {

function processBlobType(blobType: Core.IBlobType, typePrefix: string = '') {
const formatString = blobType && blobType.format ? ` (${blobType.format})` : '';
const typeString = `${dimensionalityStrings[blobType!.dimensionality!]}${formatString}`;
const typeString = blobType.dimensionality
? `${dimensionalityStrings[blobType.dimensionality]}${formatString}`
: 'unknown';

return `${typePrefix}${typeString} blob`;
}

function processBlob(blob: Core.IBlob | Core.Blob) {
const type = blob?.metadata?.type;

if (!type) {
return DEFAULT_UNSUPPORTED;
}

return {
type: processBlobType(type!),
type: processBlobType(type),
uri: blob.uri,
};
}
Expand Down Expand Up @@ -109,11 +120,11 @@ function processNone(none?: Core.IVoid) {

// TODO: FC#450 ass support for union types
function processUnionType(union: Core.IUnionType, shortString = false) {
return 'This type is not yet supported';
return DEFAULT_UNSUPPORTED;
}

function processUnion(union: Core.IUnion) {
return 'This type is not yet supported';
return DEFAULT_UNSUPPORTED;
}
/* eslint-enable @typescript-eslint/no-unused-vars */

Expand Down Expand Up @@ -217,7 +228,7 @@ function processLiteralType(literalType: Core.ILiteralType) {
case 'unionType':
return processUnionType(literalType?.unionType!, true);
default:
return 'This type is not yet supported';
return DEFAULT_UNSUPPORTED;
}
}

Expand Down Expand Up @@ -282,7 +293,7 @@ function processScalar(scalar: Core.Scalar | Core.IScalar) {
case 'union':
return processUnion(value as Core.IUnion);
default:
return 'This type is not yet supported';
return DEFAULT_UNSUPPORTED;
}
}

Expand Down

0 comments on commit 22c4f1d

Please sign in to comment.