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

[MI-2061]: Refactoring and optimisations around Forms, RTK query, and types and constants management #45

Merged
merged 32 commits into from
Sep 5, 2022

Conversation

avas27JTG
Copy link
Contributor

Changes are:

  • Created generic Form component
  • Added generic hook to render Form fields along with handling form error
  • Added generic hook to detect and perform actions on error/success state for API calls made using RTK query
  • Added util for error handling in forms after API call is made
  • Refactored types and constants files

avas27JTG and others added 28 commits August 11, 2022 11:27
@avas27JTG avas27JTG changed the title [MI-2061]: Refactor code base and Explore and implement RTK error han… [MI-2061]: Refactoring and optimisations around Forms, RTK query, and types and constants management Aug 22, 2022
webapp/src/components/dropdown/index.tsx Outdated Show resolved Hide resolved
webapp/src/components/form/index.tsx Show resolved Hide resolved
webapp/src/components/dropdown/index.tsx Outdated Show resolved Hide resolved
type Props = {
fieldConfig: Pick<ModalFormFieldConfig, 'label' | 'type' | 'validations'>
value: any
optionsList: any
Copy link
Contributor

Choose a reason for hiding this comment

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

OptionsList will always be LabelValuePair[], right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this has been changed in later PR not fixing here to avoid conflicts

} = useForm(plugin_constants.form.subscriptionModal);
const {getApiState, makeApiRequest, makeApiRequestWithCompletionStatus, state} = usePluginApi();
const {visibility} = getSubscribeModalState(state);
const {entities} = useSelector((reduxState: GlobalState) => reduxState);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const {entities} = useSelector((reduxState: GlobalState) => reduxState);
const {currentTeamId} = useSelector((reduxState: GlobalState) => reduxState.entities.teams);

Copy link
Contributor Author

@avas27JTG avas27JTG Sep 5, 2022

Choose a reason for hiding this comment

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

this change is done by @ayusht2810 but I've fixed it here

}

const projectList = getProjectState().data;
if (projectList) {
setProjectOptions(getProjectList(projectList));
setOrganizationOptions(getOrganizationList(projectList));
}
}, [usePlugin.state]);
}, [state]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use specific values here instead of using the whole state.

Copy link
Contributor Author

@avas27JTG avas27JTG Sep 5, 2022

Choose a reason for hiding this comment

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

this change is done by @ayusht2810 will be modified by him in his PR

useEffect(() => {
const channelList = getChannelState().data;
if (channelList) {
setChannelOptions(channelList.map((channel) => ({label: <span><i className='fa fa-globe dropdown-option-icon'/>{channel.display_name}</span>, value: channel.id})));
setChannelOptions(channelList.map((channel) => ({
label: <span><i className='fa fa-globe dropdown-option-icon'/>{channel.display_name}</span>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add condition for public and private channels and use the same icons used by MM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change is done by @ayusht2810
also same has been fixed in later PR

};

export const getApiQueriesState = (state: any): ApiQueriesState => {
return state[pluginPrefix].azureDevopsPluginApi?.queries;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return state[pluginPrefix].azureDevopsPluginApi?.queries;
return state[pluginPrefix].azureDevopsPluginApi.queries;

Is there really a need for optional chaining 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.

yes this is async so it may be undefined initially

webapp/src/selectors/index.tsx Outdated Show resolved Hide resolved
webapp/src/types/common/form.d.ts Outdated Show resolved Hide resolved
webapp/src/types/common/store.d.ts Outdated Show resolved Hide resolved
webapp/src/types/common/store.d.ts Outdated Show resolved Hide resolved
@avas27JTG avas27JTG changed the base branch from MI-2060 to master September 5, 2022 09:59
@avas27JTG avas27JTG merged commit e63723d into master Sep 5, 2022
@avas27JTG avas27JTG deleted the MI-2061 branch September 5, 2022 10:01
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.

3 participants