Skip to content

Commit

Permalink
fix(dashboard): Fixed broken dashboard works search
Browse files Browse the repository at this point in the history
  • Loading branch information
monotasker committed Jan 10, 2025
1 parent d9b7d53 commit 47f0928
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Knowledge Commons Works is a collaborative tool for storing and sharing academic research. It is part of Knowledge Commons and is built on an instance of the InvenioRDM repository system.

Version 0.3.4-beta7
Version 0.3.5-beta8

## Copyright

Expand Down
6 changes: 6 additions & 0 deletions assets/js/invenio_app_rdm/overridableRegistry/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { PublisherField } from "./fields/PublisherField";
import { RDMRecordMultipleSearchBarElement } from "./search/RDMRecordMultipleSearchBarElement";
import RecordsResultsListItem from "./search/RecordsResultsListItem";
import { RecordResultsListItemDashboard } from "./search/RecordsResultsListItemDashboard";
import { RecordSearchBarElement } from "./search/RecordSearchBarElement";
import { RequestMetadata } from "./requests/RequestMetadata";
import { RequestsResultsItemTemplateDashboard } from "./user_dashboard/RequestsResultsItemTemplateDashboard";
import { RequestsResultsItemTemplateWithCommunity } from "./collections/members/requests/RequestsResultsItemTemplate";
Expand All @@ -54,6 +55,10 @@ const MobileActionMenu = () => {
);
};

const DashboardSearchBarElementWithConfig = parametrize(RecordSearchBarElement, {
placeholder: "Search my works...",
});

const SearchAppLayoutWithConfig = parametrize(SearchAppLayout, {
appName: "InvenioAppRdm.Search",
});
Expand Down Expand Up @@ -89,6 +94,7 @@ export const overriddenComponents = {
"InvenioAppRdm.DashboardRequests.SearchApp.layout": DashboardRequestsSearchLayoutWithApp,
"InvenioAppRdm.DashboardRequests.ResultsList.item": RequestsResultsItemTemplateDashboard,
"InvenioAppRdm.DashboardUploads.SearchApp.layout": DashboardUploadsSearchLayout,
"InvenioAppRdm.DashboardUploads.SearchBar.element": DashboardSearchBarElementWithConfig,
"InvenioAppRdm.DashboardUploads.ResultsList.item": RecordResultsListItemDashboard,
"InvenioAppRdm.Deposit.AccessRightField.container": AccessRightField,
"InvenioAppRdm.Deposit.CreatorsField.container": CreatibutorsField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {i18next} from "@translations/invenio_app_rdm/i18next";
import { RecordSearchBarElement } from "./RecordSearchBarElement";
import _isEmpty from "lodash/isEmpty";

// Note: This search bar element is necessary for the unique
// needs of the main works search page.
export const RDMRecordMultipleSearchBarElement = ({ queryString, onInputChange }) => {
const headerSearchbar = document.getElementById("header-search-bar");
const searchbarOptions = JSON.parse(headerSearchbar.dataset.options);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@

import { i18next } from "@translations/invenio_communities/i18next";
import PropTypes from "prop-types";
import React from "react";
import React, { useState } from "react";
import { withState } from "react-searchkit";
import { Input } from "semantic-ui-react";


export const RecordSearchBarElement = withState(
({
placeholder: passedPlaceholder,
queryString,
onInputChange,
// onInputChange,
updateQueryState,
currentQueryState,
uiProps
}) => {
const placeholder = passedPlaceholder || i18next.t("Search");
const [currentValue, setCurrentValue] = useState(queryString || currentQueryState.queryString || "");

const onInputChange = (value) => {
setCurrentValue(value);
};

const onSearch = () => {
updateQueryState({ ...currentQueryState, queryString });
updateQueryState({ ...currentQueryState, queryString: currentValue });
};

const onBtnSearchClick = () => {
Expand All @@ -28,6 +33,7 @@ export const RecordSearchBarElement = withState(
onSearch();
}
};

return (
<Input
action={{
Expand All @@ -41,9 +47,18 @@ export const RecordSearchBarElement = withState(
onChange={(event, { value }) => {
onInputChange(value);
}}
value={queryString}
value={currentValue}
onKeyPress={onKeyPress}
{...uiProps}
/>
);
}
);

RecordSearchBarElement.propTypes = {
placeholder: PropTypes.string,
queryString: PropTypes.string,
onInputChange: PropTypes.func,
updateQueryState: PropTypes.func,
currentQueryState: PropTypes.object,
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ContribSearchAppFacets } from "@js/invenio_search_ui/components";
import {
ResultOptionsWithState,
} from "./ResultOptions";
import { SearchBar } from "@js/invenio_search_ui/components";
import { RecordSearchBarElement } from "./RecordSearchBarElement";

const ContribSearchHelpLinks = (props) => {
Expand Down Expand Up @@ -71,29 +72,39 @@ const SearchAppLayout = ({ config, appName, help=true, toggle=true }) => {
return (
<Container fluid>
<Grid>
<Overridable
id={buildUID("SearchApp.searchbarContainer", "", appName)}
>
<Grid.Row className="pb-0 pt-0">
<Grid.Column
mobile={16}
tablet={16}
computer={11}
largeScreen={11}
widescreen={11}
>
<RecordSearchBarElement buildUID={buildUID} appName={appName} />
</Grid.Column>
<Grid.Column
mobile={4}
tablet={4}
computer={5}
largeScreen={5}
widescreen={5}
<Grid.Row className="pb-0 pt-0">
<Grid.Column
mobile={16}
tablet={16}
computer={11}
largeScreen={11}
widescreen={11}
>
<Overridable
id={buildUID("SearchApp.searchbarContainer", "", appName)}
>
<Overridable
id={buildUID("SearchApp.searchbar", "", appName)}
>
</Grid.Column>
</Grid.Row>
</Overridable>
<Overridable
id={buildUID("SearchBar.element", "", appName)}
>
{/* invenio_search_ui SearchBar Overridable id: "<appName>.SearchApp.searchbar"
and wraps searchkit Searchbar with Overridable id: "<appName>.SearchBar.element" */}
<RecordSearchBarElement appName={appName} buildUID={buildUID} />
</Overridable>
</Overridable>
</Overridable>
</Grid.Column>
<Grid.Column
mobile={4}
tablet={4}
computer={5}
largeScreen={5}
widescreen={5}
>
</Grid.Column>
</Grid.Row>

<ResultOptionsWithState
appName={appName}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Knowledge Commons Works is a collaborative tool for storing and sharing academic research. It is part of Knowledge Commons and is built on an instance of the InvenioRDM repository system.

Version 0.3.4-beta7
Version 0.3.5-beta8

## Copyright

Expand Down
5 changes: 5 additions & 0 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

# Changes

## 0.3.5-beta8 (2025-01-10)

- Dashboard works search
- Fixed the bug that broke works searching from the dashboard.

## 0.3.4-beta7 (2025-01-09)

- Upload form collection selector
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = "Knowledge Commons Works"
copyright = "2025, Mesh Research"
author = "Mesh Research"
release = "0.3.4"
release = "0.3.5"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion site/kcworks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

"""KCWorks customizations to InvenioRDM."""

__version__ = "0.3.4-beta7"
__version__ = "0.3.5-beta8"
2 changes: 1 addition & 1 deletion site/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "kcworks"
version = "0.3.4-beta7"
version = "0.3.5-beta8"

[project.optional-dependencies]
tests = ["pytest-invenio>=2.1.0,<3.0.0"]
Expand Down

0 comments on commit 47f0928

Please sign in to comment.