Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMT-3907: Fixed Attempting to Update a Collection Permission ACL With Collection From a Different Provider Silently Ignores the User Request #1303

Merged
merged 22 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions static/src/js/components/CollectionSelector/CollectionSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import { useLazyQuery, useSuspenseQuery } from '@apollo/client'

import { GET_PERMISSION_COLLECTIONS } from '@/js/operations/queries/getPermissionCollections'

import Button from '../Button/Button'
import For from '../For/For'
import useAppContext from '@/js/hooks/useAppContext'
cgokey marked this conversation as resolved.
Show resolved Hide resolved
import Button from '@/js/components/Button/Button'
import For from '@/js/components/For/For'

import './CollectionSelector.scss'

Expand All @@ -55,10 +56,12 @@ const CollectionSelector = ({ onChange, formData }) => {
const [highlightedSelected, setHighlightedSelected] = useState({})

const [loading, setLoading] = useState(false)
const { providerId } = useAppContext()

const { data: collectionList } = useSuspenseQuery(GET_PERMISSION_COLLECTIONS, {
variables: {
params: {
provider: providerId,
limit: 100
}
}
Expand All @@ -74,11 +77,17 @@ const CollectionSelector = ({ onChange, formData }) => {
}), {})

const [selectedItems, setSelectedItems] = useState({})
const [availableItems, setAvailableItems] = useState(availableCollections)
const [availableItems, setAvailableItems] = useState([])

useEffect(() => {
setAvailableItems(availableCollections)
}, [providerId])

useEffect(() => {
if (!isEmpty(formData)) {
setSelectedItems(formData)
} else {
setSelectedItems({})
}
}, [formData])

Expand Down Expand Up @@ -191,6 +200,7 @@ const CollectionSelector = ({ onChange, formData }) => {
pattern: true
}
},
provider: providerId,
shortName: `${inputValue}*`,
limit: 100
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import userEvent from '@testing-library/user-event'

import { GET_PERMISSION_COLLECTIONS } from '@/js/operations/queries/getPermissionCollections'

import CollectionSelector from '../CollectionSelector'
import AppContext from '@/js/context/AppContext'
cgokey marked this conversation as resolved.
Show resolved Hide resolved
import CollectionSelector from '@/js/components/CollectionSelector/CollectionSelector'

const setup = ({
additionalMocks = [],
Expand All @@ -25,58 +26,66 @@ const setup = ({
}

render(
<MockedProvider mocks={
[{
request: {
query: GET_PERMISSION_COLLECTIONS,
variables: {
params: {
limit: 100
}
}
},
result: {
data: {
collections: {
items: [
{
conceptId: 'C1200444618-MMT_2',
directDistributionInformation: {
region: 'us-east-2',
s3BucketAndObjectPrefixNames: [
's3://example1',
's3://example2',
'prefix_bucket/*'
],
s3CredentialsApiEndpoint: 'https://example.org',
s3CredentialsApiDocumentationUrl: 'https://example.org'
},
shortName: 'Collection 1',
provider: 'MMT_2',
entryTitle: 'Mock title of collection 1',
__typename: 'Collection'
},
{
conceptId: 'C1200482349-MMT_2',
directDistributionInformation: null,
shortName: 'Collection 2',
<AppContext.Provider value={
{
providerId: 'MMT_2'
}
}
>
<MockedProvider mocks={
[
{
request: {
query: GET_PERMISSION_COLLECTIONS,
variables: {
params: {
provider: 'MMT_2',
entryTitle: 'Mock title of collection 2',
__typename: 'Collection'
limit: 100
}
],
__typename: 'CollectionList'
}
},
result: {
data: {
collections: {
items: [
{
conceptId: 'C1200444618-MMT_2',
directDistributionInformation: {
region: 'us-east-2',
s3BucketAndObjectPrefixNames: [
's3://example1',
's3://example2',
'prefix_bucket/*'
],
s3CredentialsApiEndpoint: 'https://example.org',
s3CredentialsApiDocumentationUrl: 'https://example.org'
},
shortName: 'Collection 1',
provider: 'MMT_2',
entryTitle: 'Mock title of collection 1',
__typename: 'Collection'
},
{
conceptId: 'C1200482349-MMT_2',
directDistributionInformation: null,
shortName: 'Collection 2',
provider: 'MMT_2',
entryTitle: 'Mock title of collection 2',
__typename: 'Collection'
}
],
__typename: 'CollectionList'
}
}
}
}
}
}, ...additionalMocks]
}
>
<Suspense>
<CollectionSelector {...props} />
</Suspense>
</MockedProvider>

}, ...additionalMocks]
}
>
<Suspense>
<CollectionSelector {...props} />
</Suspense>
</MockedProvider>
</AppContext.Provider>
)

return {
Expand Down Expand Up @@ -232,6 +241,7 @@ describe('CollectionSelector', () => {
variables: {
params: {
options: { shortName: { pattern: true } },
provider: 'MMT_2',
shortName: 'C*',
limit: 100
}
Expand Down
2 changes: 1 addition & 1 deletion static/src/js/components/Layout/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const Layout = ({ className, displayNav }) => {
naked
Icon={FaUserAlt}
>
{`${user.name} `}
{`${user?.name} `}
cgokey marked this conversation as resolved.
Show resolved Hide resolved
</Dropdown.Toggle>

<Dropdown.Menu
Expand Down
Loading