Skip to content

Commit

Permalink
Merge pull request #386 from OpenCatalogi/feature/OP-60/ResultsDispla…
Browse files Browse the repository at this point in the history
…ySwitch-NLDS

feature/OP-60/ResultsDisplaySwitch-NLDS
  • Loading branch information
remko48 authored Nov 7, 2023
2 parents 811da16 + 578c36f commit e3f20d7
Show file tree
Hide file tree
Showing 32 changed files with 347 additions and 237 deletions.
35 changes: 13 additions & 22 deletions pwa/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "cd .. && husky install"
},
"dependencies": {
"@conduction/components": "2.2.22",
"@conduction/components": "2.2.24",
"@conduction/theme": "1.0.52",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "6.4.2",
Expand Down
5 changes: 2 additions & 3 deletions pwa/src/apiService/resources/organization.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Send } from "../apiService";
import { AxiosInstance } from "axios";
import { IFiltersContext } from "../../context/filters";
import { filtersToQueryParams } from "../../services/filtersToQueryParams";

export default class Organization {
private _instance: AxiosInstance;
Expand Down Expand Up @@ -34,8 +33,8 @@ export default class Organization {
return data;
};

public getCount = async (filters: IFiltersContext): Promise<any> => {
const { data } = await Send(this._instance, "GET", `/organizations?limit=1${filtersToQueryParams(filters)}`);
public getCount = async (): Promise<any> => {
const { data } = await Send(this._instance, "GET", `/organizations?limit=1`);

return data.total;
};
Expand Down
5 changes: 3 additions & 2 deletions pwa/src/components/categoryCard/CategoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export interface CategoryCardProps {
description: string | JSX.Element;
icon: JSX.Element;
domain?: boolean;
titleHrefOnly?: boolean;
}

export const CategoryCard: React.FC<CategoryCardProps> = ({ title, description, icon, domain }) => {
export const CategoryCard: React.FC<CategoryCardProps> = ({ title, description, icon, domain, titleHrefOnly }) => {
return (
<CardWrapper className={styles.container} onClick={() => navigate(title.href)}>
<CardWrapper className={styles.container} onClick={() => !titleHrefOnly && navigate(title.href)}>
<CardHeader>
<CardHeaderTitle>
<Link className={styles.titleLink} onClick={() => navigate(title.href)}>
Expand Down
2 changes: 0 additions & 2 deletions pwa/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export * from "./applicationCard/ApplicationCard";
export * from "./buttonLink/ButtonLink";
export * from "./categoryCard/CategoryCard";
export * from "./componentCard/ComponentCard";
export * from "./organizationCard/OrganizationCard";
export * from "./resultsDisplaySwitch/ResultsDisplaySwitch";

This file was deleted.

66 changes: 0 additions & 66 deletions pwa/src/components/resultsDisplaySwitch/ResultsDisplaySwitch.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions pwa/src/context/filters.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import * as React from "react";
import { GlobalContext } from "./global";

export type TComponentResultsLayout = "table" | "cards" | "layer";
export type TComponentDependenciesLayout = "layer" | "relations";
export type TLandingDisplayLayout = "layer" | "cards";
export type TCatagoryDisplayLayout = "table" | "cards" | "layer";
export type TOrganizationsResultDisplayLayout = "table" | "cards";

export interface IFiltersContext {
resultDisplayLayout: TComponentResultsLayout;
dependenciesDisplayLayout: TComponentDependenciesLayout;
landingDisplayLayout: TLandingDisplayLayout;
catagoryDisplayLayout: TCatagoryDisplayLayout;
isForked: boolean;

organizationsResultDisplayLayout: TOrganizationsResultDisplayLayout;
organizationSearch?: string;

_search?: string;
Expand All @@ -38,11 +26,6 @@ export interface IFiltersContext {
}

export const defaultFiltersContext: IFiltersContext = {
resultDisplayLayout: "table",
dependenciesDisplayLayout: "layer",
landingDisplayLayout: "cards",
catagoryDisplayLayout: "table",
organizationsResultDisplayLayout: "cards",
_search: "",
organizationSearch: "",
isForked: true,
Expand Down
3 changes: 3 additions & 0 deletions pwa/src/context/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { defaultGatsbyContext, IGatsbyContext } from "./gatsby";
import { defaultFiltersContext, IFiltersContext } from "./filters";
import { defaultPaginationContext, IPaginationContext } from "./pagination";
import { defaultQueryLimitContext, IQueryLimitContext } from "./queryLimit";
import { defaultResultDisplayLayoutContext, IResultDisplayLayoutContext } from "./resultDisplayLayout";

export interface IGlobalContext {
initiated: boolean;
gatsby: IGatsbyContext;
filters: IFiltersContext;
pagination: IPaginationContext;
queryLimit: IQueryLimitContext;
resultDisplayLayout: IResultDisplayLayoutContext;
}

export const defaultGlobalContext: IGlobalContext = {
Expand All @@ -18,6 +20,7 @@ export const defaultGlobalContext: IGlobalContext = {
filters: defaultFiltersContext,
pagination: defaultPaginationContext,
queryLimit: defaultQueryLimitContext,
resultDisplayLayout: defaultResultDisplayLayoutContext,
};

export const GlobalContext = React.createContext<
Expand Down
39 changes: 39 additions & 0 deletions pwa/src/context/resultDisplayLayout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as React from "react";
import { GlobalContext } from "./global";

export type TComponentResultsLayout = "table" | "cards" | "layer";
export type TComponentDependenciesLayout = "layer" | "relations";
export type TLandingDisplayLayout = "layer" | "cards";
export type TCatagoryDisplayLayout = "table" | "cards" | "layer";
export type TOrganizationsResultDisplayLayout = "table" | "cards";

export interface IResultDisplayLayoutContext {
componentsDisplayLayout: TComponentResultsLayout;
dependenciesDisplayLayout: TComponentDependenciesLayout;
landingDisplayLayout: TLandingDisplayLayout;
catagoryDisplayLayout: TCatagoryDisplayLayout;
organizationsResultDisplayLayout: TOrganizationsResultDisplayLayout;
}

export const defaultResultDisplayLayoutContext: IResultDisplayLayoutContext = {
componentsDisplayLayout: "table",
dependenciesDisplayLayout: "layer",
landingDisplayLayout: "cards",
catagoryDisplayLayout: "table",
organizationsResultDisplayLayout: "cards",
};

export const useResultDisplayLayoutContext = () => {
const [globalContext, setGlobalContext] = React.useContext(GlobalContext);

const resultDisplayLayout: IResultDisplayLayoutContext = globalContext.resultDisplayLayout;

const setResultDisplayLayout = (query: IResultDisplayLayoutContext) => {
setGlobalContext((context) => ({
...context,
resultDisplayLayout: { ...globalContext.resultDisplayLayout, ...query },
}));
};

return { setResultDisplayLayout, resultDisplayLayout };
};
4 changes: 2 additions & 2 deletions pwa/src/hooks/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const useOrganization = (queryClient: QueryClient) => {
},
});

const getCount = (filters: IFiltersContext) =>
useQuery<any, Error>(["organizations_count", filters], () => API?.Organization.getCount(filters), {
const getCount = () =>
useQuery<any, Error>(["organizations_count"], () => API?.Organization.getCount(), {
onError: (error) => {
throw new Error(error.message);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ export const ApplicationsDetailTemplate: React.FC<ApplicationsDetailTemplateProp

return (
<Container layoutClassName={styles.container}>
<Link className={styles.backButton} onClick={() => navigate("/applications")}>
<Link
className={styles.backButton}
onClick={(e) => {
e.preventDefault(), navigate("/applications");
}}
href="/applications"
>
<Icon>
<FontAwesomeIcon icon={faArrowLeft} />
</Icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
align-items: baseline !important;
}

.loading > span > br {
display: none;
}

/* pagination */

.paginationContainer {
Expand Down
Loading

0 comments on commit e3f20d7

Please sign in to comment.