Skip to content

Commit

Permalink
oaipmh: update admin list view
Browse files Browse the repository at this point in the history
* display spec with <pre> tag
* displays value with Formatter cmp
* closes inveniosoftware/invenio-administration#94
* closes inveniosoftware/invenio-administration#105
  • Loading branch information
jrcastro2 committed Sep 26, 2022
1 parent d81ae06 commit e7e9d95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Actions } from "@js/invenio_administration/src/actions/Actions.js";
import { AdminUIRoutes } from "@js/invenio_administration/src/routes.js";
import { OverridableContext } from "react-overridable";
import { DeleteModal } from "./DeleteModal";
import Formatter from "@js/invenio_administration/src/components/Formatter";

const overridenComponents = {
"DeleteModal.layout": DeleteModal,
Expand All @@ -31,6 +32,29 @@ class SearchResultItemComponent extends Component {
return result.system_created;
};

displayAsPre = (result, property) => {
const { resourceSchema } = this.props;
if (property === "spec") {
return (
<pre>
<Formatter
result={result}
resourceSchema={resourceSchema}
property={property}
/>
</pre>
);
} else {
return (
<Formatter
result={result}
resourceSchema={resourceSchema}
property={property}
/>
);
}
};

render() {
const {
title,
Expand Down Expand Up @@ -61,10 +85,10 @@ class SearchResultItemComponent extends Component {
idKeyPath
)}
>
{_get(result, property)}
{this.displayAsPre(result, property)}
</a>
) : (
_get(result, property)
this.displayAsPre(result, property)
)}
</Table.Cell>
);
Expand Down Expand Up @@ -106,6 +130,7 @@ SearchResultItemComponent.propTypes = {
currentQueryState: PropTypes.object.isRequired,
idKeyPath: PropTypes.string.isRequired,
listUIEndpoint: PropTypes.string.isRequired,
resourceSchema: PropTypes.object.isRequired,
};

SearchResultItemComponent.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { NotificationController } from "@js/invenio_administration/src/ui_messag
const domContainer = document.getElementById("invenio-search-config");

const sortColumns = (columns) =>
Object.entries(columns).sort((a, b) => a[1].order > b[1].order);
Object.entries(columns).sort((a, b) => a[1].order - b[1].order);
const title = JSON.parse(domContainer.dataset.title);
const resourceName = JSON.parse(domContainer.dataset.resourceName);
const columns = JSON.parse(domContainer.dataset.fields);
Expand All @@ -26,6 +26,7 @@ const actions = JSON.parse(domContainer.dataset.actions);
const apiEndpoint = _get(domContainer.dataset, "apiEndpoint");
const idKeyPath = JSON.parse(_get(domContainer.dataset, "pidPath", "pid"));
const listUIEndpoint = domContainer.dataset.listEndpoint;
const resourceSchema = JSON.parse(domContainer.dataset.resourceSchema);

const SearchResultItemWithConfig = parametrize(SearchResultItem, {
title: title,
Expand All @@ -38,6 +39,7 @@ const SearchResultItemWithConfig = parametrize(SearchResultItem, {
apiEndpoint: apiEndpoint,
idKeyPath: idKeyPath,
listUIEndpoint: listUIEndpoint,
resourceSchema: resourceSchema,
});

const overridenComponents = {
Expand Down

0 comments on commit e7e9d95

Please sign in to comment.