Skip to content

Commit

Permalink
feat: allow user to filter by access facet (#4133) (#4221)
Browse files Browse the repository at this point in the history
* feat: allow user to filter by access facet (#4133)

* feat: updated access facet position in category group (#4133)

---------

Co-authored-by: Fran McDade <[email protected]>
  • Loading branch information
frano-m and Fran McDade authored Nov 5, 2024
1 parent 188cd8b commit ee87b40
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 139 deletions.
3 changes: 3 additions & 0 deletions explorer/app/common/types.ts
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];
};
10 changes: 9 additions & 1 deletion explorer/site-config/hca-dcp/cc-ma-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { SiteConfig } from "../../common/entities";
import { makeConfig } from "../dev/config";
import { getAuthenticationConfig } from "./authentication/authentication";
import { getMAExportConfig } from "./export/export";
import { getMAEntitiesConfig } from "./index/projectsEntityConfig";
import {
getMACategoryGroupConfig,
getMAEntitiesConfig,
} from "./index/projectsEntityConfig";

// Template constants
const BROWSER_URL =
Expand All @@ -29,6 +32,11 @@ export function makeManagedAccessConfig(config: SiteConfig): SiteConfig {
// Add authentication to the config.
cloneConfig.authentication = getAuthenticationConfig();

// Update categoryGroupConfig.
cloneConfig.categoryGroupConfig = getMACategoryGroupConfig(
cloneConfig.categoryGroupConfig
);

// Adding authentication to the header.
const header = { ...cloneConfig.layout.header };
cloneConfig.layout.header = { ...header, authenticationEnabled: true };
Expand Down
32 changes: 32 additions & 0 deletions explorer/site-config/hca-dcp/cc-ma-dev/index/common/category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
CategoryConfig,
CategoryGroup,
} from "@databiosphere/findable-ui/lib/config/entities";
import { mapSelectCategoryValue } from "../../../../../app/config/utils";
import {
HCA_DCP_CATEGORY_KEY,
HCA_DCP_CATEGORY_LABEL,
} from "../../../category";
import { CATEGORY_GROUP } from "../../../dev/index/common/category";
import { mapAccessibleValue } from "./utils";

export const ACCESSIBLE: CategoryConfig = {
key: HCA_DCP_CATEGORY_KEY.ACCESSIBLE,
label: HCA_DCP_CATEGORY_LABEL.ACCESSIBLE,
mapSelectCategoryValue: mapSelectCategoryValue(mapAccessibleValue),
};

export const MA_CATEGORY_GROUP: Record<string, CategoryGroup> = {
PROJECT: {
...CATEGORY_GROUP.PROJECT,
categoryConfigs: [...CATEGORY_GROUP.PROJECT.categoryConfigs, ACCESSIBLE],
},
};

export const CATEGORY_GROUPS: CategoryGroup[] = [
MA_CATEGORY_GROUP.PROJECT,
CATEGORY_GROUP.DONOR,
CATEGORY_GROUP.SAMPLE,
CATEGORY_GROUP.PROTOCOL,
CATEGORY_GROUP.FILE,
];
28 changes: 28 additions & 0 deletions explorer/site-config/hca-dcp/cc-ma-dev/index/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
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 * as V from "../../../../../app/viewModelBuilders/azul/hca-dcp/common/viewModelBuilders";
import {
HCA_DCP_CATEGORY_KEY,
HCA_DCP_CATEGORY_LABEL,
} from "../../../category";

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 explorer/site-config/hca-dcp/cc-ma-dev/index/common/utils.ts
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";
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import {
ColumnConfig,
ComponentConfig,
EntityConfig,
SiteConfig,
} from "@databiosphere/findable-ui/lib/config/entities";
import { ProjectsResponse } from "../../../../app/apis/azul/hca-dcp/common/responses";
import * as C from "../../../../app/components";
import * as V from "../../../../app/viewModelBuilders/azul/hca-dcp/common/viewModelBuilders";
import { HCA_DCP_CATEGORY_KEY, HCA_DCP_CATEGORY_LABEL } from "../../category";
import { getMAProjectDetailTabs } from "../detail/project/mainColumn";
import { getMAProjectDetailTop } from "../detail/project/top";
import { listHero } from "../listView/projectsListHero";
import { CATEGORY_GROUPS } from "./common/category";
import { COLUMN } from "./common/constants";

// Accessible column.
const COLUMN_ACCESS: ColumnConfig = {
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",
};
/**
* Returns managed access category group config.
* @param categoryGroupConfig - Category group config.
* @returns managed access category group config.
*/
export function getMACategoryGroupConfig(
categoryGroupConfig: SiteConfig["categoryGroupConfig"]
): SiteConfig["categoryGroupConfig"] {
if (categoryGroupConfig) {
return {
...categoryGroupConfig,
categoryGroups: CATEGORY_GROUPS,
};
}
}

/**
* Returns managed access entity config.
Expand Down Expand Up @@ -55,7 +55,7 @@ export function getMAProjectsEntityConfig(
// Clone columns.
const cloneColumns = [...cloneList.columns];
// Add accessible column.
cloneColumns.splice(1, 0, COLUMN_ACCESS); // Accessible column.
cloneColumns.splice(1, 0, COLUMN.ACCESSIBLE); // Accessible column.
cloneList.columns = cloneColumns;
cloneEntity.list = cloneList;
// Update list view.
Expand Down
122 changes: 2 additions & 120 deletions explorer/site-config/hca-dcp/dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import * as C from "../../../app/components/index";
import { bindSystemStatusResponse } from "../../../app/viewModelBuilders/azul/common/systemStatusMapper/systemStatusMapper";
import { FLATTEN } from "../../common/constants";
import { SiteConfig } from "../../common/entities";
import { HCA_DCP_CATEGORY_KEY, HCA_DCP_CATEGORY_LABEL } from "../category";
import { announcements } from "./announcements/announcements";
import { exportConfig } from "./export/export";
import { CATEGORY_GROUPS } from "./index/common/category";
import { filesEntityConfig } from "./index/filesEntityConfig";
import { projectsEntityConfig } from "./index/projectsEntityConfig";
import { samplesEntityConfig } from "./index/samplesEntityConfig";
Expand Down Expand Up @@ -50,125 +50,7 @@ export function makeConfig(
authentication: undefined,
browserURL: browserUrl,
categoryGroupConfig: {
categoryGroups: [
{
categoryConfigs: [
{
key: HCA_DCP_CATEGORY_KEY.PROJECT_TITLE,
label: HCA_DCP_CATEGORY_LABEL.PROJECT_TITLE,
},
{
key: HCA_DCP_CATEGORY_KEY.CONTACT_NAME,
label: HCA_DCP_CATEGORY_LABEL.CONTACT_NAME,
},
{
key: HCA_DCP_CATEGORY_KEY.INSTITUTION,
label: HCA_DCP_CATEGORY_LABEL.INSTITUTION,
},
{
key: HCA_DCP_CATEGORY_KEY.BIONETWORK_NAME,
label: HCA_DCP_CATEGORY_LABEL.BIONETWORK_NAME,
},
],
label: "Project",
},
{
categoryConfigs: [
{
key: HCA_DCP_CATEGORY_KEY.BIOLOGICAL_SEX,
label: HCA_DCP_CATEGORY_LABEL.BIOLOGICAL_SEX,
},
{
key: HCA_DCP_CATEGORY_KEY.DEVELOPMENT_STAGE,
label: HCA_DCP_CATEGORY_LABEL.DEVELOPMENT_STAGE,
},
{
key: HCA_DCP_CATEGORY_KEY.DONOR_DISEASE,
label: HCA_DCP_CATEGORY_LABEL.DONOR_DISEASE,
},
{
key: HCA_DCP_CATEGORY_KEY.GENUS_SPECIES,
label: HCA_DCP_CATEGORY_LABEL.GENUS_SPECIES,
},
],
label: "Donor",
},
{
categoryConfigs: [
{
key: HCA_DCP_CATEGORY_KEY.ANATOMICAL_ENTITY, // specimenOrgan
label: HCA_DCP_CATEGORY_LABEL.ANATOMICAL_ENTITY,
},
{
key: HCA_DCP_CATEGORY_KEY.ORGAN_PART,
label: HCA_DCP_CATEGORY_LABEL.ORGAN_PART,
},
{
key: HCA_DCP_CATEGORY_KEY.PRESERVATION_METHOD,
label: HCA_DCP_CATEGORY_LABEL.PRESERVATION_METHOD,
},
{
key: HCA_DCP_CATEGORY_KEY.MODEL_ORGAN,
label: HCA_DCP_CATEGORY_LABEL.MODEL_ORGAN,
},
{
key: HCA_DCP_CATEGORY_KEY.SAMPLE_ENTITY_TYPE,
label: HCA_DCP_CATEGORY_LABEL.SAMPLE_ENTITY_TYPE,
},
{
key: HCA_DCP_CATEGORY_KEY.SELECTED_CELL_TYPE,
label: HCA_DCP_CATEGORY_LABEL.SELECTED_CELL_TYPE,
},
{
key: HCA_DCP_CATEGORY_KEY.SPECIMEN_DISEASE,
label: HCA_DCP_CATEGORY_LABEL.SPECIMEN_DISEASE,
},
],
label: "Sample",
},
{
categoryConfigs: [
{
key: HCA_DCP_CATEGORY_KEY.ANALYSIS_PROTOCOL, // workflow
label: HCA_DCP_CATEGORY_LABEL.ANALYSIS_PROTOCOL,
},
{
key: HCA_DCP_CATEGORY_KEY.INSTRUMENT_MANUFACTURER_MODEL,
label: HCA_DCP_CATEGORY_LABEL.INSTRUMENT_MANUFACTURER_MODEL,
},
{
key: HCA_DCP_CATEGORY_KEY.LIBRARY_CONSTRUCTION_METHOD,
label: HCA_DCP_CATEGORY_LABEL.LIBRARY_CONSTRUCTION_METHOD,
},
{
key: HCA_DCP_CATEGORY_KEY.NUCLEIC_ACID_SOURCE,
label: HCA_DCP_CATEGORY_LABEL.NUCLEIC_ACID_SOURCE,
},
{
key: HCA_DCP_CATEGORY_KEY.PAIRED_END,
label: HCA_DCP_CATEGORY_LABEL.PAIRED_END,
},
],
label: "Protocol",
},
{
categoryConfigs: [
{
key: HCA_DCP_CATEGORY_KEY.CONTENT_DESCRIPTION,
label: HCA_DCP_CATEGORY_LABEL.CONTENT_DESCRIPTION,
},
{
key: HCA_DCP_CATEGORY_KEY.FILE_FORMAT,
label: HCA_DCP_CATEGORY_LABEL.FILE_FORMAT,
},
{
key: HCA_DCP_CATEGORY_KEY.FILE_SOURCE,
label: HCA_DCP_CATEGORY_LABEL.FILE_SOURCE,
},
],
label: "File",
},
],
categoryGroups: CATEGORY_GROUPS,
key: "hca-dcp",
},
dataSource: {
Expand Down
Loading

0 comments on commit ee87b40

Please sign in to comment.