Skip to content

Commit

Permalink
Merge pull request #443 from OpenCatalogi/feature/OP-243/filter-default
Browse files Browse the repository at this point in the history
feature/OP-243/filter-default
  • Loading branch information
remko48 authored Mar 6, 2024
2 parents 74be10b + 088dd2c commit 8c262ce
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 34 deletions.
63 changes: 48 additions & 15 deletions .github/workflows/opencatalogi-page-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy the Product Page to GitHub Pages
name: Deploy dev.opencatalogi.nl to GitHub Pages

env: # Change these to your preferences any image url can also be a base encoded image
GITHUB_PAGES_BRANCH: gh-pages
Expand All @@ -17,7 +17,7 @@ env: # Change these to your preferences any image url can also be a base encoded
LOGIN_REDIRECT: "vault"
ADMIN_DASHBOARD_URL: "https://admin.opencatalogi.nl"

NL_DESIGN_THEME_CLASSNAME: rotterdam-theme
NL_DESIGN_THEME_CLASSNAME: opencatalogi-theme
# GITHUB_ORGANIZATION_URL: ""
FAVICON_URL: "https://dev.opencatalogi.nl/static/logo_OpenCatalogi-8b1b0a001c3f37dae4d3f69b5964ec72.png"
PAGE_TITLE: "DevOpenCatalogi"
Expand All @@ -42,9 +42,27 @@ env: # Change these to your preferences any image url can also be a base encoded
FOOTER_SHOW_CREATOR: "true"
FOOTER_LOGO_URL: "https://dev.opencatalogi.nl/static/logo_OpenCatalogi-8b1b0a001c3f37dae4d3f69b5964ec72.png"
FOOTER_CONTENT: "https://raw.githubusercontent.com/OpenCatalogi/web-app/25995205e1dbb043822d1c58c5c23f8e6f77ff7e/pwa/src/templates/templateParts/footer/FooterContent.json"
# options: "heading-1" | "heading-2" | "heading-3" | "heading-4" | "heading-5"
# FOOTER_CONTENT_HEADER: ""

# options: "heading-1" | "heading-2" | "heading-3" | "heading-4" | "heading-5"
# FOOTER_CONTENT_HEADER: ""

FILTER_FORKS: "true"
# options: "false" | "OpenCatalogi" | "Commonground", default = "OpenCatalogi"
FILTER_RATING: "OpenCatalogi"
# options: "OpenCatalogi: (0-24)" | "Commonground": (0-4), default: "0"
FILTER_RATING_DEFAULT: "16"
# FILTER_LAYER: " "
# FILTER_UPL: " "
# FILTER_ORGANISATION: " "
# FILTER_CATEGORY: " "
# FILTER_PLATFORMS: " "
FILTER_STATUS: "stable"
# FILTER_MAINTENANCE_TYPES: " "
# FILTER_LICENSE: " "
# FILTER_BUSINESS_FUNCTIONS: " "
# FILTER_SOFTWARE_TYPE: " "
# FILTER_BUSINESS_SERVICES: " "
# FILTER_REFERENCE_COMPONENTS: " "

OPTIONAL_START_PAGE: "false"

