Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(website): fix sort default order and remove NAs from details page #1983

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions website/src/components/SearchPage/SearchFullUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export const InnerSearchFullUI = ({
const [state, setState] = useQueryAsState({});
const [page, setPage] = useState(1);

const orderByField = state.orderBy ?? schema.primaryKey;
const orderDirection = state.order ?? 'ascending';
const orderByField = state.orderBy ?? schema.defaultOrderBy ?? schema.primaryKey;
const orderDirection = state.order ?? schema.defaultOrder ?? 'ascending';

const setOrderByField = (field: string) => {
setState((prev: QueryState) => ({
Expand Down
29 changes: 1 addition & 28 deletions website/src/components/SequenceDetailsPage/getTableData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,35 +76,8 @@ describe('getTableData', () => {
test('should return default values when there is no data', async () => {
const result = await getTableData(accessionVersion, schema, lapisClient);

const defaultList: TableDataEntry[] = [
{
label: 'Metadata field1',
name: 'metadataField1',
value: 'N/A',
customDisplay: undefined,
header: 'testHeader1',
type: { kind: 'metadata', metadataType: 'string' },
},
{
label: 'Metadata field2',
name: 'metadataField2',
value: 'N/A',
customDisplay: undefined,
header: '',
type: { kind: 'metadata', metadataType: 'string' },
},
{
label: 'Timestamp field',
name: 'timestampField',
value: 'N/A',
customDisplay: undefined,
header: '',
type: { kind: 'metadata', metadataType: 'timestamp' },
},
];

const data = result._unsafeUnwrap().data;
expect(data).toStrictEqual(defaultList.concat(defaultMutationsInsertionsDeletionsList));
expect(data).toStrictEqual(defaultMutationsInsertionsDeletionsList);
});

test('should return details field values', async () => {
Expand Down
1 change: 1 addition & 0 deletions website/src/components/SequenceDetailsPage/getTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function toTableData(config: Schema) {
}): TableDataEntry[] => {
const data: TableDataEntry[] = config.metadata
.filter((metadata) => metadata.hideOnSequenceDetailsPage !== true)
.filter((metadata) => details[metadata.name] !== null && metadata.name in details)
.map((metadata) => ({
label: metadata.displayName ?? sentenceCase(metadata.name),
name: metadata.name,
Expand Down
Loading