Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 188d55b

Browse files
committed
Remove double-encoding of resource id in revisions and copy buttons
1 parent e6a6813 commit 188d55b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/shared/containers/ResourceViewActionsContainer.tsx

+17-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const ResourceViewActionsContainer: React.FC<{
4545
orgLabel: string;
4646
projectLabel: string;
4747
}> = ({ resource, orgLabel, projectLabel, latestResource, isLatest }) => {
48-
const encodedResourceId = encodeURIComponent(resource['@id']);
4948
const nexus = useNexusContext();
5049
const history = useHistory();
5150
const location = useLocation();
@@ -131,6 +130,7 @@ const ResourceViewActionsContainer: React.FC<{
131130
const [view, setView] = React.useState<Resource | null>(null);
132131
const subapp = useOrganisationsSubappContext();
133132
React.useEffect(() => {
133+
const encodedResourceId = encodeURIComponent(resource['@id']);
134134
nexus.Resource.tags(orgLabel, projectLabel, encodedResourceId).then(
135135
data => {
136136
setTags(data);
@@ -194,7 +194,7 @@ const ResourceViewActionsContainer: React.FC<{
194194
<Menu.Item
195195
key={rev}
196196
onClick={() => {
197-
goToResource(orgLabel, projectLabel, encodedResourceId, rev);
197+
goToResource(orgLabel, projectLabel, resource['@id'], rev);
198198
}}
199199
>
200200
Revision {rev}
@@ -305,7 +305,7 @@ const ResourceViewActionsContainer: React.FC<{
305305
{
306306
orgLabel,
307307
projectLabel,
308-
resourceId: encodedResourceId,
308+
resourceId: resource['@id'],
309309
}
310310
)}`;
311311

@@ -324,13 +324,14 @@ const ResourceViewActionsContainer: React.FC<{
324324
overlay={
325325
<Menu>
326326
<Menu.Item
327+
key="fusion-url"
327328
onClick={() => {
328329
const pathToResource = `${basePath}${generatePath(
329330
'/:orgLabel/:projectLabel/resources/:resourceId',
330331
{
331332
orgLabel,
332333
projectLabel,
333-
resourceId: encodedResourceId,
334+
resourceId: resource['@id'],
334335
}
335336
)}`;
336337

@@ -342,13 +343,14 @@ const ResourceViewActionsContainer: React.FC<{
342343
Fusion URL
343344
</Menu.Item>
344345
<Menu.Item
346+
key="fusion-url-(with-revision)"
345347
onClick={() => {
346348
const pathToResource = `${basePath}${generatePath(
347349
'/:orgLabel/:projectLabel/resources/:resourceId',
348350
{
349351
orgLabel,
350352
projectLabel,
351-
resourceId: encodedResourceId,
353+
resourceId: resource['@id'],
352354
}
353355
)}`;
354356

@@ -361,20 +363,28 @@ const ResourceViewActionsContainer: React.FC<{
361363
>
362364
Fusion URL (with revision)
363365
</Menu.Item>
364-
<Menu.Item onClick={() => triggerCopy(resource['@id'])}>
366+
<Menu.Item
367+
onClick={() => triggerCopy(resource['@id'])}
368+
key="resource-id"
369+
>
365370
Resource ID
366371
</Menu.Item>
367372
<Menu.Item
373+
key="resource-id-with-revision"
368374
onClick={() =>
369375
triggerCopy(`${resource['@id']}?rev=${resource._rev}`)
370376
}
371377
>
372378
Resource ID (with revision)
373379
</Menu.Item>
374-
<Menu.Item onClick={() => triggerCopy(self ? self : '')}>
380+
<Menu.Item
381+
onClick={() => triggerCopy(self ? self : '')}
382+
key="nexus-api-endpoint"
383+
>
375384
Nexus API endpoint
376385
</Menu.Item>
377386
<Menu.Item
387+
key="nexus-api-endpoitn-with-revision"
378388
onClick={() =>
379389
triggerCopy(
380390
self

0 commit comments

Comments
 (0)