on:
Expand Down Expand Up @@ -81,22 +99,37 @@ jobs:
envkey_GATSBY_NL_DESIGN_THEME_CLASSNAME: ${{ env.NL_DESIGN_THEME_CLASSNAME }}
# envkey_GATSBY_GITHUB_ORGANIZATION_URL: ${{ env.GITHUB_ORGANIZATION_URL }}
envkey_GATSBY_FAVICON_URL: ${{ env.FAVICON_URL }}
envkey_GATSBY_PAGE_TITLE : ${{ env.PAGE_TITLE }}
envkey_GATSBY_PAGE_TITLE: ${{ env.PAGE_TITLE }}
envkey_GATSBY_HEADER_LOGO_URL: ${{ env.HEADER_LOGO_URL }}
envkey_GATSBY_HEADER_SHOW_LOGIN : ${{ env.HEADER_SHOW_LOGIN }}
envkey_GATSBY_HEADER_CONTENT : ${{ env.HEADER_CONTENT }}
envkey_GATSBY_HEADER_SHOW_LOGIN: ${{ env.HEADER_SHOW_LOGIN }}
envkey_GATSBY_HEADER_CONTENT: ${{ env.HEADER_CONTENT }}
# envkey_GATSBY_JUMBOTRON_TITLE: ${{ env.JUMBOTRON_TITLE }}
# envkey_GATSBY_JUMBOTRON_SUBTITLE: ${{ env.JUMBOTRON_SUBTITLE }}
envkey_GATSBY_JUMBOTRON_IMAGE_PLACEMENT : ${{ env.JUMBOTRON_IMAGE_PLACEMENT }}
envkey_GATSBY_JUMBOTRON_IMAGE_PLACEMENT: ${{ env.JUMBOTRON_IMAGE_PLACEMENT }}
# envkey_GATSBY_JUMBOTRON_IMAGE_URL : ${{ env.JUMBOTRON_IMAGE_URL }}
# envkey_GATSBY_JUMBOTRON_DESCRIPTION : ${{ env.JUMBOTRON_DESCRIPTION }}
envkey_GATSBY_JUMBOTRON_ISCARD : ${{ env.JUMBOTRON_ISCARD }}
envkey_GATSBY_JUMBOTRON_SEARCHFORM : ${{ env.JUMBOTRON_SEARCHFORM }}
envkey_GATSBY_JUMBOTRON_CONTAINER : ${{ env.JUMBOTRON_CONTAINER }}
envkey_GATSBY_FOOTER_SHOW_CREATOR : ${{ env.FOOTER_SHOW_CREATOR }}
envkey_GATSBY_FOOTER_LOGO_URL : ${{ env.FOOTER_LOGO_URL }}
envkey_GATSBY_FOOTER_CONTENT : ${{ env.FOOTER_CONTENT }}
envkey_GATSBY_JUMBOTRON_ISCARD: ${{ env.JUMBOTRON_ISCARD }}
envkey_GATSBY_JUMBOTRON_SEARCHFORM: ${{ env.JUMBOTRON_SEARCHFORM }}
envkey_GATSBY_JUMBOTRON_CONTAINER: ${{ env.JUMBOTRON_CONTAINER }}
envkey_GATSBY_FOOTER_SHOW_CREATOR: ${{ env.FOOTER_SHOW_CREATOR }}
envkey_GATSBY_FOOTER_LOGO_URL: ${{ env.FOOTER_LOGO_URL }}
envkey_GATSBY_FOOTER_CONTENT: ${{ env.FOOTER_CONTENT }}
# envkey_GATSBY_FOOTER_CONTENT_HEADER : ${{ env.FOOTER_CONTENT_HEADER }}
envkey_GATSBY_FILTER_FORKS: ${{ env.FILTER_FORKS }}
envkey_GATSBY_FILTER_RATING: ${{ env.FILTER_RATING }}
envkey_GATSBY_FILTER_RATING_DEFAULT: ${{ env.FILTER_RATING_DEFAULT }}
# envkey_GATSBY_FILTER_LAYER: ${{ env.FILTER_LAYER }}
# envkey_GATSBY_FILTER_UPL: ${{ env.FILTER_UPL }}
# envkey_GATSBY_FILTER_ORGANISATION: ${{ env.FILTER_ORGANISATION }}
# envkey_GATSBY_FILTER_CATEGORY: ${{ env.FILTER_CATEGORY }}
# envkey_GATSBY_FILTER_PLATFORMS: ${{ env.FILTER_PLATFORMS }}
envkey_GATSBY_FILTER_STATUS: ${{ env.FILTER_STATUS }}
# envkey_GATSBY_FILTER_MAINTENANCE_TYPES: ${{ env.FILTER_MAINTENANCE_TYPES }}
# envkey_GATSBY_FILTER_LICENSE: ${{ env.FILTER_LICENSE }}
# envkey_GATSBY_FILTER_BUSINESS_FUNCTIONS: ${{ env.FILTER_BUSINESS_FUNCTIONS }}
# envkey_GATSBY_FILTER_SOFTWARE_TYPE: ${{ env.FILTER_SOFTWARE_TYPE }}
# envkey_GATSBY_FILTER_BUSINESS_SERVICES: ${{ env.FILTER_BUSINESS_SERVICES }}
# envkey_GATSBY_FILTER_REFERENCE_COMPONENTS: ${{ env.FILTER_REFERENCE_COMPONENTS }}
envkey_GATSBY_OPTIONAL_START_PAGE: ${{ env.OPTIONAL_START_PAGE }}
directory: pwa/static
file_name: .env.production
Expand Down
108 changes: 102 additions & 6 deletions pwa/src/context/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export interface IFiltersContext {
isForked: boolean;
orderRating: boolean;
rating: number;
organizationSearch?: string;
ratingCommonground: number;

_search?: string;
organizationSearch?: string;
softwareType?: string;
developmentStatus?: string;
platforms?: string[];
Expand All @@ -28,14 +28,110 @@ export interface IFiltersContext {
showMoreSupport?: boolean;
}

const isWindow = typeof window !== "undefined";

export const ratingDefault =
isWindow && !isNaN(parseInt(window.sessionStorage.getItem("FILTER_RATING_DEFAULT") ?? ""))
? parseInt(window.sessionStorage.getItem("FILTER_RATING_DEFAULT") ?? "")
: 0;

export const defaultFiltersContext: IFiltersContext = {
isForked:
isWindow && window.sessionStorage.getItem("FILTER_FORKS")
? window.sessionStorage.getItem("FILTER_FORKS") === "true"
? true
: false
: false,

orderRating:
isWindow && window.sessionStorage.getItem("FILTER_RATING")
? window.sessionStorage.getItem("FILTER_RATING") !== "false"
? true
: false
: false,
rating:
isWindow && window.sessionStorage.getItem("FILTER_RATING")
? window.sessionStorage.getItem("FILTER_RATING") !== "false"
? ratingDefault
: 0
: 0,
ratingCommonground:
isWindow && window.sessionStorage.getItem("FILTER_RATING")
? window.sessionStorage.getItem("FILTER_RATING") !== "false"
? ratingDefault
: 0
: 0,

_search: "",
organizationSearch: "",
isForked: true,
orderRating: true,
developmentStatus: "stable",
rating: 16,
ratingCommonground: 1,
softwareType:
isWindow && window.sessionStorage.getItem("FILTER_SOFTWARE_TYPE")
? window.sessionStorage.getItem("FILTER_SOFTWARE_TYPE") !== "false"
? window.sessionStorage.getItem("FILTER_SOFTWARE_TYPE") ?? ""
: ""
: "",

developmentStatus:
isWindow && window.sessionStorage.getItem("FILTER_STATUS")
? window.sessionStorage.getItem("FILTER_STATUS") !== "false"
? window.sessionStorage.getItem("FILTER_STATUS") ?? ""
: ""
: "",
platforms:
isWindow && window.sessionStorage.getItem("FILTER_PLATFORMS")
? window.sessionStorage.getItem("FILTER_PLATFORMS") !== "false"
? [...JSON.parse(window.sessionStorage.getItem("FILTER_PLATFORMS") ?? "")]
: []
: [],
category:
isWindow && window.sessionStorage.getItem("FILTER_CATEGORY")
? window.sessionStorage.getItem("FILTER_CATEGORY") !== "false"
? window.sessionStorage.getItem("FILTER_CATEGORY") ?? ""
: ""
: "",
"embedded.nl.embedded.commonground.layerType":
isWindow && window.sessionStorage.getItem("FILTER_LAYER")
? window.sessionStorage.getItem("FILTER_LAYER") !== "false"
? [...JSON.parse(window.sessionStorage.getItem("FILTER_LAYER") ?? "")]
: []
: [],
"embedded.nl.embedded.gemma.bedrijfsfuncties":
isWindow && window.sessionStorage.getItem("FILTER_BUSINESS_FUNCTIONS")
? window.sessionStorage.getItem("FILTER_BUSINESS_FUNCTIONS") !== "false"
? [...JSON.parse(window.sessionStorage.getItem("FILTER_BUSINESS_FUNCTIONS") ?? "")]
: []
: [],
"embedded.nl.embedded.gemma.bedrijfsservices":
isWindow && window.sessionStorage.getItem("FILTER_BUSINESS_SERVICES")
? window.sessionStorage.getItem("FILTER_BUSINESS_SERVICES") !== "false"
? [...JSON.parse(window.sessionStorage.getItem("FILTER_BUSINESS_SERVICES") ?? "")]
: []
: [],
"embedded.nl.embedded.gemma.referentieComponenten":
isWindow && window.sessionStorage.getItem("FILTER_REFERENCE_COMPONENTS")
? window.sessionStorage.getItem("FILTER_REFERENCE_COMPONENTS") !== "false"
? [...JSON.parse(window.sessionStorage.getItem("FILTER_REFERENCE_COMPONENTS") ?? "")]
: []
: [],
"embedded.nl.embedded.gemma.applicatiefunctie": "",
"embedded.nl.embedded.upl":
isWindow && window.sessionStorage.getItem("FILTER_UPL")
? window.sessionStorage.getItem("FILTER_UPL") !== "false"
? [...JSON.parse(window.sessionStorage.getItem("FILTER_UPL") ?? "")]
: []
: [],
"embedded.maintenance.type":
isWindow && window.sessionStorage.getItem("FILTER_MAINTENANCE_TYPES")
? window.sessionStorage.getItem("FILTER_MAINTENANCE_TYPES") !== "false"
? window.sessionStorage.getItem("FILTER_MAINTENANCE_TYPES") ?? ""
: ""
: "",
"embedded.legal.license":
isWindow && window.sessionStorage.getItem("FILTER_LICENSE")
? window.sessionStorage.getItem("FILTER_LICENSE") !== "false"
? window.sessionStorage.getItem("FILTER_LICENSE") ?? ""
: ""
: "",
};

export const useFiltersContext = () => {
Expand Down
6 changes: 4 additions & 2 deletions pwa/src/hooks/useEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const useEnvironment = () => {

window.sessionStorage.setItem("FILTER_FORKS", process.env.GATSBY_FILTER_FORKS ?? "");
window.sessionStorage.setItem("FILTER_RATING", process.env.GATSBY_FILTER_RATING ?? "OpenCatalogi");
window.sessionStorage.setItem("FILTER_RATING_DEFAULT", process.env.FILTER_RATING_DEFAULT ?? "16");
window.sessionStorage.setItem("FILTER_LAYER", process.env.GATSBY_FILTER_LAYER ?? "");
window.sessionStorage.setItem("FILTER_UPL", process.env.GATSBY_FILTER_UPL ?? "");
window.sessionStorage.setItem("FILTER_ORGANISATION", process.env.GATSBY_FILTER_ORGANISATION ?? "");
Expand All @@ -63,7 +64,7 @@ export const useEnvironment = () => {
window.sessionStorage.setItem("FILTER_MAINTENANCE_TYPES", process.env.GATSBY_FILTER_MAINTENANCE_TYPES ?? "");
window.sessionStorage.setItem("FILTER_LICENSE", process.env.GATSBY_FILTER_LICENSE ?? "");
window.sessionStorage.setItem("FILTER_BUSINESS_FUNCTIONS", process.env.GATSBY_FILTER_BUSINESS_FUNCTIONS ?? "");
window.sessionStorage.setItem("FILTER_SOFTWARE_TYPES", process.env.GATSBY_FILTER_SOFTWARE_TYPES ?? "");
window.sessionStorage.setItem("FILTER_SOFTWARE_TYPE", process.env.GATSBY_FILTER_SOFTWARE_TYPE ?? "");
window.sessionStorage.setItem("FILTER_BUSINESS_SERVICES", process.env.GATSBY_FILTER_BUSINESS_SERVICES ?? "");
window.sessionStorage.setItem("FILTER_REFERENCE_COMPONENTS", process.env.GATSBY_FILTER_REFERENCE_COMPONENTS ?? "");

Expand Down Expand Up @@ -106,6 +107,7 @@ export const useEnvironment = () => {

window.sessionStorage.setItem("FILTER_FORKS", config.GATSBY_FILTER_FORKS ?? "");
window.sessionStorage.setItem("FILTER_RATING", config.GATSBY_FILTER_RATING ?? "OpenCatalogi");
window.sessionStorage.setItem("FILTER_RATING_DEFAULT", config.FILTER_RATING_DEFAULT ?? "16");
window.sessionStorage.setItem("FILTER_LAYER", config.GATSBY_FILTER_LAYER ?? "");
window.sessionStorage.setItem("FILTER_UPL", config.GATSBY_FILTER_UPL ?? "");
window.sessionStorage.setItem("FILTER_ORGANISATION", config.GATSBY_FILTER_ORGANISATION ?? "");
Expand All @@ -115,7 +117,7 @@ export const useEnvironment = () => {
window.sessionStorage.setItem("FILTER_MAINTENANCE_TYPES", config.GATSBY_FILTER_MAINTENANCE_TYPES ?? "");
window.sessionStorage.setItem("FILTER_LICENSE", config.GATSBY_FILTER_LICENSE ?? "");
window.sessionStorage.setItem("FILTER_BUSINESS_FUNCTIONS", config.GATSBY_FILTER_BUSINESS_FUNCTIONS ?? "");
window.sessionStorage.setItem("FILTER_SOFTWARE_TYPES", config.GATSBY_FILTER_SOFTWARE_TYPES ?? "");
window.sessionStorage.setItem("FILTER_SOFTWARE_TYPE", config.GATSBY_FILTER_SOFTWARE_TYPE ?? "");
window.sessionStorage.setItem("FILTER_BUSINESS_SERVICES", config.GATSBY_FILTER_BUSINESS_SERVICES ?? "");
window.sessionStorage.setItem("FILTER_REFERENCE_COMPONENTS", config.GATSBY_FILTER_REFERENCE_COMPONENTS ?? "");
updateSessionStorage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clsx from "clsx";
import qs from "qs";
import _ from "lodash";
import { useForm } from "react-hook-form";
import { IFiltersContext, defaultFiltersContext, useFiltersContext } from "../../../../context/filters";
import { IFiltersContext, defaultFiltersContext, ratingDefault, useFiltersContext } from "../../../../context/filters";
import { InputCheckbox, SelectMultiple, SelectSingle } from "@conduction/components";
import {
upls,
Expand Down Expand Up @@ -54,10 +54,12 @@ export const VerticalFiltersTemplate: React.FC<VerticalFiltersTemplateProps> = (

const [statusRadioFilter, setStatusRadioFilter] = React.useState<string>("");
const [maintenanceTypeRadioFilter, setMaintenanceTypeRadioFilter] = React.useState<string>("");
const [softwareTypeRadioFilter, setSoftwareTypeRadioFilter] = React.useState<string>("");
const [softwareTypeRadioFilter, setSoftwareTypeRadioFilter] = React.useState<string>(
window.sessionStorage.getItem("FILTER_SOFTWARE_TYPE") ?? "",
);

const [ratingFilter, setRatingFilter] = React.useState<number>(16);
const [ratingFilterCommonground, setRatingFilterCommonground] = React.useState<number>(1);
const [ratingFilter, setRatingFilter] = React.useState<number>(ratingDefault);
const [ratingFilterCommonground, setRatingFilterCommonground] = React.useState<number>(ratingDefault);

const [isOpen, setIsOpen] = React.useState<boolean>(false);

Expand Down Expand Up @@ -342,11 +344,12 @@ export const VerticalFiltersTemplate: React.FC<VerticalFiltersTemplateProps> = (
isForked: window.sessionStorage.getItem("FILTER_FORKS") !== "false" && params.isForked ? params.isForked : false,
orderRating:
window.sessionStorage.getItem("FILTER_RATING") !== "false" && params.orderRating ? params.orderRating : false,
rating: window.sessionStorage.getItem("FILTER_RATING") !== "false" && params.rating ? params.rating : 16,
rating:
window.sessionStorage.getItem("FILTER_RATING") !== "false" && params.rating ? params.rating : ratingDefault,
ratingCommonground:
window.sessionStorage.getItem("FILTER_RATING") !== "false" && params.ratingCommonground
? params.ratingCommonground
: 1,
: ratingDefault,
"embedded.nl.embedded.commonground.layerType":
window.sessionStorage.getItem("FILTER_LAYER") !== "false" &&
params["embedded.nl.embedded.commonground.layerType"]
Expand Down Expand Up @@ -382,7 +385,7 @@ export const VerticalFiltersTemplate: React.FC<VerticalFiltersTemplateProps> = (
? [...params["embedded.nl.embedded.gemma.bedrijfsfuncties"]]
: [],
softwareType:
window.sessionStorage.getItem("FILTER_SOFTWARE_TYPES") !== "false" && params.softwareType
window.sessionStorage.getItem("FILTER_BUSINESS_FUNCTIONS") !== "false" && params.softwareType
? params.softwareType
: "",
"embedded.nl.embedded.gemma.bedrijfsservices":
Expand Down Expand Up @@ -835,7 +838,7 @@ export const VerticalFiltersTemplate: React.FC<VerticalFiltersTemplateProps> = (
</FormField>
)}

{window.sessionStorage.getItem("FILTER_SOFTWARE_TYPES") !== "false" && (
{window.sessionStorage.getItem("FILTER_SOFTWARE_TYPE") !== "false" && (
<FormField>
<Collapsible
className={styles.collapsible}
Expand All @@ -845,7 +848,8 @@ export const VerticalFiltersTemplate: React.FC<VerticalFiltersTemplateProps> = (
trigger={
<div className={styles.trigger}>
<span className={styles.filterTitle}>
Softwaretypes <span className={styles.filterCountIndicator}>({softwareTypes.length})</span>
{filters.softwareType} Softwaretypes{" "}
<span className={styles.filterCountIndicator}>({softwareTypes.length})</span>
</span>
<FontAwesomeIcon
className={clsx(styles.toggleIcon, isOpenSoftwareTypes && styles.isOpen)}
Expand Down
3 changes: 2 additions & 1 deletion pwa/static/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ GATSBY_FOOTER_CONTENT_HEADER=""
GATSBY_FILTER_FORKS=
# options: "false" | "OpenCatalogi" | "Commonground", default = "OpenCatalogi"
GATSBY_FILTER_RATING="OpenCatalogi"
GATSBY_FILTER_RATING_DEFAULT="16"
GATSBY_FILTER_LAYER=
GATSBY_FILTER_UPL=
GATSBY_FILTER_ORGANISATION=
Expand All @@ -55,7 +56,7 @@ GATSBY_FILTER_STATUS=
GATSBY_FILTER_MAINTENANCE_TYPES=
GATSBY_FILTER_LICENSE=
GATSBY_FILTER_BUSINESS_FUNCTIONS=
GATSBY_FILTER_SOFTWARE_TYPES=
GATSBY_FILTER_SOFTWARE_TYPE=
GATSBY_FILTER_BUSINESS_SERVICES=
GATSBY_FILTER_REFERENCE_COMPONENTS=

Expand Down
3 changes: 2 additions & 1 deletion pwa/static/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ GATSBY_FOOTER_CONTENT_HEADER=""
GATSBY_FILTER_FORKS=
# options: "false" | "OpenCatalogi" | "Commonground", default = "OpenCatalogi"
GATSBY_FILTER_RATING="OpenCatalogi"
GATSBY_FILTER_RATING_DEFAULT="16"
GATSBY_FILTER_LAYER=
GATSBY_FILTER_UPL=
GATSBY_FILTER_ORGANISATION=
Expand All @@ -56,7 +57,7 @@ GATSBY_FILTER_STATUS=
GATSBY_FILTER_MAINTENANCE_TYPES=
GATSBY_FILTER_LICENSE=
GATSBY_FILTER_BUSINESS_FUNCTIONS=
GATSBY_FILTER_SOFTWARE_TYPES=
GATSBY_FILTER_SOFTWARE_TYPE=
GATSBY_FILTER_BUSINESS_SERVICES=
GATSBY_FILTER_REFERENCE_COMPONENTS=

Expand Down

0 comments on commit 8c262ce

Please sign in to comment.