diff --git a/explorer/app/common/types.ts b/explorer/app/common/types.ts new file mode 100644 index 000000000..ed8ff1edf --- /dev/null +++ b/explorer/app/common/types.ts @@ -0,0 +1,3 @@ +export type PickSome = { + [P in K]: T[P]; +}; diff --git a/explorer/site-config/hca-dcp/cc-ma-dev/config.ts b/explorer/site-config/hca-dcp/cc-ma-dev/config.ts index 826c5a2d3..c069569c6 100644 --- a/explorer/site-config/hca-dcp/cc-ma-dev/config.ts +++ b/explorer/site-config/hca-dcp/cc-ma-dev/config.ts @@ -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 = @@ -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 }; diff --git a/explorer/site-config/hca-dcp/cc-ma-dev/index/common/category.ts b/explorer/site-config/hca-dcp/cc-ma-dev/index/common/category.ts new file mode 100644 index 000000000..ea6cef5a3 --- /dev/null +++ b/explorer/site-config/hca-dcp/cc-ma-dev/index/common/category.ts @@ -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 = { + 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, +]; diff --git a/explorer/site-config/hca-dcp/cc-ma-dev/index/common/constants.ts b/explorer/site-config/hca-dcp/cc-ma-dev/index/common/constants.ts new file mode 100644 index 000000000..406084543 --- /dev/null +++ b/explorer/site-config/hca-dcp/cc-ma-dev/index/common/constants.ts @@ -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, + "ACCESSIBLE" +> = { + ACCESSIBLE: { + componentConfig: { + component: C.StatusBadge, + viewBuilder: V.buildProjectAccess, + } as ComponentConfig, + disableSorting: true, + header: HCA_DCP_CATEGORY_LABEL.ACCESSIBLE, + id: HCA_DCP_CATEGORY_KEY.ACCESSIBLE, + width: "auto", + }, +}; diff --git a/explorer/site-config/hca-dcp/cc-ma-dev/index/common/utils.ts b/explorer/site-config/hca-dcp/cc-ma-dev/index/common/utils.ts new file mode 100644 index 000000000..174bb7af1 --- /dev/null +++ b/explorer/site-config/hca-dcp/cc-ma-dev/index/common/utils.ts @@ -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"; +} diff --git a/explorer/site-config/hca-dcp/cc-ma-dev/index/projectsEntityConfig.ts b/explorer/site-config/hca-dcp/cc-ma-dev/index/projectsEntityConfig.ts index 65f0cf6e7..f93f58c92 100644 --- a/explorer/site-config/hca-dcp/cc-ma-dev/index/projectsEntityConfig.ts +++ b/explorer/site-config/hca-dcp/cc-ma-dev/index/projectsEntityConfig.ts @@ -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, - 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. @@ -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. diff --git a/explorer/site-config/hca-dcp/dev/config.ts b/explorer/site-config/hca-dcp/dev/config.ts index 247b75d24..399321c50 100644 --- a/explorer/site-config/hca-dcp/dev/config.ts +++ b/explorer/site-config/hca-dcp/dev/config.ts @@ -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"; @@ -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: { diff --git a/explorer/site-config/hca-dcp/dev/index/common/category.ts b/explorer/site-config/hca-dcp/dev/index/common/category.ts new file mode 100644 index 000000000..516addf99 --- /dev/null +++ b/explorer/site-config/hca-dcp/dev/index/common/category.ts @@ -0,0 +1,178 @@ +import { + CategoryConfig, + CategoryGroup, +} from "@databiosphere/findable-ui/lib/config/entities"; +import { + HCA_DCP_CATEGORY_KEY, + HCA_DCP_CATEGORY_LABEL, +} from "../../../category"; + +export const ANALYSIS_PROTOCOL: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.ANALYSIS_PROTOCOL, + label: HCA_DCP_CATEGORY_LABEL.ANALYSIS_PROTOCOL, +}; + +export const ANATOMICAL_ENTITY: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.ANATOMICAL_ENTITY, + label: HCA_DCP_CATEGORY_LABEL.ANATOMICAL_ENTITY, +}; + +export const BIOLOGICAL_SEX: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.BIOLOGICAL_SEX, + label: HCA_DCP_CATEGORY_LABEL.BIOLOGICAL_SEX, +}; + +export const BIONETWORK_NAME: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.BIONETWORK_NAME, + label: HCA_DCP_CATEGORY_LABEL.BIONETWORK_NAME, +}; + +export const CONTACT_NAME: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.CONTACT_NAME, + label: HCA_DCP_CATEGORY_LABEL.CONTACT_NAME, +}; + +export const CONTENT_DESCRIPTION: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.CONTENT_DESCRIPTION, + label: HCA_DCP_CATEGORY_LABEL.CONTENT_DESCRIPTION, +}; + +export const DEVELOPMENT_STAGE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.DEVELOPMENT_STAGE, + label: HCA_DCP_CATEGORY_LABEL.DEVELOPMENT_STAGE, +}; + +export const DONOR_DISEASE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.DONOR_DISEASE, + label: HCA_DCP_CATEGORY_LABEL.DONOR_DISEASE, +}; + +export const FILE_FORMAT: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.FILE_FORMAT, + label: HCA_DCP_CATEGORY_LABEL.FILE_FORMAT, +}; + +export const FILE_SOURCE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.FILE_SOURCE, + label: HCA_DCP_CATEGORY_LABEL.FILE_SOURCE, +}; + +export const GENUS_SPECIES: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.GENUS_SPECIES, + label: HCA_DCP_CATEGORY_LABEL.GENUS_SPECIES, +}; + +export const INSTITUTION: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.INSTITUTION, + label: HCA_DCP_CATEGORY_LABEL.INSTITUTION, +}; + +export const INSTRUMENT_MANUFACTURER_MODEL: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.INSTRUMENT_MANUFACTURER_MODEL, + label: HCA_DCP_CATEGORY_LABEL.INSTRUMENT_MANUFACTURER_MODEL, +}; + +export const LIBRARY_CONSTRUCTION_METHOD: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.LIBRARY_CONSTRUCTION_METHOD, + label: HCA_DCP_CATEGORY_LABEL.LIBRARY_CONSTRUCTION_METHOD, +}; + +export const MODEL_ORGAN: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.MODEL_ORGAN, + label: HCA_DCP_CATEGORY_LABEL.MODEL_ORGAN, +}; + +export const NUCLEIC_ACID_SOURCE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.NUCLEIC_ACID_SOURCE, + label: HCA_DCP_CATEGORY_LABEL.NUCLEIC_ACID_SOURCE, +}; + +export const ORGAN_PART: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.ORGAN_PART, + label: HCA_DCP_CATEGORY_LABEL.ORGAN_PART, +}; + +export const PAIRED_END: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.PAIRED_END, + label: HCA_DCP_CATEGORY_LABEL.PAIRED_END, +}; + +export const PRESERVATION_METHOD: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.PRESERVATION_METHOD, + label: HCA_DCP_CATEGORY_LABEL.PRESERVATION_METHOD, +}; + +export const PROJECT_TITLE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.PROJECT_TITLE, + label: HCA_DCP_CATEGORY_LABEL.PROJECT_TITLE, +}; + +export const SAMPLE_ENTITY_TYPE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.SAMPLE_ENTITY_TYPE, + label: HCA_DCP_CATEGORY_LABEL.SAMPLE_ENTITY_TYPE, +}; + +export const SELECTED_CELL_TYPE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.SELECTED_CELL_TYPE, + label: HCA_DCP_CATEGORY_LABEL.SELECTED_CELL_TYPE, +}; + +export const SPECIMEN_DISEASE: CategoryConfig = { + key: HCA_DCP_CATEGORY_KEY.SPECIMEN_DISEASE, + label: HCA_DCP_CATEGORY_LABEL.SPECIMEN_DISEASE, +}; + +export const CATEGORY_GROUP: Record = { + DONOR: { + categoryConfigs: [ + BIOLOGICAL_SEX, + DEVELOPMENT_STAGE, + DONOR_DISEASE, + GENUS_SPECIES, + ], + label: "Donor", + }, + FILE: { + categoryConfigs: [CONTENT_DESCRIPTION, FILE_FORMAT, FILE_SOURCE], + label: "File", + }, + PROJECT: { + categoryConfigs: [ + PROJECT_TITLE, + CONTACT_NAME, + INSTITUTION, + BIONETWORK_NAME, + ], + label: "Project", + }, + PROTOCOL: { + categoryConfigs: [ + ANALYSIS_PROTOCOL, // workflow + INSTRUMENT_MANUFACTURER_MODEL, + LIBRARY_CONSTRUCTION_METHOD, + NUCLEIC_ACID_SOURCE, + PAIRED_END, + ], + label: "Protocol", + }, + SAMPLE: { + categoryConfigs: [ + ANATOMICAL_ENTITY, // specimenOrgan + ORGAN_PART, + PRESERVATION_METHOD, + MODEL_ORGAN, + SAMPLE_ENTITY_TYPE, + SELECTED_CELL_TYPE, + SPECIMEN_DISEASE, + ], + label: "Sample", + }, +}; + +export const CATEGORY_GROUPS: CategoryGroup[] = [ + CATEGORY_GROUP.PROJECT, + CATEGORY_GROUP.DONOR, + CATEGORY_GROUP.SAMPLE, + CATEGORY_GROUP.PROTOCOL, + CATEGORY_GROUP.FILE, +];