-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow user to filter by access facet (#4133)
- Loading branch information
Fran McDade
authored and
Fran McDade
committed
Oct 31, 2024
1 parent
334b6dc
commit a97be95
Showing
5 changed files
with
90 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type PickSome<T, K extends keyof T> = { | ||
[P in K]: T[P]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
explorer/site-config/hca-dcp/cc-ma-dev/index/common/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
CategoryGroup, | ||
ColumnConfig, | ||
ComponentConfig, | ||
} from "@databiosphere/findable-ui/lib/config/entities"; | ||
import { ProjectsResponse } from "../../../../../app/apis/azul/hca-dcp/common/responses"; | ||
import { PickSome } from "../../../../../app/common/types"; | ||
import * as C from "../../../../../app/components"; | ||
import { mapSelectCategoryValue } from "../../../../../app/config/utils"; | ||
import * as V from "../../../../../app/viewModelBuilders/azul/hca-dcp/common/viewModelBuilders"; | ||
import { | ||
HCA_DCP_CATEGORY_KEY, | ||
HCA_DCP_CATEGORY_LABEL, | ||
} from "../../../category"; | ||
import { mapAccessibleValue } from "./utils"; | ||
|
||
export const CATEGORY_GROUP: PickSome< | ||
Record<keyof typeof HCA_DCP_CATEGORY_KEY, CategoryGroup>, | ||
"ACCESSIBLE" | ||
> = { | ||
ACCESSIBLE: { | ||
categoryConfigs: [ | ||
{ | ||
key: HCA_DCP_CATEGORY_KEY.ACCESSIBLE, | ||
label: HCA_DCP_CATEGORY_LABEL.ACCESSIBLE, | ||
mapSelectCategoryValue: mapSelectCategoryValue(mapAccessibleValue), | ||
}, | ||
], | ||
label: "Access", | ||
}, | ||
}; | ||
|
||
export const COLUMN: PickSome< | ||
Record<keyof typeof HCA_DCP_CATEGORY_KEY, ColumnConfig>, | ||
"ACCESSIBLE" | ||
> = { | ||
ACCESSIBLE: { | ||
componentConfig: { | ||
component: C.StatusBadge, | ||
viewBuilder: V.buildProjectAccess, | ||
} as ComponentConfig<typeof C.StatusBadge, ProjectsResponse>, | ||
disableSorting: true, | ||
header: HCA_DCP_CATEGORY_LABEL.ACCESSIBLE, | ||
id: HCA_DCP_CATEGORY_KEY.ACCESSIBLE, | ||
width: "auto", | ||
}, | ||
}; |
11 changes: 11 additions & 0 deletions
11
explorer/site-config/hca-dcp/cc-ma-dev/index/common/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Returns "accessible" select category label for the given select category value. | ||
* @param value - Value. | ||
* @returns select category label. | ||
*/ | ||
export function mapAccessibleValue(value: string): string { | ||
if (value === "false") { | ||
return "Required"; | ||
} | ||
return "Granted"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters