diff --git a/packages/openneuro-app/src/scripts/datalad/dataset/dataset-query-fragments.js b/packages/openneuro-app/src/scripts/datalad/dataset/dataset-query-fragments.js index 7c64060fe..7d249c3f3 100644 --- a/packages/openneuro-app/src/scripts/datalad/dataset/dataset-query-fragments.js +++ b/packages/openneuro-app/src/scripts/datalad/dataset/dataset-query-fragments.js @@ -74,6 +74,8 @@ export const PERMISSION_FRAGMENT = gql` user { id email + orcid + name } level } diff --git a/packages/openneuro-app/src/scripts/datalad/mutations/remove-permissions.jsx b/packages/openneuro-app/src/scripts/datalad/mutations/remove-permissions.jsx deleted file mode 100644 index 705eb4c19..000000000 --- a/packages/openneuro-app/src/scripts/datalad/mutations/remove-permissions.jsx +++ /dev/null @@ -1,42 +0,0 @@ -import React from "react" -import PropTypes from "prop-types" -import { gql } from "@apollo/client" -import { Mutation } from "@apollo/client/react/components" -import WarnButton from "../../common/forms/warn-button.jsx" - -const REMOVE_PERMISSION = gql` - mutation removePermissions($datasetId: ID!, $userId: String!) { - removePermissions(datasetId: $datasetId, userId: $userId) - } -` - -/** - * Remove any permissions matching the user - * @param {object} userPermissions - * @param {string} userId - */ -export const userPermissionsFilter = (userPermissions, userId) => - userPermissions.filter((permission) => permission.user.id !== userId) - -const RemovePermissions = ({ datasetId, userId }) => ( - - {(removePermissions) => ( - { - await removePermissions({ variables: { datasetId, userId } }) - cb() - }} - /> - )} - -) - -RemovePermissions.propTypes = { - datasetId: PropTypes.string, - userId: PropTypes.string, -} - -export default RemovePermissions diff --git a/packages/openneuro-app/src/scripts/datalad/mutations/update-permissions.jsx b/packages/openneuro-app/src/scripts/datalad/mutations/update-permissions.jsx deleted file mode 100644 index 5e660e86d..000000000 --- a/packages/openneuro-app/src/scripts/datalad/mutations/update-permissions.jsx +++ /dev/null @@ -1,86 +0,0 @@ -import React from "react" -import PropTypes from "prop-types" -import { gql } from "@apollo/client" -import { Mutation } from "@apollo/client/react/components" -import { toast } from "react-toastify" -import ToastContent from "../../common/partials/toast-content.jsx" -import { validate as isValidEmail } from "email-validator" - -const UPDATE_PERMISSIONS = gql` - mutation updatePermissions( - $datasetId: ID! - $userEmail: String! - $level: String! - ) { - updatePermissions( - datasetId: $datasetId - userEmail: $userEmail - level: $level - ) { - id - email - } - } -` - -export const mergeNewPermission = ( - datasetId, - oldPermissions, - userInfo, - metadata, -) => { - return { - __typename: "Dataset", - id: datasetId, - permissions: { - ...oldPermissions, - userPermissions: [ - ...oldPermissions.userPermissions, - { - __typename: "Permission", - user: { __typename: "User", ...userInfo }, - level: metadata, - }, - ], - }, - } -} - -const UpdateDatasetPermissions = ({ datasetId, userEmail, metadata, done }) => ( - - {(UpdateDatasetPermissions) => ( - - )} - -) - -UpdateDatasetPermissions.propTypes = { - datasetId: PropTypes.string, - userEmail: PropTypes.string, - metadata: PropTypes.oneOf(["ro", "rw", "admin"]), - done: PropTypes.func, -} - -export default UpdateDatasetPermissions diff --git a/packages/openneuro-app/src/scripts/dataset/mutations/__tests__/__snapshots__/update-permissions.spec.jsx.snap b/packages/openneuro-app/src/scripts/dataset/mutations/__tests__/__snapshots__/update-permissions.spec.jsx.snap index a7e905e71..5c4f721d1 100644 --- a/packages/openneuro-app/src/scripts/dataset/mutations/__tests__/__snapshots__/update-permissions.spec.jsx.snap +++ b/packages/openneuro-app/src/scripts/dataset/mutations/__tests__/__snapshots__/update-permissions.spec.jsx.snap @@ -1,6 +1,19 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`UpdateDatasetPermissions mutation > renders with default props 1`] = ` +exports[`UpdateDatasetPermissions mutation > calls UPDATE_ORCID_PERMISSIONS when clicked with an ORCID 1`] = ` + + + +`; + +exports[`UpdateDatasetPermissions mutation > calls UPDATE_PERMISSIONS when clicked with an email address 1`] = `