-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MMT-3494: As a user, I can edit a published record (#1113)
* MMT-3494: Added support for Editing a publish record * MMT-3494: Added test cases for edit button * MMT-3494: Moved ingestMutation in a hook * MMT-3494: Removed one comment * MMT-3494: Added loading when the user clicks publish btn * MMT-3494: Addressed PR comments
- Loading branch information
Showing
8 changed files
with
166 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useMutation } from '@apollo/client' | ||
import pluralize from 'pluralize' | ||
import { useNavigate } from 'react-router' | ||
import { INGEST_DRAFT } from '../operations/mutations/ingestDraft' | ||
import getUmmVersion from '../utils/getUmmVersion' | ||
import errorLogger from '../utils/errorLogger' | ||
import useNotificationsContext from './useNotificationsContext' | ||
|
||
const useIngestDraftMutation = () => { | ||
const [ingestDraftMutation] = useMutation(INGEST_DRAFT) | ||
|
||
const navigate = useNavigate() | ||
|
||
const { addNotification } = useNotificationsContext() | ||
|
||
const ingestMutation = (conceptType, metadata, nativeId, providerId) => { | ||
ingestDraftMutation({ | ||
variables: { | ||
conceptType, | ||
metadata, | ||
nativeId, | ||
providerId, | ||
ummVersion: getUmmVersion(conceptType) | ||
}, | ||
onCompleted: (getDraftData) => { | ||
const { ingestDraft } = getDraftData | ||
const { conceptId } = ingestDraft | ||
navigate(`/drafts/${pluralize(conceptType).toLowerCase()}/${conceptId}`) | ||
addNotification({ | ||
message: 'Draft created successfully', | ||
variant: 'success' | ||
}) | ||
}, | ||
onError: (getMutationError) => { | ||
// Send the error to the errorLogger | ||
errorLogger(getMutationError, 'PublishPreview ingestDraftMutation Query') | ||
addNotification({ | ||
message: 'Error creating draft', | ||
variant: 'danger' | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
return ingestMutation | ||
} | ||
|
||
export default useIngestDraftMutation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ export const GET_COLLECTION = gql` | |
url | ||
} | ||
} | ||
ummMetadata | ||
useConstraints | ||
variables { | ||
count | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters