Skip to content

Commit

Permalink
literatureSearch: add snv messages box
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 committed Oct 19, 2023
1 parent 116e9dc commit d9acbde
Show file tree
Hide file tree
Showing 12 changed files with 7,042 additions and 11,272 deletions.
8 changes: 8 additions & 0 deletions ui/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ module.exports = {
mode: 'file',
},
webpack: {
configure: webpackConfig => {
const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
({ constructor }) => constructor && constructor.name === 'ModuleScopePlugin' // Needed to skip the check of preventing from importing from outside of src/ and node_modules/ directory.
);

webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);
return webpackConfig;
},
alias: {
// aliases for all peer dependencies to avoid double libraries
'@babel/runtime': path.resolve('./node_modules/@babel/runtime'),
Expand Down
18,145 changes: 6,902 additions & 11,243 deletions ui/package-lock.json

Large diffs are not rendered by default.

16 changes: 4 additions & 12 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,10 @@
"semantic-ui-react": "^2.1.1"
},
"devDependencies": {
"@craco/craco": "^5.9.0",
"@inveniosoftware/eslint-config-invenio": "^1.0.11",
"@semantic-ui-react/craco-less": "^1.2.1",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-flowtype": "^4.0.0",
"eslint-plugin-react": "^7.22.0",
"prettier": "^1.19.1",
"react-scripts": "^3.4.1"
"@craco/craco": "^7.0.0",
"@inveniosoftware/eslint-config-invenio": "^2.0.0",
"@semantic-ui-react/craco-less": "3.0.0",
"react-scripts": "^5.0.0"
},
"scripts": {
"start": "HOST=127.0.0.1 HTTPS=true craco start",
Expand Down
5 changes: 1 addition & 4 deletions ui/src/importer/ImporterList.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ export class ImporterList extends Component {
if (endTime) {
const t0 = DateTime.fromISO(row["start_time"]);
const t1 = DateTime.fromISO(row[col.field]);
const duration = t0
.until(t1)
.toDuration()
.shiftTo("hours", "minutes", "seconds");
const duration = t0.until(t1).toDuration().shiftTo("hours", "minutes", "seconds");
const parts = [];
if (duration.hours > 0) {
parts.push(duration.hours, `hour${duration.hours !== 1 ? "s" : ""}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from "prop-types";
export const RenderStatistics = ({ statistics, selectedResult, applyFilter }) => {
return (
<Statistic.Group widths="seven" size="small">
{Object.keys(statistics).map(function(statisticKey, index) {
{Object.keys(statistics).map(function (statisticKey, index) {
return (
<Statistic
className={
Expand Down
2 changes: 2 additions & 0 deletions ui/src/overridableMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { StandardCardView } from "./overridden/frontsite/DocumentSearch/Standard
import { LiteratureKeyword } from "./overridden/frontsite/Document/DocumentDetails/DocumentCirculation/LiteratureKeyword";
import { Identifiers } from "./overridden/frontsite/Document/DocumentDetails/DocumentMetadataTabs/Identifiers";
import { DocumentConference } from "./overridden/frontsite/Document/DocumentDetails/DocumentMetadataTabs/DocumentConference";
import { DocumentItemsHeader } from "./overridden/frontsite/Document/DocumentDetails/DocumentItemsHeader";

export const overriddenCmps = {
"Backoffice.PatronDetails.Metadata": PatronMetadata,
Expand All @@ -48,4 +49,5 @@ export const overriddenCmps = {
"LiteratureKeywords.layout": LiteratureKeyword,
"DocumentMetadataTabs.Identifiers": Identifiers,
"DocumentConference.layout": DocumentConference,
"DocumentDetails.DocumentItems.header": DocumentItemsHeader,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";
import { Divider, Message } from "semantic-ui-react";
import { Link } from "react-router-dom";
import PropTypes from "prop-types";

export const DocumentItemsHeader = ({ document }) => {
const snvLink = (
<Link
href="https://sis.web.cern.ch/search-and-read/online-resources/snv-connect"
taget="_blank"
>
SNV-Connect
</Link>
);
return document.metadata.document_type === "STANDARD" ? (
<>
<Divider horizontal>Where to find</Divider>
<Message attached="top" className="warning center">
<Message.Content>
For standards, please directly search on {snvLink}. Please contact
[email protected] in case you cannot find what you are looking for.
</Message.Content>
</Message>
</>
) : (
""
);
};

DocumentItemsHeader.propTypes = {
document: PropTypes.object.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ export const SUCCESS = "fetchIdentifiers/SUCCESS";
export const HAS_ERROR = "fetchIdentifiers/HAS_ERROR";

const createQueryPromise = (type) => {
const query = vocabularyApi
.query()
.withType(type)
.qs();
const query = vocabularyApi.query().withType(type).qs();

return vocabularyApi.list(query);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { LiteratureSearch } from "@inveniosoftware/react-invenio-app-ils";
import { StandardListView } from "../DocumentSearch/StandardListView";
import { StandardCardView } from "../DocumentSearch/StandardCardView";
import { SearchMessageContent } from "./SearchMessageContent";
import { SearchResultExtra } from "./SearchResultExtra";
import { SearchResultHeader } from "./SearchResultHeader";

export const overriddenSearchAppCmps = parametrize(LiteratureSearch, {
overriddenSearchAppCmps: {
"DocumentListEntry.BeforeAuthors": StandardListView,
"DocumentCard.AfterAuthors": StandardCardView,
"SearchMessage.content": SearchMessageContent,
"SearchResults.NoResults.extra": SearchResultExtra,
"LiteratureSearch.results.header": SearchResultHeader,
},
});
44 changes: 44 additions & 0 deletions ui/src/overridden/frontsite/LiteratureSearch/SearchResultExtra.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from "react";
import { Message, List } from "semantic-ui-react";
import { FrontSiteRoutes } from "@inveniosoftware/react-invenio-app-ils";
import { Link } from "react-router-dom";
import Qs from "qs";

export const SearchResultExtra = () => {
const onClickBookRequestLink = () => {
const params = Qs.parse(window.location.search);
const queryString = params["?q"];
return {
pathname: FrontSiteRoutes.documentRequestForm,
state: { queryString },
};
};

const snvLink = (
<Link
href="https://sis.web.cern.ch/search-and-read/online-resources/snv-connect"
taget="_blank"
>
SNV-Connect
</Link>
);
const requestFormLink = (
<Link className="primary" to={onClickBookRequestLink()}>
request form
</Link>
);
return (
<Message.Content>
<Message.Header>
Couldn't find the literature you were looking for?
</Message.Header>
<List className="mt-5">
<List.Item>For standards, please directly search on {snvLink}.</List.Item>
<List.Item>
Please fill in {requestFormLink} to request new additions or purchases to the
catalogue. (Login required)
</List.Item>
</List>
</Message.Content>
);
};
35 changes: 35 additions & 0 deletions ui/src/overridden/frontsite/LiteratureSearch/SearchResultHeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from "react";
import { Message } from "semantic-ui-react";
import { Link } from "react-router-dom";
import { withState } from "react-searchkit";
import PropTypes from "prop-types";

const SearchResultHeaderCmp = ({ currentQueryState }) => {
const snvLink = (
<Link
href="https://sis.web.cern.ch/search-and-read/online-resources/snv-connect"
taget="_blank"
>
SNV-Connect
</Link>
);

const filters = currentQueryState.filters;

console.log("test", currentQueryState);
return filters.some((item) => item.includes("STANDARD")) ? (
<Message attached="top" className="warning center">
<Message.Content>
For standards, please directly search on {snvLink}.
</Message.Content>
</Message>
) : (
""
);
};

SearchResultHeaderCmp.propTypes = {
currentQueryState: PropTypes.object.isRequired,
};

export const SearchResultHeader = withState(SearchResultHeaderCmp);
16 changes: 8 additions & 8 deletions ui/src/reducers.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { injectAsyncReducer, ILSStore } from "@inveniosoftware/react-invenio-app-ils";

const jsonModalViewReducer = require("./importer/JsonViewModal/reducer")
.jsonModalViewReducer;
const seriesDetailsModalViewReducer = require("./importer/SeriesImportDetailsModal/reducer")
.seriesDetailsModalViewReducer;
const eitemDetailsModalViewReducer = require("./importer/EitemImportDetailsModal/reducer")
.eitemDetailsModalViewReducer;
const jsonModalViewReducer =
require("./importer/JsonViewModal/reducer").jsonModalViewReducer;
const seriesDetailsModalViewReducer =
require("./importer/SeriesImportDetailsModal/reducer").seriesDetailsModalViewReducer;
const eitemDetailsModalViewReducer =
require("./importer/EitemImportDetailsModal/reducer").eitemDetailsModalViewReducer;

const vocabularyIdentifiersReducer = require("./overridden/frontsite/Document/DocumentDetails/DocumentMetadataTabs/Identifiers/reducer")
.vocabularyIdentifiersReducer;
const vocabularyIdentifiersReducer =
require("./overridden/frontsite/Document/DocumentDetails/DocumentMetadataTabs/Identifiers/reducer").vocabularyIdentifiersReducer;

export function initialiseReducers() {
injectAsyncReducer(ILSStore, "jsonModal", jsonModalViewReducer);
Expand Down

0 comments on commit d9acbde

Please sign in to comment.