From 1849cbc456bd61e773734d50428f6f12c4fce504 Mon Sep 17 00:00:00 2001 From: ducica Date: Thu, 4 Apr 2024 13:10:40 +0200 Subject: [PATCH 1/8] added invenio component --- .../search/FacetsButtonGroupNameToggler.jsx | 2 +- .../search/ComputerTabletRequestsListItem.jsx | 2 +- .../js/dashboard_requests/search/index.js | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx b/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx index 92e7ce8..608644e 100644 --- a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx +++ b/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx @@ -47,7 +47,7 @@ const FacetsButtonGroupNameTogglerComponent = ({ updateQueryState(currentQueryState); }; return ( - + - + {toggledFilters.map(({ text, filterName }) => ( + + ))} ); }; @@ -70,14 +64,20 @@ FacetsButtonGroupNameTogglerComponent.propTypes = { currentQueryState: PropTypes.object.isRequired, updateQueryState: PropTypes.func.isRequired, currentResultsState: PropTypes.object.isRequired, - facetNames: PropTypes.array.isRequired, - firstFacetButtonText: PropTypes.string, - secondFacetButtonText: PropTypes.string, + toggledFilters: PropTypes.arrayOf( + PropTypes.shape({ + filterName: PropTypes.string.isRequired, + text: PropTypes.string.isRequired, + }) + ).isRequired, keepFiltersOnUpdate: PropTypes.bool, }; + FacetsButtonGroupNameTogglerComponent.defaultProps = { - firstFacetButtonText: i18next.t("My"), - secondFacetButtonText: i18next.t("Others"), + toggledFilters: [ + { text: i18next.t("My"), filterName: "mine" }, + { text: i18next.t("Others"), filterName: "assigned" }, + ], keepFiltersOnUpdate: true, }; export const FacetsButtonGroupNameToggler = withState( diff --git a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupValueToggler.jsx b/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupValueToggler.jsx deleted file mode 100644 index 2400c34..0000000 --- a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupValueToggler.jsx +++ /dev/null @@ -1,83 +0,0 @@ -import React, { useContext } from "react"; -import PropTypes from "prop-types"; -import { i18next } from "@translations/oarepo_dashboard"; -import { Button } from "semantic-ui-react"; -import { withState } from "react-searchkit"; -import { SearchConfigurationContext } from "@js/invenio_search_ui/components"; - -const FacetsButtonGroupValueTogglerComponent = ({ - currentResultsState, - currentQueryState, - updateQueryState, - facetName, - trueButtonText, - falseButtonText, - keepFiltersOnUpdate, - ...uiProps -}) => { - const { initialQueryState } = useContext(SearchConfigurationContext); - const currentFilter = currentQueryState.filters?.find( - (f) => f[0] === facetName - ); - const initialQueryFacets = initialQueryState.filters?.map((f) => f[0]); - if (!currentFilter) - console.error( - "FacetsButtonGroup: Query does not contain this facet, make sure initial filters are set properly" - ); - const currentStatus = currentFilter && JSON.parse(currentFilter?.[1]); - const handeFacetStatusChange = (status) => { - if (currentStatus === status) return; - - currentQueryState.filters = keepFiltersOnUpdate - ? currentQueryState.filters.filter((element) => element[0] !== facetName) - : [ - ...(currentQueryState?.filters - ? currentQueryState.filters.filter((element) => - initialQueryFacets.includes(element[0]) - ) - : []), - ]; - currentQueryState.filters = currentQueryState.filters.filter( - (f) => f[0] !== facetName - ); - - currentQueryState.filters.push([facetName, status]); - updateQueryState(currentQueryState); - }; - return ( - - - - - ); -}; - -FacetsButtonGroupValueTogglerComponent.propTypes = { - currentQueryState: PropTypes.object.isRequired, - updateQueryState: PropTypes.func.isRequired, - currentResultsState: PropTypes.object.isRequired, - facetName: PropTypes.string.isRequired, - trueButtonText: PropTypes.string, - falseButtonText: PropTypes.string, - keepFiltersOnUpdate: PropTypes.bool, -}; -FacetsButtonGroupValueTogglerComponent.defaultProps = { - trueButtonText: i18next.t("Open"), - falseButtonText: i18next.t("Closed"), - keepFiltersOnUpdate: true, -}; -export const FacetsButtonGroupValueToggler = withState( - FacetsButtonGroupValueTogglerComponent -); diff --git a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/index.js b/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/index.js index 111b841..6bd5584 100644 --- a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/index.js +++ b/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/index.js @@ -1,4 +1,3 @@ export * from "./UserDashboardSearchAppLayout"; export * from "./UserDashboardSearchAppResultView"; -export * from "./FacetsButtonGroupValueToggler"; export * from "./FacetsButtonGroupNameToggler"; diff --git a/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/index.js b/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/index.js index 2b149b0..13acf5c 100644 --- a/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/index.js +++ b/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/index.js @@ -52,13 +52,25 @@ export const FacetButtons = () => ( - + - + ); From 16c0c0da68518f7342d0b7e17b421ff93ed4b0b2 Mon Sep 17 00:00:00 2001 From: ducica Date: Thu, 4 Apr 2024 14:46:15 +0200 Subject: [PATCH 4/8] fixed button size in button group --- .../search/FacetsButtonGroupNameToggler.jsx | 5 ----- .../themes/default/elements/button.overrides | 7 +++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx b/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx index 3fb6815..df0a1ce 100644 --- a/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx +++ b/oarepo_dashboard/ui/dashboard_components/semantic-ui/js/dashboard_components/search/FacetsButtonGroupNameToggler.jsx @@ -1,6 +1,5 @@ import React, { useContext } from "react"; import PropTypes from "prop-types"; -import { i18next } from "@translations/oarepo_dashboard"; import { Button } from "semantic-ui-react"; import { withState } from "react-searchkit"; import { SearchConfigurationContext } from "@js/invenio_search_ui/components"; @@ -74,10 +73,6 @@ FacetsButtonGroupNameTogglerComponent.propTypes = { }; FacetsButtonGroupNameTogglerComponent.defaultProps = { - toggledFilters: [ - { text: i18next.t("My"), filterName: "mine" }, - { text: i18next.t("Others"), filterName: "assigned" }, - ], keepFiltersOnUpdate: true, }; export const FacetsButtonGroupNameToggler = withState( diff --git a/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/elements/button.overrides b/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/elements/button.overrides index 6d4e754..b916004 100644 --- a/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/elements/button.overrides +++ b/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/elements/button.overrides @@ -1,5 +1,8 @@ -.ui.active.button { +.ui.button { &.request-search-filter { - cursor: default; + &.active { + cursor: default; + } + font-size: @mini; } } From e93c426371bd555271c8ed2a15c48f29e298ace0 Mon Sep 17 00:00:00 2001 From: ducica Date: Thu, 4 Apr 2024 16:14:29 +0200 Subject: [PATCH 5/8] fixed weird hover issue on items whose header is not a link --- .../oarepo_dashboard/themes/default/views/item.overrides | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/views/item.overrides b/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/views/item.overrides index d9604e3..93cc630 100644 --- a/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/views/item.overrides +++ b/oarepo_dashboard/ui/dashboard_components/semantic-ui/less/oarepo_dashboard/themes/default/views/item.overrides @@ -9,3 +9,9 @@ border-top: none !important; } } + +// to override strange behavior of SUI where even though header is not a link +// you get link color on hover of the item +.ui.link.items > .item:hover .content .header { + color: inherit; +} From ee35158b3a5c0d86e85b98ee026a0af7abda4c56 Mon Sep 17 00:00:00 2001 From: ducica Date: Thu, 4 Apr 2024 20:46:38 +0200 Subject: [PATCH 6/8] fixed translation issue --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.cfg b/setup.cfg index 9dd9a3b..1a7e1d0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,6 +46,8 @@ invenio_assets.webpack = oarepo_dashboard_requests_ui_theme = oarepo_dashboard.ui.dashboard_requests.webpack:theme oarepo_dashboard_communities_ui_theme = oarepo_dashboard.ui.dashboard_communities.webpack:theme oarepo_dashboard_components_ui_theme = oarepo_dashboard.ui.dashboard_components.webpack:theme +invenio_i18n.translations = + oarepo_dashboard_messages = oarepo_dashboard.i18n From 26380dca1e175c26acfc5cb607084619b5068a64 Mon Sep 17 00:00:00 2001 From: ducica Date: Fri, 5 Apr 2024 15:47:42 +0200 Subject: [PATCH 7/8] request type label neutral --- .../js/dashboard_requests/search/labels/TypeLabels.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/labels/TypeLabels.jsx b/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/labels/TypeLabels.jsx index 2aa4772..fc352cc 100644 --- a/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/labels/TypeLabels.jsx +++ b/oarepo_dashboard/ui/dashboard_requests/semantic-ui/js/dashboard_requests/search/labels/TypeLabels.jsx @@ -3,19 +3,19 @@ import { Label } from "semantic-ui-react"; import { i18next } from "@translations/oarepo_dashboard"; export const LabelTypeEditRecord = (props) => ( -