-
Notifications
You must be signed in to change notification settings - Fork 3
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
COR-487: search page #395
base: main
Are you sure you want to change the base?
COR-487: search page #395
Conversation
9bc9c2e
to
4e580a2
Compare
261a7de
to
404eef4
Compare
f99cfcb
to
4bd3c4a
Compare
frontend/apps/core-app/src/screens/RecipientListScreen/RecipientListScreen.container.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the data loading and table data is wrong here. You're currently getting the ancestors of the leaf node and showing a table for each (with the wrong fields for them). I think it'll be best to merge in the leaf node pr and then change it to do this:
- Read leaf node forms from context
- Select first leaf node from list (temporary until we have a UI to choose between leaf nodes)
- List records for leaf node
- Render a single table for leaf node
We can also probably look at rendering less table columns. Maybe something like 5 columns, starting at the root of FormWithRecord
and working down.
I don't think the table is growing to the full width. If you use a form with less columns they wont grow to fit the space.
export type RecordListRequest = { | ||
databaseId: string; | ||
formId: string; | ||
subforms?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change this to something like fetchSubforms
import { RecordLookup } from './Record'; | ||
|
||
export type Recipient = Record; | ||
export type RecipientList = RecordList; | ||
export type RecipientListResponse = Response<FormLookup, RecipientList>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is used
id: `record${index}`, | ||
values: form.fields.map((f) => { | ||
return { | ||
value: `value-${f.id}`, | ||
fieldId: f.id, | ||
}; | ||
}), | ||
formId: form.id, | ||
databaseId: 'databaseId', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these fake ids it'd be good to be consistent with the format. My preference is for foo-${id}
for ids and foo ${name}
for named things (eg. name, description), but happy with whatever as long as it's consistent.
}); | ||
}); | ||
|
||
describe('error', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error test for when this.get
fails
@@ -29,7 +29,7 @@ jest.mock('../../../components/Recipient/RecipientViewer', () => { | |||
}; | |||
}); | |||
|
|||
const makeFormWithRecord = (i: number): FormWithRecord<Recipient> => { | |||
export const makeFormWithRecord = (i: number): FormWithRecord<Recipient> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be moved to the mock data rather than just exported?
@@ -10,11 +10,13 @@ import { RecipientListTableEntry, SortedFilteredTable } from './types'; | |||
|
|||
type Props<T extends Record> = { | |||
data: FormWithRecord<T>[][]; | |||
form: FormDefinition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be passed in. We can calculate the columns from FormWithRecord
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought so initially too, but data might be an empty array, then we should still be able to show the table header, need the form for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that state I'd typically replace the table with some form of placeholder text (the subform table does something like this)
public list = async ({ | ||
formId, | ||
databaseId, | ||
}: FormLookup): Promise<FormWithRecord<Recipient>[][]> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change is worth doing outside of this pr as a refactor later.
I'm thinking FormWithRecord<Recipient>[][]
isn't the best return type here as we're duplicating a lot of data as the forms are the same for each record. We could probably reduce the api calls made by doing a list
for each form and then connecting the records together.
Something like:
{
forms: FormDefinition[];
records: Record<string, Record>[]; // Different Record types
}
or
{
forms: FormDefinition[];
records: Record[][];
}
or maybe FormWithRecord<Recipient>[][]
is the best return type as it's used by the frontend widely, but how we build it could be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the current structure is definitely not ideal, we should do this when we find time
4bd3c4a
to
c8b4d44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this yet as I'm having local tunnel issues
onRowClick: (id: string) => void; | ||
handleRowClick: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you renamed this prop? I think the name was correct.
I'd typically name event function props onSomething
because it is what happens when that event occurs. The function being passed in I'd typically name handleSomething
as it is handling the event.
<VStack> | ||
<FlatList data={rows} renderItem={renderRow} /> | ||
</VStack> | ||
<Box mb="63px"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few spacing things in here that should use a spacing token. Here either mb={16}
or mb="nrc_?"
. I do think we should move our nrc
spacing to the proper spacing naming though.
Also I think if the designs use a number that isn't a multiple of 5 then we should just round.
|
||
import { RecipientListTableEntry } from './types'; | ||
|
||
export const createTableColumns = ( | ||
data: FormWithRecord<Record>[][], | ||
recipientWithForm: FormWithRecord<Recipient>[] | null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just pass the form in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I need all of the forms of one recipient, this was the easiest way to get them
); | ||
const memoizedColumns = React.useMemo( | ||
() => createTableColumns(data), | ||
[JSON.stringify(data)], | ||
() => createTableColumns(recipientState.data && recipientState.data[0]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you just pass the form in then this can be the form from the props
<ScrollView bg="white"> | ||
<Box bg="secondary.100" width="100%" my="16px" alignItems="center"> | ||
<Box maxWidth={1180} width="100%"> | ||
<Box mr="auto" mt="26px" mb="42px" maxWidth={580} width="100%"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
px
</Styles.Container> | ||
<ScrollView bg="white"> | ||
<Box bg="secondary.100" width="100%" my="16px" alignItems="center"> | ||
<Box maxWidth={1180} width="100%"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not need px
?
</Box> | ||
|
||
<Box maxWidth={1180} mx="auto" width="100%"> | ||
{forms?.map((form) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have !isLoading
otherwise if we had some refresh functionality this would show both the table and skeleton.
@@ -2,10 +2,64 @@ import React from 'react'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests in this file seem out of date and aren't really testing anything
: [() => Promise.resolve(), { data, loading: false, error: null }], | ||
); | ||
const { toJSON } = render(<RecipientListScreenContainer />); | ||
expect(toJSON()).toMatchSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think snapshot tests are that useful for containers. What you want to test is that given "x" the component is rendered with the correct props. To do this I normally mock the component to return something like:
<View>
<Text>{stringProps}</Text>
<Text>{JSON.stringify(objectProp)}</Text>
</View>
c8b4d44
to
77b0414
Compare
@internetti: Adding label Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: internetti The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
COR-487
list all recipients in table on search page.
used the Recipient.get function in the Recipient.list function, to be able to show the names in the table. turned off the fetching of the subforms for that usecase.