Skip to content

Commit

Permalink
API Standardise endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jul 26, 2024
1 parent cfb57e7 commit ce2f753
Show file tree
Hide file tree
Showing 6 changed files with 16,294 additions and 9 deletions.
15,962 changes: 15,961 additions & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

259 changes: 258 additions & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 35 additions & 4 deletions client/src/components/HistoryViewer/HistoryViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Griddle from 'griddle-react';
import historyViewerConfig from 'containers/HistoryViewer/HistoryViewerConfig';
import i18n from 'i18n';
import { inject } from 'lib/Injector';
import backend from 'lib/Backend';
import Loading from 'components/Loading/Loading';
import {
setCurrentPage,
Expand All @@ -20,6 +21,8 @@ import ResizeAware from 'components/ResizeAware/ResizeAware';
import * as viewModeActions from 'state/viewMode/ViewModeActions';
import PropTypes from 'prop-types';

const useRPC = true;

/**
* The HistoryViewer component is abstract, and requires an Injector component
* to be connected providing the GraphQL query implementation for the appropriate
Expand All @@ -29,9 +32,20 @@ class HistoryViewer extends Component {
constructor(props) {
super(props);

console.log('contextKey=', this.props.contextKey);

this.handleSetPage = this.handleSetPage.bind(this);
this.handleNextPage = this.handleNextPage.bind(this);
this.handlePrevPage = this.handlePrevPage.bind(this);
this.refreshVersions = this.refreshVersions.bind(this);

this.state = {
versions: [],
};
}

componentDidMount() {
this.refreshVersions();
}

/**
Expand Down Expand Up @@ -65,16 +79,33 @@ class HistoryViewer extends Component {
}
}

refreshVersions() {
if (useRPC) {
// TODO: hardcoded
const url = `/admin/pages/history/api/readHistory/${this.props.recordId}?recordClass=Page`;
backend.get(url)
.then(response => response.json())
.then(responseJson => {
this.setState({ versions: responseJson.versions });
});
} else {
const { versions } = this.props;
const nodes = (versions && versions.versions && versions.versions.nodes)
? versions.versions.nodes
: [];
this.setState({ versions: nodes });
}
}

/**
* Returns the result of the GraphQL version history query
*
* TODO get rid of this method just get state directly
*
* @returns {Array}
*/
getVersions() {
const { versions } = this.props;
return (versions && versions.versions && versions.versions.nodes)
? versions.versions.nodes
: [];
return this.state.versions;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions client/src/legacy/HistoryViewer/HistoryViewerEntwine.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jQuery.entwine('ss', ($) => {
? { context: cmsContent }
: {};

console.log('entwine context=', context);

const HistoryViewerComponent = loadComponent('HistoryViewer', context);
const schemaData = this.data('schema');

Expand Down
Loading

0 comments on commit ce2f753

Please sign in to comment.