Skip to content

Commit 5c8e274

Browse files
committed
fix some displays
1 parent e20a145 commit 5c8e274

File tree

7 files changed

+23
-17
lines changed

7 files changed

+23
-17
lines changed

integration-tests/tests/specs/features/search/active-filters.dependent.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test.describe('Search', () => {
3737
});
3838

3939
test('multi-segment mutation filter can be added and removed', async ({ page }) => {
40+
//TODO: expand segment level
4041
const mutation = 'S:G100A';
4142
await searchPage.cchf();
4243
await searchPage.enterMutation(mutation);

website/src/components/SearchPage/DownloadDialog/DownloadDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const DownloadDialog: FC<DownloadDialogProps> = ({
6969
return new Map(
7070
schema.metadata.map((field) => [
7171
field.name,
72-
new MetadataVisibility(selectedFields.has(field.name), field.onlyForReference),
72+
new MetadataVisibility(selectedFields.has(field.name), field.onlyForReference, field.sequenceMetadataScope),
7373
]),
7474
);
7575
}, [selectedFields, schema]);

website/src/components/SearchPage/DownloadDialog/FieldSelector/FieldSelectorModal.spec.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ describe('FieldSelectorModal', () => {
222222
new Map(
223223
metadata.map((field) => [
224224
field.name,
225-
new MetadataVisibility(result.current[0].has(field.name), field.onlyForReference),
225+
new MetadataVisibility(
226+
result.current[0].has(field.name),
227+
field.onlyForReference,
228+
field.sequenceMetadataScope,
229+
),
226230
]),
227231
)
228232
}

website/src/components/SearchPage/SearchForm.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const defaultSearchFormFilters: MetadataFilter[] = [
5757
];
5858

5959
const defaultSearchVisibilities = new Map<string, MetadataVisibility>([
60-
['field1', new MetadataVisibility(true, undefined)],
61-
['field3', new MetadataVisibility(true, undefined)],
60+
['field1', new MetadataVisibility(true, undefined, undefined)],
61+
['field3', new MetadataVisibility(true, undefined, undefined)],
6262
]);
6363

6464
const setSomeFieldValues = vi.fn();
@@ -212,8 +212,8 @@ describe('SearchForm', () => {
212212
},
213213
]);
214214
const searchVisibilities = new Map<string, MetadataVisibility>([
215-
['field1', new MetadataVisibility(true, 'suborganism1')],
216-
['field2', new MetadataVisibility(true, 'suborganism2')],
215+
['field1', new MetadataVisibility(true, 'suborganism1', 'main')],
216+
['field2', new MetadataVisibility(true, 'suborganism2', 'main')],
217217
]);
218218

219219
const field1 = () => screen.queryByLabelText('Field 1');

website/src/components/common/FieldSelectorModal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { Metadata } from '../../types/config.ts';
77
import type { ReferenceGenomesInfo } from '../../types/referencesGenomes.ts';
88
import { CustomTooltip } from '../../utils/CustomTooltip.tsx';
99
import {
10-
stillRequiresReferenceNameSelection,
10+
segmentReferenceSelected,
1111
type SegmentReferenceSelections,
1212
} from '../../utils/sequenceTypeHelpers.ts';
1313

@@ -265,10 +265,9 @@ export function getDisplayState(
265265
return undefined;
266266
}
267267

268-
//TODO: fix this to be at segment level
269268
if (
270269
field.onlyForReference !== undefined &&
271-
stillRequiresReferenceNameSelection(referenceGenomesInfo, selectedReferenceNames)
270+
!segmentReferenceSelected(field.sequenceMetadataScope!, referenceGenomesInfo, selectedReferenceNames)
272271
) {
273272
if (greyOutIfStillRequiresReferenceSelection) {
274273
return {

website/src/utils/search.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('MetadataFilterSchema', () => {
3838

3939
describe('MetadataVisibility', () => {
4040
it('should return false when isChecked is false', () => {
41-
const visibility = new MetadataVisibility(false, undefined);
41+
const visibility = new MetadataVisibility(false, undefined, undefined);
4242

4343
// Single segment single references
4444
expect(visibility.isVisible(SINGLE_SEG_SINGLE_REF_REFERENCEGENOMES, { [singleSegmentName]: null })).toBe(false);
@@ -65,7 +65,7 @@ describe('MetadataVisibility', () => {
6565
});
6666

6767
it('should return true when isChecked is true and onlyForReference is undefined', () => {
68-
const visibility = new MetadataVisibility(true, undefined);
68+
const visibility = new MetadataVisibility(true, undefined, undefined);
6969

7070
// Single segment single references
7171
expect(visibility.isVisible(SINGLE_SEG_SINGLE_REF_REFERENCEGENOMES, { [singleSegmentName]: null })).toBe(true);
@@ -90,15 +90,15 @@ describe('MetadataVisibility', () => {
9090
});
9191

9292
it('should return true when isChecked is true and selectedReference matches or is not set', () => {
93-
let visibility = new MetadataVisibility(true, 'singleReference');
93+
let visibility = new MetadataVisibility(true, 'singleReference', 'main');
9494

9595
// Single segment single references
9696
expect(visibility.isVisible(SINGLE_SEG_SINGLE_REF_REFERENCEGENOMES, { [singleSegmentName]: null })).toBe(false);
9797
expect(
9898
visibility.isVisible(SINGLE_SEG_SINGLE_REF_REFERENCEGENOMES, { [singleSegmentName]: 'singleReference' }),
9999
).toBe(true);
100100

101-
visibility = new MetadataVisibility(true, 'ref1');
101+
visibility = new MetadataVisibility(true, 'ref1', 'main');
102102

103103
// Single segment multiple references
104104
expect(visibility.isVisible(SINGLE_SEG_MULTI_REF_REFERENCEGENOMES, { [singleSegmentName]: null })).toBe(false);

website/src/utils/search.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { sentenceCase } from 'change-case';
22

33
import { validateSingleValue } from './extractFieldValue';
4-
import { stillRequiresReferenceNameSelection, type SegmentReferenceSelections } from './sequenceTypeHelpers.ts';
4+
import { segmentReferenceSelected, type SegmentReferenceSelections } from './sequenceTypeHelpers.ts';
55
import type { TableSequenceData } from '../components/SearchPage/Table';
66
import type { QueryState } from '../components/SearchPage/useStateSyncedWithUrlQueryParams.ts';
77
import type {
@@ -40,10 +40,12 @@ type VisiblitySelectableAccessor = (field: MetadataFilter) => boolean;
4040
export class MetadataVisibility {
4141
public readonly isChecked: boolean;
4242
private readonly onlyForReference: string | undefined;
43+
private readonly segmentName: string | undefined;
4344

44-
constructor(isChecked: boolean, onlyForReference: string | undefined) {
45+
constructor(isChecked: boolean, onlyForReference: string | undefined, segmentName: string | undefined) {
4546
this.isChecked = isChecked;
4647
this.onlyForReference = onlyForReference;
48+
this.segmentName = segmentName;
4749
}
4850

4951
public isVisible(
@@ -60,10 +62,9 @@ export class MetadataVisibility {
6062
if (selectedReferenceNames === undefined) {
6163
return false;
6264
}
63-
//TODO: fix this to be at segment level
6465
if (
6566
!hideIfStillRequiresReferenceSelection &&
66-
stillRequiresReferenceNameSelection(referenceGenomesInfo, selectedReferenceNames)
67+
segmentReferenceSelected(this.segmentName!, referenceGenomesInfo, selectedReferenceNames)
6768
) {
6869
return true;
6970
}
@@ -104,6 +105,7 @@ const getFieldOrColumnVisibilitiesFromQuery = (
104105
const visibility = new MetadataVisibility(
105106
explicitVisibilitiesInUrlByFieldName.get(fieldName) ?? initiallyVisibleAccessor(field),
106107
field.onlyForReference,
108+
field.sequenceMetadataScope,
107109
);
108110

109111
visibilities.set(fieldName, visibility);

0 commit comments

Comments
 (0)