Skip to content

Commit

Permalink
API Remove GraphQL
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Aug 19, 2024
1 parent 19b5fa3 commit 05c7a18
Show file tree
Hide file tree
Showing 53 changed files with 1,735 additions and 1,803 deletions.
10 changes: 0 additions & 10 deletions _config/graphql.yml

This file was deleted.

5 changes: 0 additions & 5 deletions _graphql/config.yml

This file was deleted.

41 changes: 0 additions & 41 deletions _graphql/models.yml

This file was deleted.

9 changes: 0 additions & 9 deletions _graphql/mutations.yml

This file was deleted.

4 changes: 0 additions & 4 deletions _graphql/scalars.yml

This file was deleted.

110 changes: 1 addition & 109 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

47 changes: 4 additions & 43 deletions client/src/boot/registerTransforms.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Injector from 'lib/Injector';
import readOneBlockQuery from 'state/history/readOneBlockQuery';
import HistoricElementViewFactory from 'components/HistoricElementView/HistoricElementView';
import revertToBlockVersionMutation from 'state/history/revertToBlockVersionMutation';
import readBlocksForAreaQuery from 'state/editor/readBlocksForAreaQuery';
import addElementToArea from 'state/editor/addElementMutation';
import revertToBlockVersionRequest from 'state/history/revertToBlockVersionRequest';
import ArchiveAction from 'components/ElementActions/ArchiveAction';
import DuplicateAction from 'components/ElementActions/DuplicateAction';
import SaveAction from 'components/ElementActions/SaveAction';
Expand All @@ -25,50 +22,14 @@ export default () => {
}
);

Injector.transform(
'elements-history',
(updater) => {
// Add content block history to the HistoryViewer
updater.component(
'HistoryViewer.Form_ItemEditForm',
readOneBlockQuery,
'ElementHistoryViewer'
);
}
);

Injector.transform(
'blocks-history-revert',
(updater) => {
// Add block element revert GraphQL mutation to the HistoryViewerToolbar
// Add revertToVersion() to props.actions on HistoryViewerToolbar
updater.component(
'HistoryViewerToolbar.VersionedAdmin.HistoryViewer.Element.HistoryViewerVersionDetail',
revertToBlockVersionMutation,
'BlockRevertMutation'
);
}
);

Injector.transform(
'cms-element-editor',
(updater) => {
// Add GraphQL query for reading elements on a page for the ElementEditor
updater.component(
'ElementList',
readBlocksForAreaQuery,
'PageElements'
);
}
);

Injector.transform(
'cms-element-adder',
(updater) => {
// Add GraphQL query for adding elements to an ElementEditor (ElementalArea)
updater.component(
'AddElementPopover',
addElementToArea,
'ElementAddButton'
revertToBlockVersionRequest,
'BlockRevertRequest'
);
}
);
Expand Down
33 changes: 17 additions & 16 deletions client/src/components/ElementActions/ArchiveAction.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
/* global window */
import React from 'react';
import { compose } from 'redux';
import React, { useContext } from 'react';
import AbstractAction from 'components/ElementActions/AbstractAction';
import archiveBlockMutation from 'state/editor/archiveBlockMutation';
import i18n from 'i18n';
import { ElementEditorContext } from 'components/ElementEditor/ElementEditor';
import backend from 'lib/Backend';
import Config from 'lib/Config';
import { getConfig } from 'state/editor/elementConfig';

