mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-06-29 07:59:37 +02:00
e3237f9638
* NEW Add revert mutation and refactor injector transformations Removing the existing HOC component and just using Injector transformations to apply the GraphQL query and mutation * Refetch versions after performing the revert mutation * WIP Provide additional context
45 lines
903 B
JavaScript
45 lines
903 B
JavaScript
import { graphql } from 'react-apollo';
|
|
import gql from 'graphql-tag';
|
|
|
|
const mutation = gql`
|
|
mutation revertPageToVersion($id:ID!, $fromStage:VersionedStage!, $toStage:VersionedStage!, $fromVersion:Int!) {
|
|
copySilverStripeSiteTreeToStage(Input: {
|
|
ID: $id
|
|
FromVersion: $fromVersion
|
|
FromStage: $fromStage
|
|
ToStage: $toStage
|
|
}) {
|
|
ID
|
|
}
|
|
}
|
|
|
|
`;
|
|
|
|
const config = {
|
|
props: ({ mutate, ownProps: { actions } }) => {
|
|
const revertToVersion = (id, fromVersion, fromStage, toStage) => mutate({
|
|
variables: {
|
|
id,
|
|
fromVersion,
|
|
fromStage,
|
|
toStage,
|
|
},
|
|
});
|
|
|
|
return {
|
|
actions: {
|
|
...actions,
|
|
revertToVersion,
|
|
},
|
|
};
|
|
},
|
|
options: {
|
|
// Refetch versions after mutation is completed
|
|
refetchQueries: ['ReadHistoryViewerPage']
|
|
}
|
|
};
|
|
|
|
export { mutation, config };
|
|
|
|
export default graphql(mutation, config);
|