Skip to content

Commit 659bfb2

Browse files
authored
Merge pull request #194 from kaleido-io/ns-query-update
use selected namespace in API calls
2 parents bfe0462 + 406253c commit 659bfb2

File tree

10 files changed

+44
-9
lines changed

10 files changed

+44
-9
lines changed

src/components/Accordions/DataViewerAccordion.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
AccordionSummary,
66
Grid,
77
} from '@mui/material';
8-
import { useState } from 'react';
8+
import { useContext, useState } from 'react';
9+
import { ApplicationContext } from '../../contexts/ApplicationContext';
910
import { IData } from '../../interfaces';
1011
import { DownloadButton } from '../Buttons/DownloadButton';
1112
import { DownloadJsonButton } from '../Buttons/DownloadJsonButton';
@@ -25,6 +26,7 @@ export const DataViewAccordion: React.FC<Props> = ({
2526
data,
2627
}) => {
2728
const [expanded, setExpanded] = useState<boolean>(isOpen);
29+
const { selectedNamespace } = useContext(ApplicationContext);
2830

2931
return (
3032
<Accordion
@@ -39,7 +41,12 @@ export const DataViewAccordion: React.FC<Props> = ({
3941
}
4042
rightContent={
4143
data.blob ? (
42-
<DownloadButton isBlob url={data.id} filename={data.blob.name} />
44+
<DownloadButton
45+
isBlob
46+
url={data.id}
47+
namespace={selectedNamespace}
48+
filename={data.blob.name}
49+
/>
4350
) : (
4451
<DownloadJsonButton
4552
jsonString={JSON.stringify(data.value)}

src/components/Accordions/MessageDataAccordion.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const MessageDataAccordion: React.FC<Props> = ({
7171
isBlob
7272
url={data.id}
7373
filename={data.blob.name}
74+
namespace={selectedNamespace}
7475
/>
7576
) : (
7677
<DownloadJsonButton

src/components/Buttons/DownloadButton.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ interface Props {
66
filename?: string;
77
isBlob: boolean;
88
url: string;
9+
namespace: string;
910
}
1011

11-
export const DownloadButton: React.FC<Props> = ({ filename, isBlob, url }) => {
12+
export const DownloadButton: React.FC<Props> = ({
13+
filename,
14+
isBlob,
15+
url,
16+
namespace,
17+
}) => {
1218
return (
1319
<IconButton
1420
onClick={(e) => {
1521
e.stopPropagation();
1622
isBlob
17-
? downloadBlobFile(url, filename)
23+
? downloadBlobFile(url, namespace, filename)
1824
: downloadExternalFile(url, filename);
1925
}}
2026
>

src/components/Lists/ApiList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const ApiList: React.FC<Props> = ({ api }) => {
6565
filename={api.name}
6666
url={api.urls.openapi}
6767
isBlob={false}
68+
namespace={selectedNamespace}
6869
/>
6970
<FFCopyButton value={api.urls.openapi} />
7071
</>

src/components/Slides/IdentitySlide.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { Grid } from '@mui/material';
1818
import React, { useContext, useEffect, useState } from 'react';
1919
import { useTranslation } from 'react-i18next';
20+
import { ApplicationContext } from '../../contexts/ApplicationContext';
2021
import { SnackbarContext } from '../../contexts/SnackbarContext';
2122
import { FF_Paths, IIdentity } from '../../interfaces';
2223
import { DEFAULT_PADDING } from '../../theme';
@@ -37,6 +38,7 @@ export const IdentitySlide: React.FC<Props> = ({ did, open, onClose }) => {
3738
const { reportFetchError } = useContext(SnackbarContext);
3839
const { t } = useTranslation();
3940
const [identity, setIdentity] = useState<IIdentity>();
41+
const { selectedNamespace } = useContext(ApplicationContext);
4042

4143
const [isMounted, setIsMounted] = useState(false);
4244
useEffect(() => {
@@ -49,7 +51,9 @@ export const IdentitySlide: React.FC<Props> = ({ did, open, onClose }) => {
4951
useEffect(() => {
5052
isMounted &&
5153
fetchCatcher(
52-
`${FF_Paths.apiPrefix}${FF_Paths.networkIdentitiesByDID(
54+
`${
55+
FF_Paths.nsPrefix
56+
}/${selectedNamespace}/${FF_Paths.networkIdentitiesByDID(
5357
did
5458
)}?fetchverifiers`
5559
)

src/pages/Blockchain/views/Apis.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export const BlockchainApis: () => JSX.Element = () => {
155155
filename={api.name}
156156
url={api.urls.openapi}
157157
isBlob={false}
158+
namespace={selectedNamespace}
158159
/>
159160
),
160161
},

src/pages/Blockchain/views/Dashboard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export const BlockchainDashboard: () => JSX.Element = () => {
247247
filename={api.name}
248248
url={api.urls.openapi}
249249
isBlob={false}
250+
namespace={selectedNamespace}
250251
/>
251252
),
252253
},

src/pages/Off-Chain/views/Dashboard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,12 @@ export const OffChainDashboard: () => JSX.Element = () => {
231231
},
232232
{
233233
value: data.blob ? (
234-
<DownloadButton isBlob url={data.id} filename={data.blob?.name} />
234+
<DownloadButton
235+
isBlob
236+
url={data.id}
237+
filename={data.blob?.name}
238+
namespace={selectedNamespace}
239+
/>
235240
) : (
236241
<FFTableText color="secondary" text={t('noBlobInData')} />
237242
),

src/pages/Off-Chain/views/Data.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ export const OffChainData: () => JSX.Element = () => {
159159
},
160160
{
161161
value: d.blob && (
162-
<DownloadButton isBlob url={d.id} filename={d.blob?.name} />
162+
<DownloadButton
163+
isBlob
164+
url={d.id}
165+
filename={d.blob?.name}
166+
namespace={selectedNamespace}
167+
/>
163168
),
164169
},
165170
],

src/utils/files.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { fetchWithCredentials } from './fetches';
22

3-
export const downloadBlobFile = async (id: string, filename?: string) => {
3+
export const downloadBlobFile = async (
4+
id: string,
5+
namespace: string,
6+
filename?: string
7+
) => {
48
const file = await fetchWithCredentials(
5-
`/api/v1/namespaces/default/data/${id}/blob`
9+
`/api/v1/namespaces/${namespace}/data/${id}/blob`
610
);
711
const blob = await file.blob();
812
const href = await URL.createObjectURL(blob);

0 commit comments

Comments
 (0)