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

wip - initial table load with list provider #212

Merged
merged 6 commits into from Jun 1, 2022

Conversation

anncatton
Copy link
Contributor

@anncatton anncatton commented May 16, 2022

Adds initial list load to list context. Sort/query/pagination logic not added yet.

  • creates parent schema map
  • renames ItemTable to Table
  • deletes ItemGrid, removes grid display code from ListPane
  • Table component accepts schema prop, accesses list state from context
  • fixes sortField accessor in getList method params

Copy link
Contributor

@joneubank joneubank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep going, its improving!

Comment on lines +10 to +15
export type ParentResource =
| ResourceType.USERS
| ResourceType.GROUPS
| ResourceType.APPLICATIONS
| ResourceType.POLICIES;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay moved somewhere central!

Comment on lines +119 to +144
const loadList = useCallback(async () => {
if (resourceName) {
const getList = RESOURCE_MAP[resourceName].getList;
const newParams = {
...currentListParams,
sortField: getInitialSortField(resourceName),
};
// TODO: there's still 2 api requests happening, because of params update i think. need to investigate
const data = await getList(newParams);
setListState(data);
}
}, [resourceName, currentListParams]);

useEffect(() => {
if (resourceName) {
setCurrentResource(resourceName);
setCurrentListParams((current) => ({
...current,
sortField: getInitialSortField(resourceName),
}));
}
}, [resourceName]);

useEffect(() => {
loadList();
}, [loadList]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we use loadList anywhere other than this useEffect? if not, shouldnt we just define a use effect based on the state of [resourceName, currentListParams] that immediately calls the function? It feels cumbersome to define it as a variable then just use it once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think as of right now it's not...but i will refresh my memory on what my plan was here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually i'm going to leave this as is, i have a follow-up branch that adds in the params/sorting etc so i can make the change there! It may be i'll need loadList externally somewhere down the line but it that happens i can restore this setup

@anncatton anncatton marked this pull request as ready for review June 1, 2022 13:30
Base automatically changed from refactor-nav to 161-replace-freactal June 1, 2022 13:56
@anncatton anncatton merged commit 910c5de into 161-replace-freactal Jun 1, 2022
@anncatton anncatton deleted the 207-parent-table branch June 1, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants