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

UISACQCOMP-168: extend <Donors /> component props #730

Merged
merged 8 commits into from
Nov 16, 2023

Conversation

alisher-epam
Copy link
Contributor

Purpose

UISACQCOMP-168 -
Pass onChange and onRemove props for the Donors component in order to gain more control for complex use cases. The issue with the previous implementation was adding and removing the donors' list, controlled by the component.

The proposed solution helps to pass donorOrganizationIds along with the mentioned props above in order to manage the list programmatically(conditionally).

Related issues - UIOR-1148

Approach

Screen.Recording.2023-11-15.at.4.22.16.PM.mov

Pre-Merge Checklist

Before merging this PR, please go through the following list and take appropriate actions.

  • I've added appropriate record to the CHANGELOG.md
  • Does this PR meet or exceed the expected quality standards?
    • Code coverage on new code is 80% or greater
    • Duplications on new code is 3% or less
    • There are no major code smells or security issues
  • Does this introduce breaking changes?
    • If any API-related changes - okapi interfaces and permissions are reviewed/changed correspondingly
    • There are no breaking changes in this PR.

If there are breaking changes, please STOP and consider the following:

  • What other modules will these changes impact?
  • Do JIRAs exist to update the impacted modules?
    • If not, please create them
    • Do they contain the appropriate level of detail? Which endpoints/schemas changed, etc.
    • Do they have all they appropriate links to blocked/related issues?
  • Are the JIRAs under active development?
    • If not, contact the project's PO and make sure they're aware of the urgency.
  • Do PRs exist for these changes?
    • If so, have they been approved?

Ideally all of the PRs involved in breaking changes would be merged in the same day to avoid breaking the folio-testing environment. Communication is paramount if that is to be achieved, especially as the number of intermodule and inter-team dependencies increase.

While it's helpful for reviewers to help identify potential problems, ensuring that it's safe to merge is ultimately the responsibility of the PR assignee.

Copy link

github-actions bot commented Nov 15, 2023

Jest Unit Test Statistics

    1 files  ±0  146 suites  ±0   4m 5s ⏱️ +6s
384 tests ±0  383 ✔️ ±0  1 💤 ±0  0 ±0 
386 runs  ±0  385 ✔️ ±0  1 💤 ±0  0 ±0 

Results for commit 6344233. ± Comparison against base commit f28d3b2.

This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.
Donors should render Loading component ‑ Donors should render Loading component
Donors should call onChange when donorOrganizationIds changed ‑ Donors should call onChange when donorOrganizationIds changed

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 15, 2023

BigTest Unit Test Statistics

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ±0 

Results for commit 6344233. ± Comparison against base commit f28d3b2.

♻️ This comment has been updated with latest results.

@alisher-epam alisher-epam requested review from a team November 15, 2023 12:56
@alisher-epam alisher-epam requested a review from a team November 16, 2023 06:18
@@ -79,7 +85,8 @@ export function DonorsContainer({
onAddDonors={onAddDonors}
name={id}
searchLabel={searchLabel}
visibleColumns={visibleColumns}
visibleColumns={pluginVisibleColumnsProp}
Copy link
Contributor

Choose a reason for hiding this comment

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

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, I need it. Because Donors form visible columns include unassignDonor column name like below
Screenshot 2023-11-16 at 1 12 42 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean <DonorsLookup> has the default visibleColumns prop with the same value you are provided as pluginVisibleColumnsProp. You don't have to pass visibleColumns value to the <DonorsLookup> here at all, right?

@@ -12,10 +13,19 @@ import { defaultColumnMapping } from './constants';
import { DonorsContainer } from './DonorsContainer';
import { useFetchDonors } from './hooks';

export function Donors({ name, donorOrganizationIds, ...rest }) {
export function Donors({ name, donorOrganizationIds, onChange, ...rest }) {
const [donorIds, setDonorIds] = useState(donorOrganizationIds);
const { donors, isLoading } = useFetchDonors(donorIds);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please apply some changes to improve the UX (keep prev changes in the MCL and display loading indicator inside the list):

// useFetchDonors.js

export const useFetchDonors = (donorOrganizationIds = DEFAULT_DATA, options = {}) => {
 ..
    {
       enabled: Boolean(donorOrganizationIds.length)
       ...options,
     },
  ..
  );

// ------
// Donors.js

..

  const { donors, isFetching } = useFetchDonors(donorIds, { keepPreviousData: true });

..

  // Remove this
  if (isLoading) {
    return <Loading />;
  }

..

  <FieldArray
     ..
     component={DonorsContainer}
     loading={isFetching}
     ..
   />

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 is a very nice improvement. Thank you for your advice.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

94.4% 94.4% Coverage
0.0% 0.0% Duplication

@alisher-epam alisher-epam merged commit fcf089d into master Nov 16, 2023
5 checks passed
@alisher-epam alisher-epam deleted the UISACQCOMP-168 branch November 16, 2023 14:04
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.

4 participants