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

Commit 1e52e0f

Browse files
committed
Open tagged resource in drawer if self contains tag/rev
Signed-off-by: Dinika Saxena <dinikasaxenas@gmail.com>
1 parent dab565f commit 1e52e0f

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

.github/workflows/review.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
run: docker build . --tag=nexus-web:fresh
146146

147147
- name: Start services
148-
run: docker-compose -f ci/docker-compose.yml up -d && sleep 60
148+
run: docker compose -f ci/docker-compose.yml up -d && sleep 60
149149

150150
- name: Copy nexus-web into Cypress container
151151
run: docker cp ./. cypress:/e2e
@@ -165,4 +165,4 @@ jobs:
165165
166166
- name: Cleanup Docker Containers
167167
if: ${{ always() }}
168-
run: docker-compose -f ci/docker-compose.yml down --rmi "local" --volumes
168+
run: docker compose -f ci/docker-compose.yml down --rmi "local" --volumes

src/pages/StudiosPage/StudiosPage.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('StudiosPage', () => {
5555
const studios = await screen.getAllByRole('routeitem-studio');
5656
expect(studios.length).not.toBe(10);
5757
// const pageTitleExtra = await screen.findAllByText('Total of 19 Projects')
58-
// expect(pageTitleExtra).toBeInTheDocument();
58+
// expect(pageTitleExtra).toBeInTheDocument()
5959
});
6060
});
6161
});

src/shared/containers/DataTableContainer.spec.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ describe('DataTableContainer - Row Click', () => {
442442
let component: RenderResult;
443443
let nexus: ReturnType<typeof createNexusClient>;
444444
let nexusSpy: jest.SpyInstance;
445+
let historySpy: jest.SpyInstance;
445446

446447
beforeAll(() => {
447448
server = setupServer(
@@ -495,6 +496,7 @@ describe('DataTableContainer - Row Click', () => {
495496
? Promise.resolve([getMockResource('doesnt-matter', {}, 'agents')])
496497
: Promise.resolve(getMockResource('doesnt-matter', {}, 'agents'))
497498
);
499+
historySpy = vitest.spyOn(history, 'push');
498500
});
499501

500502
// reset any request handlers that are declared as a part of our tests
@@ -504,6 +506,7 @@ describe('DataTableContainer - Row Click', () => {
504506
queryClient.clear();
505507
localStorage.clear();
506508
nexusSpy.mockClear();
509+
historySpy.mockClear();
507510
});
508511

509512
afterAll(() => {
@@ -538,6 +541,8 @@ describe('DataTableContainer - Row Click', () => {
538541
path: `${selfWithRevision}&format=expanded`,
539542
headers: { Accept: 'application/json' },
540543
});
544+
const navigateTo = historySpy.mock.calls[0][0];
545+
expect(navigateTo).toContain('rev=30');
541546
});
542547

543548
it('requests correct resource from delta when user clicks on row with tag in self', async () => {
@@ -555,11 +560,13 @@ describe('DataTableContainer - Row Click', () => {
555560
path: `${selfWithTag}&format=expanded`,
556561
headers: { Accept: 'application/json' },
557562
});
563+
const navigateTo = historySpy.mock.calls[0][0];
564+
expect(navigateTo).toContain('tag=30');
558565
});
559566

560567
it('requests correct resource from delta when user clicks on row with tag and revision in self', async () => {
561568
const selfWithTagAndRev =
562-
'https://localhost:3000/resources/bbp/agents/_/persons%2Fc3358e61-7650-4954-99b7-f7572cbf5d5g?tag=30&rev=2-';
569+
'https://localhost:3000/resources/bbp/agents/_/persons%2Fc3358e61-7650-4954-99b7-f7572cbf5d5g?tag=30&rev=20';
563570

564571
const resources = [getMockStudioResource('Malory', `${selfWithTagAndRev}`)];
565572

@@ -572,6 +579,8 @@ describe('DataTableContainer - Row Click', () => {
572579
path: `${selfWithTagAndRev}&format=expanded`,
573580
headers: { Accept: 'application/json' },
574581
});
582+
const navigateTo = historySpy.mock.calls[0][0];
583+
expect(navigateTo).toContain('rev=20');
575584
});
576585

577586
it('requests correct resource from delta when user clicks on row with no tag or revision in self', async () => {
@@ -591,6 +600,9 @@ describe('DataTableContainer - Row Click', () => {
591600
path: `${selfWithoutTagOrRev}?format=expanded`,
592601
headers: { Accept: 'application/json' },
593602
});
603+
const navigateTo = historySpy.mock.calls[0][0];
604+
expect(navigateTo).not.toContain('rev');
605+
expect(navigateTo).not.toContain('tag');
594606
});
595607
});
596608

src/shared/containers/DataTableContainer.tsx

+18-5
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,32 @@ const DataTableContainer: React.FC<DataTableProps> = ({
219219
if (resource['@type'] === 'Project') {
220220
return;
221221
}
222-
const url = new URL(selfUrl);
223-
url.searchParams.set('format', 'expanded');
222+
const resourceUrl = new URL(selfUrl);
223+
resourceUrl.searchParams.set('format', 'expanded');
224+
224225
nexus
225226
.httpGet({
226-
path: `${url.toString()}`,
227+
path: `${resourceUrl.toString()}`,
227228
headers: { Accept: 'application/json' },
228229
})
229230
.then((fullIdResponse: Resource) => {
230231
const [orgLabel, projectLabel] = parseProjectUrl(resource._project);
231-
const hist = `/${orgLabel}/${projectLabel}/resources/${encodeURIComponent(
232+
let fullResourceId = `/${orgLabel}/${projectLabel}/resources/${encodeURIComponent(
232233
fullIdResponse[0]['@id']
233234
)}`;
234-
history.push(hist, { background: location });
235+
236+
const revision = resourceUrl.searchParams.get('rev');
237+
const tag = resourceUrl.searchParams.get('tag');
238+
239+
if (revision) {
240+
fullResourceId = `${fullResourceId}?rev=${revision}`;
241+
} else if (tag) {
242+
fullResourceId = `${fullResourceId}?tag=${tag}`;
243+
}
244+
245+
history.push(`${fullResourceId.toString()}`, {
246+
background: location,
247+
});
235248
});
236249
})
237250
.catch(() => {

0 commit comments

Comments
 (0)