diff --git a/client/src/boot/registerComponents.js b/client/src/boot/registerComponents.js index c3132f3..3b962c7 100644 --- a/client/src/boot/registerComponents.js +++ b/client/src/boot/registerComponents.js @@ -38,4 +38,3 @@ export default () => { SnapshotHistoryViewerCompareWarning: HistoryViewerCompareWarning, }, { force: true }); }; - diff --git a/client/src/components/HistoryViewer/HistoryViewer.js b/client/src/components/HistoryViewer/HistoryViewer.js index c7e729d..d157c72 100644 --- a/client/src/components/HistoryViewer/HistoryViewer.js +++ b/client/src/components/HistoryViewer/HistoryViewer.js @@ -458,7 +458,6 @@ HistoryViewer.defaultProps = { }, }; - function mapStateToProps(state) { const { currentPage, diff --git a/client/src/components/HistoryViewer/HistoryViewerSnapshot.js b/client/src/components/HistoryViewer/HistoryViewerSnapshot.js index b0fcee7..0e9f1ee 100644 --- a/client/src/components/HistoryViewer/HistoryViewerSnapshot.js +++ b/client/src/components/HistoryViewer/HistoryViewerSnapshot.js @@ -128,8 +128,8 @@ export default compose( inject( ['FormAction', 'SnapshotHistoryViewerSnapshotState'], (FormAction, HistoryViewerSnapshotState) => ({ - FormActionComponent: FormAction, - StateComponent: HistoryViewerSnapshotState, - }) + FormActionComponent: FormAction, + StateComponent: HistoryViewerSnapshotState, + }) ) )(HistoryViewerSnapshot); diff --git a/client/src/components/HistoryViewer/HistoryViewerSnapshotState.js b/client/src/components/HistoryViewer/HistoryViewerSnapshotState.js index 150130b..048a2a5 100644 --- a/client/src/components/HistoryViewer/HistoryViewerSnapshotState.js +++ b/client/src/components/HistoryViewer/HistoryViewerSnapshotState.js @@ -1,6 +1,6 @@ -import { Component as VersionedState } from './HistoryViewerVersionState'; import { inject } from 'lib/Injector'; import React from 'react'; +import { Component as VersionedState } from './HistoryViewerVersionState'; class HistoryViewerSnapshotState extends VersionedState { translateType(type) { diff --git a/client/src/components/HistoryViewer/HistoryViewerToolbar.js b/client/src/components/HistoryViewer/HistoryViewerToolbar.js index d6b0c57..53561a9 100644 --- a/client/src/components/HistoryViewer/HistoryViewerToolbar.js +++ b/client/src/components/HistoryViewer/HistoryViewerToolbar.js @@ -72,11 +72,11 @@ class HistoryViewerToolbar extends Component { icon="back-in-time" name="revert" attributes={{ - title: revertButtonTitle, - }} + title: revertButtonTitle, + }} data={{ - buttonStyle: 'warning' - }} + buttonStyle: 'warning' + }} disabled={isLatestVersion || isReverting || !canRollback} loading={isReverting} title={i18n._t('HistoryViewerToolbar.REVERT_TO_VERSION', 'Revert to this version')} @@ -91,11 +91,11 @@ class HistoryViewerToolbar extends Component { > {rollbackMessage} - )} + )} { isPreviewable && } - )} + )} ); } @@ -123,14 +123,13 @@ HistoryViewerToolbar.defaultProps = { canRollback: true, }; - function mapDispatchToProps(dispatch) { return { onAfterRevert(versionId) { dispatch(addMessage(i18n.sprintf( - i18n._t('HistoryViewerToolbar.REVERTED_MESSAGE', 'Successfully reverted to version %s'), - versionId - ))); + i18n._t('HistoryViewerToolbar.REVERTED_MESSAGE', 'Successfully reverted to version %s'), + versionId + ))); dispatch(showList()); }, }; diff --git a/client/src/components/HistoryViewer/HistoryViewerVersion.js b/client/src/components/HistoryViewer/HistoryViewerVersion.js index 4a72c7d..66e876f 100644 --- a/client/src/components/HistoryViewer/HistoryViewerVersion.js +++ b/client/src/components/HistoryViewer/HistoryViewerVersion.js @@ -195,6 +195,7 @@ class HistoryViewerVersion extends Component { ); } + render() { const { version, isActive, StateComponent } = this.props; const rowTitle = i18n._t('HistoryViewerVersion.GO_TO_VERSION', 'Go to version {version}'); diff --git a/client/src/components/HistoryViewer/HistoryViewerVersionList.js b/client/src/components/HistoryViewer/HistoryViewerVersionList.js index 353edf3..be9d2d6 100644 --- a/client/src/components/HistoryViewer/HistoryViewerVersionList.js +++ b/client/src/components/HistoryViewer/HistoryViewerVersionList.js @@ -43,12 +43,12 @@ class HistoryViewerVersionList extends PureComponent { * @returns {boolean} */ isVersionActive(version) { - const { currentVersion, compare, compare: { versionFrom, versionTo } } = this.props; - const isCurrent = currentVersion && currentVersion.id === version.id; - const isCompareFrom = versionFrom && versionFrom.id === version.id; - const isCompareTo = versionTo && versionTo.id === version.id; + const { currentVersion, compare, compare: { versionFrom, versionTo } } = this.props; + const isCurrent = currentVersion && currentVersion.id === version.id; + const isCompareFrom = versionFrom && versionFrom.id === version.id; + const isCompareTo = versionTo && versionTo.id === version.id; - return (!compare && isCurrent) || isCompareFrom || isCompareTo; + return (!compare && isCurrent) || isCompareFrom || isCompareTo; } /** diff --git a/client/src/components/HistoryViewer/HistoryViewerVersionState.js b/client/src/components/HistoryViewer/HistoryViewerVersionState.js index 950e94f..82d75b1 100644 --- a/client/src/components/HistoryViewer/HistoryViewerVersionState.js +++ b/client/src/components/HistoryViewer/HistoryViewerVersionState.js @@ -32,7 +32,6 @@ class HistoryViewerVersionState extends Component { return i18n._t('HistoryViewer.Saved', 'Saved'); } - /** * Return any status badges for the record * diff --git a/client/src/components/HistoryViewer/RollbackMutation.js b/client/src/components/HistoryViewer/RollbackMutation.js index 8ce9039..410c8de 100644 --- a/client/src/components/HistoryViewer/RollbackMutation.js +++ b/client/src/components/HistoryViewer/RollbackMutation.js @@ -3,12 +3,12 @@ import { Mutation } from 'react-apollo'; import createRollbackMutation from '../../graphql/createRollbackMutation'; const RollbackMutation = ({ typeName, children }) => { - const ROLLBACK = useMemo(() => createRollbackMutation(typeName), [typeName]); - return ( - - {children} - - ); + const ROLLBACK = useMemo(() => createRollbackMutation(typeName), [typeName]); + return ( + + {children} + + ); }; export default RollbackMutation; diff --git a/client/src/components/HistoryViewer/SnapshotViewerContainer.js b/client/src/components/HistoryViewer/SnapshotViewerContainer.js index eb21d7d..15fb07b 100644 --- a/client/src/components/HistoryViewer/SnapshotViewerContainer.js +++ b/client/src/components/HistoryViewer/SnapshotViewerContainer.js @@ -16,59 +16,59 @@ const SnapshotViewerContainer = ({ }, SnapshotViewerComponent, }) => { - const QUERY = useMemo( - () => createSnapshotsQuery(typeName, isPreviewable), - [typeName, isPreviewable] - ); + const QUERY = useMemo( + () => createSnapshotsQuery(typeName, isPreviewable), + [typeName, isPreviewable] + ); - const variables = { - limit, - offset: ((page || 1) - 1) * limit, - page_id: recordId, - }; - return ( - - {({ loading, error, data, refetch }) => { - let readOne = null; - if (data) { - readOne = data[`readOne${typeName}`]; - } - const versions = readOne || {}; + const variables = { + limit, + offset: ((page || 1) - 1) * limit, + page_id: recordId, + }; + return ( + + {({ loading, error, data, refetch }) => { + let readOne = null; + if (data) { + readOne = data[`readOne${typeName}`]; + } + const versions = readOne || {}; - const errors = error && error.graphQLErrors && + const errors = error && error.graphQLErrors && error.graphQLErrors.map((graphQLError) => graphQLError.message); - const props = { - loading, - versions, - graphQLErrors: errors, - actions: { - ...actions, - versions: { - ...versions, - // eslint-disable-next-line no-shadow - goToPage(page) { - refetch({ - offset: ((page || 1) - 1) * limit, - limit, - page_id: recordId, - }); - } - }, - }, - recordId, - recordClass, - typeName, - limit, - page, - }; + const props = { + loading, + versions, + graphQLErrors: errors, + actions: { + ...actions, + versions: { + ...versions, + // eslint-disable-next-line no-shadow + goToPage(page) { + refetch({ + offset: ((page || 1) - 1) * limit, + limit, + page_id: recordId, + }); + } + }, + }, + recordId, + recordClass, + typeName, + limit, + page, + }; - return ( - - ); - }} - - ); + return ( + + ); + }} + + ); }; SnapshotViewerContainer.propTypes = { @@ -82,9 +82,9 @@ SnapshotViewerContainer.propTypes = { }; export default inject( - ['SnapshotViewer'], - (SnapshotViewerComponent) => ({ - SnapshotViewerComponent, - }), - ({ contextKey }) => `VersionedAdmin.HistoryViewer.${contextKey}` + ['SnapshotViewer'], + (SnapshotViewerComponent) => ({ + SnapshotViewerComponent, + }), + ({ contextKey }) => `VersionedAdmin.HistoryViewer.${contextKey}` )(SnapshotViewerContainer); diff --git a/client/src/components/HistoryViewer/tests/HistoryViewer-test.js b/client/src/components/HistoryViewer/tests/HistoryViewer-test.js index 72d4b7f..8612f51 100644 --- a/client/src/components/HistoryViewer/tests/HistoryViewer-test.js +++ b/client/src/components/HistoryViewer/tests/HistoryViewer-test.js @@ -2,9 +2,9 @@ /* global jest, describe, it, expect */ import React from 'react'; -import { Component as HistoryViewer } from '../HistoryViewer'; import Enzyme, { shallow } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16/build/index'; +import { Component as HistoryViewer } from '../HistoryViewer'; Enzyme.configure({ adapter: new Adapter() }); @@ -105,9 +105,9 @@ describe('HistoryViewer', () => { page={1} compare={false} currentVersion={{ - version: 123, - latestDraftVersion: true - }} + version: 123, + latestDraftVersion: true + }} />); expect(wrapper.instance().getLatestVersion().version).toEqual(123); @@ -202,8 +202,8 @@ describe('HistoryViewer', () => { page={2} versions={versions} currentVersion={{ - ID: 1, - }} + ID: 1, + }} compare={false} />); @@ -222,13 +222,13 @@ describe('HistoryViewer', () => { page={2} versions={versions} currentVersion={{ - ID: 1, - }} + ID: 1, + }} compare={{ - versionFrom: { - ID: 1, - }, - }} + versionFrom: { + ID: 1, + }, + }} />); expect(wrapper.instance().isListView()).toBe(true); @@ -246,16 +246,16 @@ describe('HistoryViewer', () => { page={2} versions={versions} currentVersion={{ - ID: 1 - }} + ID: 1 + }} compare={{ - versionFrom: { - ID: 1, - }, - versionTo: { - ID: 2, - }, - }} + versionFrom: { + ID: 1, + }, + versionTo: { + ID: 2, + }, + }} />); expect(wrapper.instance().isListView()).toBe(false); @@ -290,13 +290,13 @@ describe('HistoryViewer', () => { limit={1} page={2} versions={{ - Versions: { - pageInfo: { totalCount: 1 }, - edges: [ - { node: { Version: 14 } }, - ], - } - }} + Versions: { + pageInfo: { totalCount: 1 }, + edges: [ + { node: { Version: 14 } }, + ], + } + }} />); expect(wrapper.instance().compareModeAvailable()).toBe(false); diff --git a/client/src/components/HistoryViewer/tests/HistoryViewerHeading-test.js b/client/src/components/HistoryViewer/tests/HistoryViewerHeading-test.js index 09d39db..a7981fe 100644 --- a/client/src/components/HistoryViewer/tests/HistoryViewerHeading-test.js +++ b/client/src/components/HistoryViewer/tests/HistoryViewerHeading-test.js @@ -2,9 +2,9 @@ /* global jest, describe, it, expect */ import React from 'react'; -import { Component as HistoryViewerHeading } from '../HistoryViewerHeading'; import Enzyme, { shallow } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16/build/index'; +import { Component as HistoryViewerHeading } from '../HistoryViewerHeading'; Enzyme.configure({ adapter: new Adapter() }); @@ -37,4 +37,3 @@ describe('HistoryViewerHeading', () => { }); }); }); - diff --git a/client/src/components/HistoryViewer/tests/HistoryViewerVersion-test.js b/client/src/components/HistoryViewer/tests/HistoryViewerVersion-test.js index 368056f..d6d18d2 100644 --- a/client/src/components/HistoryViewer/tests/HistoryViewerVersion-test.js +++ b/client/src/components/HistoryViewer/tests/HistoryViewerVersion-test.js @@ -2,9 +2,9 @@ /* global jest, describe, it, expect */ import React from 'react'; -import { Component as HistoryViewerVersion } from '../HistoryViewerVersion'; import Enzyme, { shallow } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16/build/index'; +import { Component as HistoryViewerVersion } from '../HistoryViewerVersion'; Enzyme.configure({ adapter: new Adapter() }); @@ -64,9 +64,9 @@ describe('HistoryViewerVersion', () => { it.skip('returns the publisher name when published', () => { const wrapper = shallow(); @@ -132,9 +132,9 @@ describe('HistoryViewerVersion', () => { onSelect={mockOnSelect} onCompareSelect={mockOnCompareSelect} compare={{ - versionFrom: { version: 0 }, - versionTo: { version: 0 }, - }} + versionFrom: { version: 0 }, + versionTo: { version: 0 }, + }} />); wrapper.instance().handleClick(); @@ -193,9 +193,9 @@ describe('HistoryViewerVersion', () => { onCompareSelect={mockOnCompareSelect} isActive compare={{ - versionFrom: { version: 0 }, - versionTo: { version: 0 }, - }} + versionFrom: { version: 0 }, + versionTo: { version: 0 }, + }} />); wrapper.instance().handleClose(); diff --git a/client/src/components/HistoryViewer/tests/HistoryViewerVersionState-test.js b/client/src/components/HistoryViewer/tests/HistoryViewerVersionState-test.js index c887a3b..ece567b 100644 --- a/client/src/components/HistoryViewer/tests/HistoryViewerVersionState-test.js +++ b/client/src/components/HistoryViewer/tests/HistoryViewerVersionState-test.js @@ -25,7 +25,7 @@ describe('HistoryViewerVersionState', () => { }; component = ReactTestUtils - .renderIntoDocument(); + .renderIntoDocument(); expect(component.getPublishedState()).toBe('Published'); }); diff --git a/client/src/state/historyviewer/HistoryViewerActions.js b/client/src/state/historyviewer/HistoryViewerActions.js index 9359e6d..e4e9112 100644 --- a/client/src/state/historyviewer/HistoryViewerActions.js +++ b/client/src/state/historyviewer/HistoryViewerActions.js @@ -1,5 +1,5 @@ -import HISTORY_VIEWER from './HistoryViewerActionTypes'; import uuidv1 from 'uuid/v1'; +import HISTORY_VIEWER from './HistoryViewerActionTypes'; /** * Show the provided version in the viewer, i.e. a detail or comparison view diff --git a/client/src/state/historyviewer/HistoryViewerReducer.js b/client/src/state/historyviewer/HistoryViewerReducer.js index 7b9a81d..819f825 100644 --- a/client/src/state/historyviewer/HistoryViewerReducer.js +++ b/client/src/state/historyviewer/HistoryViewerReducer.js @@ -1,6 +1,6 @@ -import HISTORY_VIEWER from './HistoryViewerActionTypes'; import { defaultCompare } from 'types/compareType'; import { VERSION_MODE_VERSION, VERSION_MODE_DATE } from 'components/HistoryViewer/HistoryViewer'; +import HISTORY_VIEWER from './HistoryViewerActionTypes'; const initialState = { currentPage: 1,