Skip to content

Commit 8fad329

Browse files
feat(FOROME-1425): Reworking wizard scenarios (#865)
1 parent 094caa3 commit 8fad329

32 files changed

+632
-445
lines changed

src/i18n/locales/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,18 @@ export const en = {
145145
startWith: 'Start with',
146146
prevWorkSection: 'In this section your previous work will be displayed',
147147
prevWorkWith: 'You previously worked with',
148+
candidateIsUnavailable: 'Existing candidates are unavailable',
149+
genomeIsUnavailable: 'Whole genome/exome is unavailable',
148150
},
149151
buildFlow: {
150152
candidateSet: 'Existing candidate sets',
151153
candidateName: 'Candidate set name',
152154
whatsNext: "What's next?",
153155
relevantPresets: 'Relevant presets',
154156
additionalPresetFilter: 'Additional preset filters',
157+
simpleFilter: 'Simple Filter',
158+
inclusionExclusion: 'Inclusion/Exclusion Criteria',
159+
viewVariants: 'View Variants',
155160
},
156161
},
157162
ds: {

src/pages/main/components/selected-dataset/build-flow/components/build-flow-left-column.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/pages/main/components/selected-dataset/build-flow/components/build-flow-right-column.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/pages/main/components/selected-dataset/build-flow/components/cards/components/card-radio-list.interface.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ export interface ICardRadioItem<T extends string> {
33
value: T
44
}
55

6-
export type TDisabledOptions<T extends string> = Record<T, boolean>
6+
export interface IDisabledOption {
7+
isDisabled: boolean
8+
placeholder: () => JSX.Element
9+
}
10+
11+
export type TDisabledOptions<T extends string> = Record<
12+
T,
13+
boolean | IDisabledOption
14+
>
Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Radio } from '@ui/radio'
2+
import { disabledOptionIsObject } from './card-radio.utils'
23
import { ICardRadioItem, TDisabledOptions } from './card-radio-list.interface'
34

