Skip to content

Commit

Permalink
Process IPFS schema URLs in the Import Schema Preview and Schema Deta…
Browse files Browse the repository at this point in the history
…ils screens
  • Loading branch information
amonsosanz committed Oct 10, 2024
1 parent f902135 commit c29308b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion ui/src/components/schemas/ImportSchemaPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button, Space, Typography } from "antd";
import { processUrl } from "src/adapters/api/schemas";

import IconBack from "src/assets/icons/arrow-narrow-left.svg?react";
import { DownloadSchema } from "src/components/schemas/DownloadSchema";
Expand Down Expand Up @@ -33,6 +34,7 @@ export function ImportSchemaPreview({
? schemaHashResult.data
: schemaHashResult.error.message;
const version = jsonSchema.jsonSchemaProps.$metadata.version;
const processedSchemaUrl = processUrl(url, env);

return (
<SchemaViewer
Expand Down Expand Up @@ -63,7 +65,12 @@ export function ImportSchemaPreview({

<Detail copyable={schemaHashResult.success} label="Hash" text={schemaHash} />

<Detail copyable href={url} label="URL" text={url} />
<Detail
copyable
href={processedSchemaUrl.success ? processedSchemaUrl.data : url}
label="URL"
text={url}
/>

<DownloadSchema env={env} fileName={jsonSchema.name} url={url} />
</Space>
Expand Down
10 changes: 8 additions & 2 deletions ui/src/components/schemas/SchemaDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Card, Space, Typography } from "antd";
import { useCallback, useEffect, useState } from "react";
import { generatePath, useNavigate, useParams } from "react-router-dom";

import { getApiSchema } from "src/adapters/api/schemas";
import { getApiSchema, processUrl } from "src/adapters/api/schemas";
import { getJsonSchemaFromUrl, getSchemaJsonLdTypes } from "src/adapters/jsonSchemas";
import CreditCardIcon from "src/assets/icons/credit-card-plus.svg?react";
import { DownloadSchema } from "src/components/schemas/DownloadSchema";
Expand Down Expand Up @@ -171,6 +171,7 @@ export function SchemaDetails() {
);
} else {
const { bigInt, createdAt, hash, url, version } = schema.data;
const processedSchemaUrl = processUrl(url, env);
const [jsonSchema, jsonSchemaObject] = jsonSchemaTuple.data;
const [jsonLdType, jsonLdContextObject] = contextTuple.data;

Expand Down Expand Up @@ -204,7 +205,12 @@ export function SchemaDetails() {

<Detail copyable label="Hash" text={hash} />

<Detail copyable href={url} label="URL" text={url} />
<Detail
copyable
href={processedSchemaUrl.success ? processedSchemaUrl.data : url}
label="URL"
text={url}
/>

<Detail label="Import date" text={formatDate(createdAt)} />

Expand Down

0 comments on commit c29308b

Please sign in to comment.