-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds deletion of queries from workspace
- Loading branch information
1 parent
6ffd68b
commit 8ce95f7
Showing
6 changed files
with
65 additions
and
10 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as useCreateQuery } from './use-create-query' | ||
export { default as useDeleteQuery } from './use-delete-query' | ||
export { default as useSaveQuery } from './use-save-query' | ||
export { default as useSaveWorkspace } from './use-save-workspace' |
25 changes: 25 additions & 0 deletions
25
src/main/webapp/components/workspace/hooks/use-delete-query.tsx
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,25 @@ | ||
import { useMutation } from '@apollo/react-hooks' | ||
import gql from 'graphql-tag' | ||
|
||
export default (onDelete: any) => { | ||
const mutation = gql` | ||
mutation DeleteQuery($id: ID!) { | ||
deleteMetacard(id: $id) | ||
} | ||
` | ||
|
||
const [_delete] = useMutation(mutation, { | ||
onCompleted: data => { | ||
onDelete(data.deleteMetacard) | ||
}, | ||
}) | ||
|
||
return (id: string) => { | ||
_delete({ | ||
variables: { | ||
id, | ||
}, | ||
optimisticResponse: { deleteMetacard: id }, | ||
}) | ||
} | ||
} |
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