Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global: react-searchkit integration #76

Merged
merged 12 commits into from
May 15, 2020

Conversation

kpsherva
Copy link
Contributor

@kpsherva kpsherva commented May 8, 2020

Screenshot 2020-05-13 at 16 06 40

@kpsherva kpsherva force-pushed the searchkit-integration branch from af2666b to a7be4eb Compare May 8, 2020 14:25
@kpsherva kpsherva self-assigned this May 8, 2020
@kpsherva kpsherva changed the title global: react-searchkit integration [BLOCKED] global: react-searchkit integration May 11, 2020
import { Results } from "./Results";
import { InvenioSearchApi } from "react-searchkit";

import "semantic-ui-css/semantic.min.css";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this will have to be removed when integrated in the global Invenio theme

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I'm waiting for the theme to be available to remove that


render() {

const config = new InvenioSearchApi({
Copy link
Contributor

@ntarocco ntarocco May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that this should be configurable too. What about if you have:

const searchApi = this.props.searchApi || new InvenioSearchApi(...)

this should be possible for all the params that can be passed to the RSK, for at least most of them, see [https://inveniosoftware.github.io/react-searchkit/docs/components/react-searchkit] (I am not sure that the doc there is up-to-date).
How to inject that JS inside... something to be brainstormed! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<Grid.Row columns={2}>
<Grid.Column width={4}>
<Grid.Row><Grid.Column/></Grid.Row>
<BucketAggregation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use RECORDS_REST_FACETS to render these buckets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks for noticing this


const OnResults = withState(Results);

const resultsPerPageValues = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be also configurable, depending on the default that the user sets in RECORDS_REST_DEFAULT_RESULTS_SIZE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this component in the end, as the variable allows only one option

<Item.Content>
<Item.Header>{metadata.title}</Item.Header>
<Item.Description>
{_truncate(metadata.keywords.join(","), { length: 200 })}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lnielsen in invenio-search-ui we had a marc21 folder with some fields displayed. What would be a sensible default here to display records? I guess it is for sure overridden in cookiecutter-invenio-instance, but what should we have here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything related to marc21 can be removed.

Something like record.title + record.description

<Grid relaxed>
<Grid.Row>
<Grid.Column width={16}>
<ActiveFilters />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, I would remove this one in the default invenio-search-ui

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

}
}

Results.propTypes = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure that at some point (probably later?) you fill in all propTypes and defaultProps :)

@kpsherva kpsherva force-pushed the searchkit-integration branch 3 times, most recently from 31e4b1c to a502595 Compare May 12, 2020 16:03
renderResultsListItem = (result, index) => {
const metadata = result.metadata;
return (
<Item key={index} href={_get(result, "links.html", "#")}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I solved the link like this: inveniosoftware/cookiecutter-invenio-instance#226
(also removed truncate and change style... do we actually need lodash)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the solution for the links.html under your link. Could you explain in more details, which line do you mean?

<Grid.Row verticalAlign="middle">
<Grid.Column width={7}>
<Count
renderElement={this.renderCount}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be aware render element has disappeared in the next version of RSK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember, actually I could just remove it

@kpsherva kpsherva force-pushed the searchkit-integration branch from ca96b7e to 981323b Compare May 13, 2020 13:01
setup.py Outdated Show resolved Hide resolved
themes={
'semantic-ui': dict(
entry={
'search_ui_app': './js/invenio_react_search_ui/index.js',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'search_ui_app': './js/invenio_react_search_ui/index.js',
'search_ui_app': './js/invenio_search_ui/react/index.js',

I would do the namespacing like suggested (<module name>/react/) or simply just use without react part.

Ditto for below on the angular app. -> invenio_search_ui/angular/app.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

config_default_sort = config.get('RECORDS_REST_DEFAULT_SORT', {}).get(
search_index)

return json.dumps({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Use the Jinja filter |tojson instead. It's not a big issue since there's no user-provided data, but tojson does proper escaping to prevent XSS attacks, so that the JSON can safely be included in HTML script tags.

I can see this is an inherited problem from the module :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -10,6 +10,8 @@

from __future__ import absolute_import, print_function

APP_THEME = ['semantic-ui', 'bootstrap3']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: I guess this is also just for testing?

Copy link
Contributor Author

@kpsherva kpsherva May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it until I'm sure where this should go, cookiecutter right? Also I'm still not 100% sure if the js framework should be "hidden" under themes= names

@kpsherva kpsherva force-pushed the searchkit-integration branch 3 times, most recently from 3590535 to a5aca8f Compare May 13, 2020 14:08
@kpsherva kpsherva force-pushed the searchkit-integration branch from 6f0253d to 9e332c7 Compare May 13, 2020 16:38
@ntarocco
Copy link
Contributor

There are issues when integrating with cookiecutter with the id of the header and React portals, we will need to fix it tomorrow.

@ntarocco ntarocco linked an issue May 14, 2020 that may be closed by this pull request
@ntarocco ntarocco changed the title [BLOCKED] global: react-searchkit integration global: react-searchkit integration May 14, 2020
@lnielsen lnielsen assigned lnielsen and unassigned kpsherva May 15, 2020
@lnielsen lnielsen force-pushed the searchkit-integration branch from b210ebd to 9bb42a7 Compare May 15, 2020 05:57
@lnielsen lnielsen force-pushed the searchkit-integration branch from 9bb42a7 to 2fecd7a Compare May 15, 2020 05:58
@lnielsen lnielsen merged commit 2fecd7a into inveniosoftware:master May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add search bar outside the react-searchkit app Integrate React-SearchKit
3 participants