Skip to content

Commit 20bc113

Browse files
committed
MMT-4089: Addressing PR Feedback
1 parent 79ee029 commit 20bc113

File tree

4 files changed

+48
-31
lines changed

4 files changed

+48
-31
lines changed

static/src/js/components/CollectionAssociationForm/CollectionAssociationForm.jsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const CollectionAssociationForm = () => {
150150
// Validate ummMetadata
151151
const { errors: validationErrors } = validator.validateFormData(searchFormData, schema)
152152

153-
// Query to retrieve collections
153+
// Query to retrieve collections after 'Search for Collection' button click
154154
const [
155155
getCollections,
156156
{
@@ -166,6 +166,7 @@ const CollectionAssociationForm = () => {
166166
}
167167
})
168168

169+
// Query to retrieve concept after 'Search for Collection' button click
169170
const [
170171
getConcept,
171172
{
@@ -286,14 +287,6 @@ const CollectionAssociationForm = () => {
286287
if (derivedConceptType === conceptIdTypes.O) {
287288
navigate(`/order-options/${conceptId}`)
288289
} else {
289-
getConcept({
290-
variables: {
291-
params: {
292-
conceptId
293-
}
294-
}
295-
})
296-
297290
navigate(`/${pluralize(camelCase(derivedConceptType)).toLowerCase()}/${conceptId}/collection-association`)
298291
}
299292

static/src/js/components/ManageCollectionAssociation/ManageCollectionAssociation.jsx

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { Col, Row } from 'react-bootstrap'
1+
import {
2+
Alert,
3+
Col,
4+
Row
5+
} from 'react-bootstrap'
26
import { camelCase } from 'lodash-es'
37
import { useMutation, useSuspenseQuery } from '@apollo/client'
48
import { useParams } from 'react-router'
@@ -78,13 +82,7 @@ const ManageCollectionAssociation = () => {
7882
})
7983

8084
const [deleteAssociationMutation] = useMutation(DELETE_ASSOCIATION, {
81-
refetchQueries: [
82-
{
83-
query: conceptTypeQueries[derivedConceptType],
84-
variables: params
85-
}
86-
],
87-
awaitRefetchQueries: true,
85+
8886
onCompleted: () => {
8987
setShowDeleteModal(false)
9088

@@ -95,8 +93,11 @@ const ManageCollectionAssociation = () => {
9593
})
9694

9795
setCollectionConceptIds([])
98-
console.log('refetching in onComplete in ManageCollectionAssociation....')
99-
refetch()
96+
97+
// Gives time for CMR to update data
98+
setTimeout(() => {
99+
refetch()
100+
}, 250)
100101
},
101102
onError: () => {
102103
setShowDeleteModal(false)
@@ -222,10 +223,31 @@ const ManageCollectionAssociation = () => {
222223

223224
const { collections: associatedCollections } = concept
224225

225-
const { items = [], count } = associatedCollections
226+
const { items, count } = associatedCollections
226227

227228
return (
228229
<div>
230+
<Alert className="fst-italic fs-6" variant="warning">
231+
<i className="eui-icon eui-fa-info-circle" />
232+
{' '}
233+
Association operations may take some time. If you are not seeing what you expect below,
234+
please
235+
{' '}
236+
<button
237+
className="btn btn-link p-0 text-decoration-underline"
238+
style={
239+
{
240+
color: 'blue',
241+
cursor: 'pointer'
242+
}
243+
}
244+
onClick={() => refetch()}
245+
aria-label="Refresh the page"
246+
type="button"
247+
>
248+
<i>refresh the page</i>
249+
</button>
250+
</Alert>
229251
<ControlledPaginatedContent
230252
activePage={activePage}
231253
count={count}

static/src/js/components/ManageCollectionAssociation/__tests__/ManageCollectionAssociation.test.jsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
} from 'react-router'
1212
import { MockedProvider } from '@apollo/client/testing'
1313
import userEvent from '@testing-library/user-event'
14-
import * as router from 'react-router'
1514
import { InMemoryCache, defaultDataIdFromObject } from '@apollo/client'
1615

1716
import NotificationsContext from '@/js/context/NotificationsContext'
@@ -254,19 +253,23 @@ describe('ManageCollectionAssociation', () => {
254253
})
255254
})
256255

257-
describe('when clicking on Add Collection Associations button', () => {
258-
test.skip('should navigate to collection-search', async () => {
259-
const navigateSpy = vi.fn()
260-
vi.spyOn(router, 'useNavigate').mockImplementation(() => navigateSpy)
256+
describe('when clicking on refresh button', () => {
257+
test('should refetch the data', async () => {
258+
const { user } = setup({
259+
overrideMocks: [toolRecordSearch, deletedAssociationResponse]
260+
})
261261

262-
const { user } = setup({})
262+
await screen.findByText('Showing 2 Collection Associations')
263263

264-
const addCollectionAssociationButton = await screen.findByRole('button', { name: 'Add Collection Associations' })
264+
const refreshButton = screen.getByRole('button', { name: /refresh the page/i })
265+
expect(refreshButton).toBeInTheDocument()
265266

266-
await user.click(addCollectionAssociationButton)
267+
await user.click(refreshButton)
267268

268-
expect(navigateSpy).toHaveBeenCalledWith('/tools/T1200000-TEST/collection-association-search')
269-
expect(navigateSpy).toHaveBeenCalledTimes(1)
269+
// Check to see that data has been refetched
270+
await waitFor(() => {
271+
expect(screen.getByText('Showing 1 Collection Association')).toBeInTheDocument()
272+
})
270273
})
271274
})
272275

static/src/js/components/Table/Table.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
th:first-child,
5555
td:first-child {
5656
position: sticky;
57-
z-index: 1000;
5857
left: 0;
5958
max-width: 20rem;
6059
}

0 commit comments

Comments
 (0)