Skip to content

Commit

Permalink
#129 : add catalog config and filter
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermau committed Jan 17, 2025
1 parent 5c9fff0 commit 0267ef6
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 183 deletions.
25 changes: 25 additions & 0 deletions web/src/ui/config-ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@
"enabled": true
}
},
"catalog": {
"defaultLogo": true,
"search": {
"options": {
"organisation": true,
"applicationCategories": true,
"softwareType": true,
"prerogatives": true,
"programmingLanguages": false
}
},
"sortOptions": {
"referent_count": true,
"user_count": true,
"added_time": true,
"update_time": true,
"latest_version_publication_date": true,
"user_count_ASC": true,
"referent_count_ASC": true
},
"cardOptions": {
"referentCount": true,
"userCase": true
}
},
"footer": {
"domains": [
"info.gouv.fr",
Expand Down
68 changes: 39 additions & 29 deletions web/src/ui/pages/softwareCatalog/SoftwareCatalogCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Tooltip from "@mui/material/Tooltip";
import { DetailUsersAndReferents } from "ui/shared/DetailUsersAndReferents";
import softwareLogoPlaceholder from "ui/assets/software_logo_placeholder.png";
import Markdown from "react-markdown";
import config from "../../config-ui.json";

export type Props = {
className?: string;
Expand Down Expand Up @@ -79,13 +80,15 @@ export const SoftwareCatalogCard = memo((props: Props) => {
<div className={cx(fr.cx("fr-card"), classes.root, className)}>
<div className={classes.cardBody}>
<a className={cx(classes.headerContainer)} {...softwareDetailsLink}>
<div className={classes.logoWrapper}>
<img
className={cx(classes.logo)}
src={logoUrl ?? softwareLogoPlaceholder}
alt={"software logo"}
/>
</div>
{(logoUrl || config.catalog.defaultLogo) && (
<div className={classes.logoWrapper}>
<img
className={cx(classes.logo)}
src={logoUrl ?? softwareLogoPlaceholder}
alt={"software logo"}
/>
</div>
)}

<div className={cx(classes.header)}>
<div className={cx(classes.titleContainer)}>
Expand Down Expand Up @@ -199,29 +202,33 @@ export const SoftwareCatalogCard = memo((props: Props) => {
<Markdown>{resolveLocalizedString(softwareDescription)}</Markdown>
</div>

<DetailUsersAndReferents
seeUserAndReferent={
referentCount > 0 || userCount > 0
? softwareUsersAndReferentsLink
: undefined
}
referentCount={referentCount}
userCount={userCount}
className={classes.detailUsersAndReferents}
/>
{config.catalog.cardOptions.referentCount && (
<DetailUsersAndReferents
seeUserAndReferent={
referentCount > 0 || userCount > 0
? softwareUsersAndReferentsLink
: undefined
}
referentCount={referentCount}
userCount={userCount}
className={classes.detailUsersAndReferents}
/>
)}
</div>
<div className={classes.footer}>
{!userDeclaration?.isReferent && !userDeclaration?.isUser && (
<a
className={cx(
fr.cx("fr-btn", "fr-btn--secondary", "fr-text--sm"),
classes.declareReferentOrUserButton
)}
{...declareFormLink}
>
{t("softwareCatalogCard.declareOneselfReferent")}
</a>
)}
{config.catalog.cardOptions.userCase &&
!userDeclaration?.isReferent &&
!userDeclaration?.isUser && (
<a
className={cx(
fr.cx("fr-btn", "fr-btn--secondary", "fr-text--sm"),
classes.declareReferentOrUserButton
)}
{...declareFormLink}
>
{t("softwareCatalogCard.declareOneselfReferent")}
</a>
)}
<div className={cx(classes.footerActionsContainer)}>
<a className={cx(classes.footerActionLink)} {...softwareDetailsLink}>
<i className={fr.cx("fr-icon-arrow-right-line")} />
Expand Down Expand Up @@ -326,7 +333,10 @@ const useStyles = tss
"overflow": "hidden",
"display": "-webkit-box",
"WebkitBoxOrient": "vertical",
"WebkitLineClamp": isSearchHighlighted ? "5" : "3",
"WebkitLineClamp":
isSearchHighlighted || !config.catalog.cardOptions.referentCount
? "5"
: "3",
"whiteSpace": "pre-wrap"
},
"detailUsersAndReferents": {
Expand Down
Loading

0 comments on commit 0267ef6

Please sign in to comment.