45
interface ICardRadioListProps<T extends string> {
@@ -18,18 +19,37 @@ export const CardRadioList = function <T extends string>({
1819
}: ICardRadioListProps<T>) {
1920
return (
2021
<>
21-
{data.map(({ label, value }) => (
22-
<div className="flex mb-2" key={value}>
23-
<Radio
24-
className="flex items-center"
25-
checked={value === selectedOption}
26-
onChange={() => onChange(value)}
27-
disabled={isOptionsDisabled || disabledOptions?.[value]}
28-
>
29-
<div className="ml-1.5">{label}</div>
30-
</Radio>
31-
</div>
32-
))}
22+
{data.map(({ label, value }) => {
23+
const disabledOption = disabledOptions?.[value]
24+
if (
25+
disabledOptionIsObject(disabledOption) &&
26+
disabledOption.isDisabled
27+
) {
28+
return (
29+
<div className="flex mb-2" key={value}>
30+
{disabledOption.placeholder()}
31+
</div>
32+
)
33+
} else {
34+
return (
35+
<div className="flex mb-2" key={value}>
36+
<Radio
37+
className="flex items-center"
38+
checked={value === selectedOption}
39+
onChange={() => onChange(value)}
40+
disabled={
41+
!!isOptionsDisabled ||
42+
(disabledOptionIsObject(disabledOption)
43+
? disabledOption.isDisabled
44+
: disabledOption)
45+
}
46+
>
47+
<div className="ml-1.5">{label}</div>
48+
</Radio>
49+
</div>
50+
)
51+
}
52+
})}
3353
</>
3454
)
3555
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { IDisabledOption } from './card-radio-list.interface'
2+
3+
export const disabledOptionIsObject = (
4+
value: boolean | IDisabledOption | undefined,
5+
): value is IDisabledOption => {
6+
return typeof value === 'object'
7+
}

src/pages/main/components/selected-dataset/build-flow/components/cards/description-card/description-card.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const DescriptionCard = observer(
3434
continueDisabled,
3535
contentDisabled,
3636
editDisabled,
37+
position,
3738
} = props
3839
const history = useHistory()
3940
const ds = title || datasetStore.datasetName
@@ -60,7 +61,6 @@ export const DescriptionCard = observer(
6061
}
6162

6263
useEffect(() => {
63-
wizardStore.wizardScenario[id].title = ds
6464
wizardStore.updateSelectedDataset(ds)
6565
setDsName(ds)
6666
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -73,16 +73,17 @@ export const DescriptionCard = observer(
7373
return (
7474
<Card
7575
isNeedToAnimate={wizardStore.isNeedToAnimateCard(id)}
76-
className={cn(styles.descriptionCard, 'mt-4')}
76+
className={cn(styles.descriptionCard)}
77+
position={position}
7778
>
7879
<CardTitleWithEdit
7980
title={ds}
80-
isEditShown={editDisabled}
81+
isEditShown={!editDisabled}
8182
onEdit={() => wizardStore.editCard(id)}
8283
/>
8384

8485
<div className="mb-4">
85-
<Card className="w-full mt-4 bg-grey-tertiary">
86+
<Card className="w-full mt-4 bg-grey-tertiary" position="stretch">
8687
<div className="flex items-center mb-2">
8788
<span className="font-bold">Description</span>
8889
<Button

src/pages/main/components/selected-dataset/build-flow/components/cards/existing-candidate-set-card.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ICardProps } from '../wizard/wizard.interface'
66
import wizardStore from '../wizard/wizard.store'
77

88
export const ExistingCandidatesCard = observer((props: ICardProps) => {
9-
const { title, id, maxHeight } = props
9+
const { title, id, maxHeight, position } = props
1010
const secodaryDatasets = wizardStore.secondaryDatasets
1111
const onSelect = (ds: string) => {
1212
wizardStore.setSelectedDataset(ds, id)
@@ -17,6 +17,7 @@ export const ExistingCandidatesCard = observer((props: ICardProps) => {
1717
isNeedToAnimate={wizardStore.isNeedToAnimateCard(id)}
1818
className="mt-4"
1919
style={{ paddingLeft: 0, paddingRight: 0 }}
20+
position={position}
2021
>
2122
<CardTitle text={title} className="px-4" />
2223

src/pages/main/components/selected-dataset/build-flow/components/cards/presets-card/presets-card.tsx

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -14,87 +14,88 @@ import wizardStore from '../../wizard/wizard.store'
1414
import { memorizeLocation } from '../../wizard/wizard.utils'
1515
import presetsCardStore from './presets-card.store'
1616

17-
export const PresetsCard = observer((props: ICardProps) => {
18-
const history = useHistory()
19-
const { title, id, selectedValue, maxHeight } = props
17+
export const PresetsCard = observer(
18+
({ title, id, selectedValue, maxHeight, position }: ICardProps) => {
19+
const history = useHistory()
2020

21-
useEffect(() => {
22-
presetsCardStore.loadSolutions()
23-
}, [])
21+
useEffect(() => {
22+
presetsCardStore.loadSolutions()
23+
}, [])
2424

25-
const onClickOpen = () => {
26-
if (!wizardStore.selectedPreset) return
25+
const onClickOpen = () => {
26+
if (!wizardStore.selectedPreset) return
2727

28-
const { kind, name } = wizardStore.selectedPreset
29-
let location = ''
28+
const { kind, name } = wizardStore.selectedPreset
29+
let location = ''
3030

31-
if (kind === 'preset') {
32-
location = `${Routes.Refiner}?ds=${datasetStore.datasetName}&preset=${name}`
33-
} else if (kind === 'dtree') {
34-
location = `${Routes.Dtree}?ds=${datasetStore.datasetName}&dtree=${name}`
35-
}
31+
if (kind === 'preset') {
32+
location = `${Routes.Refiner}?ds=${datasetStore.datasetName}&preset=${name}`
33+
} else if (kind === 'dtree') {
34+
location = `${Routes.Dtree}?ds=${datasetStore.datasetName}&dtree=${name}`
35+
}
3636

37-
memorizeLocation(location)
38-
history.push(location)
39-
}
37+
memorizeLocation(location)
38+
history.push(location)
39+
}
4040

41-
const renderPresets = () => {
42-
return presetsCardStore
43-
.getSolutionsByRubric(wizardStore.whatsNextOption)
44-
.map(preset => {
45-
const isSelected = selectedValue === preset.name
41+
const renderPresets = () => {
42+
return presetsCardStore
43+
.getSolutionsByRubric(wizardStore.whatsNextOption)
44+
.map(preset => {
45+
const isSelected = selectedValue === preset.name
4646

47-
return (
48-
<div
49-
key={preset.name}
50-
onClick={() => wizardStore.setSelectedPreset(preset, id)}
51-
>
47+
return (
5248
<div
53-
className={cn(
54-
'w-full flex items-center py-2 leading-5 cursor-pointer px-4',
55-
isSelected
56-
? 'bg-blue-bright text-white'
57-
: 'hover:bg-blue-light',
58-
)}
49+
key={preset.name}
50+
onClick={() => wizardStore.setSelectedPreset(preset, id)}
5951
>
60-
<Icon
61-
name="File"
62-
className={cn(isSelected ? 'text-white' : 'text-blue-bright')}
63-
/>
52+
<div
53+
className={cn(
54+
'w-full flex items-center py-2 leading-5 cursor-pointer px-4',
55+
isSelected
56+
? 'bg-blue-bright text-white'
57+
: 'hover:bg-blue-light',
58+
)}
59+
>
60+
<Icon
61+
name="File"
62+
className={cn(isSelected ? 'text-white' : 'text-blue-bright')}
63+
/>
6464

65-
<div className="ml-1.5">{preset.name}</div>
65+
<div className="ml-1.5">{preset.name}</div>
66+
</div>
6667
</div>
67-
</div>
68-
)
69-
})
70-
}
71-
72-
return (
73-
<Card
74-
isNeedToAnimate={wizardStore.isNeedToAnimateCard(id)}
75-
className="mt-4"
76-
style={{ paddingLeft: 0, paddingRight: 0 }}
77-
>
78-
<CardTitle text={title} className="px-4" />
68+
)
69+
})
70+
}
7971

80-
<div
81-
className="mb-4 mt-2 text-14 overflow-y-auto"
82-
style={{ maxHeight: maxHeight }}
72+
return (
73+
<Card
74+
isNeedToAnimate={wizardStore.isNeedToAnimateCard(id)}
75+
style={{ paddingLeft: 0, paddingRight: 0 }}
76+
position={position}
8377
>
84-
{presetsCardStore.isFetchingSolutions ? (
85-
<Loader size="m" />
86-
) : (
87-
renderPresets()
88-
)}
89-
</div>
78+
<CardTitle text={title} className="px-4" />
79+
80+
<div
81+
className="mb-4 mt-2 text-14 overflow-y-auto"
82+
style={{ maxHeight: maxHeight }}
83+
>
84+
{presetsCardStore.isFetchingSolutions ? (
85+
<Loader size="m" />
86+
) : (
87+
renderPresets()
88+
)}
89+
</div>
9090

91-
<div className="flex justify-end px-4">
92-
<Button
93-
onClick={onClickOpen}
94-
text="Open"
95-
disabled={!wizardStore.selectedPreset}
96-
/>
97-
</div>
98-
</Card>
99-
)
100-
})
91+
<div className="flex justify-end px-4">
92+
<Button
93+
onClick={onClickOpen}
94+
text="Open"
95+
disabled={!wizardStore.selectedPreset}
96+
/>
97+
</div>
98+
</Card>
99+
)
100+
},
101+
)

0 commit comments

Comments
 (0)