/**
* Adds the elemental menu action to archive a block of any state
*/
const ArchiveAction = (MenuComponent) => (props) => {
const { fetchElements } = useContext(ElementEditorContext);

const handleClick = (event) => {
event.stopPropagation();

const { element: { id }, isPublished, actions: { handleArchiveBlock } } = props;

const isPublished = props.element.isPublished;
let archiveMessage = i18n._t(
'ElementArchiveAction.CONFIRM_DELETE',
'Are you sure you want to send this block to the archive?'
);

if (isPublished) {
archiveMessage = i18n._t(
'ElementArchiveAction.CONFIRM_DELETE_AND_UNPUBLISH',
'Warning: This block will be unpublished before being sent to the archive. Are you sure you want to proceed?'
);
}

// eslint-disable-next-line no-alert
if (handleArchiveBlock && window.confirm(archiveMessage)) {
handleArchiveBlock(id).then(() => {
const preview = window.jQuery('.cms-preview');
if (preview && typeof preview.entwine === 'function') {
preview.entwine('ss.preview')._loadUrl(preview.find('iframe').attr('src'));
}
});
if (!window.confirm(archiveMessage)) {
return;
}
const id = props.element.id;
const url = `${getConfig().controllerLink.replace(/\/$/, '')}/api/archive/${id}`;
backend.delete(url, {}, {
'X-SecurityID': Config.get('SecurityID')
})
.then(() => fetchElements());
};

const disabled = props.element.canDelete !== undefined && !props.element.canDelete;
Expand All @@ -61,4 +62,4 @@ const ArchiveAction = (MenuComponent) => (props) => {

export { ArchiveAction as Component };

export default compose(archiveBlockMutation, ArchiveAction);
export default ArchiveAction;
29 changes: 16 additions & 13 deletions client/src/components/ElementActions/DuplicateAction.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
/* global window */
import React from 'react';
import { compose } from 'redux';
import React, { useContext } from 'react';
import AbstractAction from 'components/ElementActions/AbstractAction';
import duplicateBlockMutation from 'state/editor/duplicateBlockMutation';
import i18n from 'i18n';
import { ElementEditorContext } from 'components/ElementEditor/ElementEditor';
import backend from 'lib/Backend';
import Config from 'lib/Config';
import { getConfig } from 'state/editor/elementConfig';

/**
* Adds the elemental menu action to duplicate a block
*/
const DuplicateAction = (MenuComponent) => (props) => {
const { fetchElements } = useContext(ElementEditorContext);

if (props.type.broken) {
// Don't allow this action for a broken element.
return (
Expand All @@ -18,15 +22,14 @@ const DuplicateAction = (MenuComponent) => (props) => {

const handleClick = (event) => {
event.stopPropagation();

const { element: { id }, actions: { handleDuplicateBlock } } = props;

if (handleDuplicateBlock) {
handleDuplicateBlock(id).then(() => {
const preview = window.jQuery('.cms-preview');
preview.entwine('ss.preview')._loadUrl(preview.find('iframe').attr('src'));
});
}
const id = props.element.id;
const url = `${getConfig().controllerLink.replace(/\/$/, '')}/api/duplicate`;
backend.post(url, {
id,
}, {
'X-SecurityID': Config.get('SecurityID')
})
.then(() => fetchElements());
};

const disabled = props.element.canCreate !== undefined && !props.element.canCreate;
Expand All @@ -53,4 +56,4 @@ const DuplicateAction = (MenuComponent) => (props) => {

export { DuplicateAction as Component };

export default compose(duplicateBlockMutation, DuplicateAction);
export default DuplicateAction;
87 changes: 42 additions & 45 deletions client/src/components/ElementActions/UnpublishAction.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,63 @@
/* global window */
import React from 'react';
import { compose } from 'redux';
import React, { useContext } from 'react';
import AbstractAction from 'components/ElementActions/AbstractAction';
import unpublishBlockMutation from 'state/editor/unpublishBlockMutation';
import i18n from 'i18n';
import backend from 'lib/Backend';
import { ElementEditorContext } from 'components/ElementEditor/ElementEditor';
import Config from 'lib/Config';
import { getConfig } from 'state/editor/elementConfig';

/**
* Adds the elemental menu action to unpublish a published block
*/
const UnpublishAction = (MenuComponent) => (props) => {
const { fetchElements } = useContext(ElementEditorContext);

if (props.type.broken) {
// Don't allow this action for a broken element.
return (
<MenuComponent {...props} />
);
}

const { element, type, actions: { handleUnpublishBlock } } = props;

const handleClick = (event) => {
event.stopPropagation();
const { jQuery: $ } = window;
const reportUnpublicationStatus = (type, title, success) => {
const noTitle = i18n.inject(
i18n._t(
'ElementHeader.NOTITLE',
'Untitled {type} block'
),
{ type: type.title }
i18n._t('ElementHeader.NOTITLE', 'Untitled {type} block'),
{ type }
);
const successMessage = i18n.inject(
i18n._t('ElementUnpublishAction.SUCCESS_NOTIFICATION', 'Removed \'{title}\' from the published page'),
{ title: title || noTitle }
);
const errorMessage = i18n.inject(
i18n._t('ElementUnpublishAction.ERROR_NOTIFICATION', 'Error unpublishing \'{title}\''),
{ title: title || noTitle }
);
window.jQuery.noticeAdd({
text: success ? successMessage : errorMessage,
stay: false,
type: success ? 'success' : 'error',
});
};

const unpublishElement = () => {
const id = props.element.id;
const url = `${getConfig().controllerLink.replace(/\/$/, '')}/api/unpublish`;
return backend.post(url, {
id,
}, {
'X-SecurityID': Config.get('SecurityID')
})
.then(() => fetchElements());
};

if (handleUnpublishBlock) {
handleUnpublishBlock(element.id)
.then(() => {
const preview = $('.cms-preview');
preview.entwine('ss.preview')._loadUrl(preview.find('iframe').attr('src'));
const { element, type } = props;

$.noticeAdd({
text: i18n.inject(
i18n._t(
'ElementUnpublishAction.SUCCESS_NOTIFICATION',
'Removed \'{title}\' from the published page'
),
{ title: element.title || noTitle }
),
stay: false,
type: 'success'
});
})
.catch(() => {
$.noticeAdd({
text: i18n.inject(
i18n._t(
'ElementUnpublishAction.ERROR_NOTIFICATION',
'Error unpublishing \'{title}\''
),
{ title: element.title || noTitle }
),
stay: false,
type: 'error'
});
});
}
const handleClick = (event) => {
event.stopPropagation();
unpublishElement()
.then(() => reportUnpublicationStatus(type.title, element.title, true))
.catch(() => reportUnpublicationStatus(type.title, element.title, false));
};

const disabled = props.element.canUnpublish !== undefined && !props.element.canUnpublish;
Expand All @@ -87,4 +84,4 @@ const UnpublishAction = (MenuComponent) => (props) => {

export { UnpublishAction as Component };

export default compose(unpublishBlockMutation, UnpublishAction);
export default UnpublishAction;
Loading

0 comments on commit 05c7a18

Please sign in to comment.