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

tech-story: [M3-8939] - Get rid of DrawerContent #11338

Merged
merged 8 commits into from
Dec 2, 2024

Conversation

abailly-akamai
Copy link
Contributor

@abailly-akamai abailly-akamai commented Nov 27, 2024

Description 📝

Small PR as a follow up to #11273 (loading patterns in Drawer) to clean up remaining legacy Drawer patterns.

DrawerContent was meant to handle loading states and errors, which is not handled directly within Drawer 🧹

Changes 🔄

  • Delete DrawerContent
  • Achieve parity for a variety of components
  • Cleanup Kube ACL Drawer
  • fix useKubernetesKubeConfigQuery typo

Preview 📷

No visual changes/regressions expected as part fo this PR

How to test 🧪

Verification steps

  • Verify kubernetes summary drawers (/kubernetes/clusters/{id}/summary
    • in Summary Panel, click on "view"
    • in Summary Panel, click on "Control Plane ACL: {CTA}"
  • Verify managed monitor history drawer (/managed/monitors)
    • use MSW if no data
    • monitors table > "View Issue History"
Author Checklists

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@abailly-akamai abailly-akamai self-assigned this Nov 27, 2024
errorText={Array.isArray(error) ? error[0].reason : error}
/>
)
) : 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.

addition of error handling is the change here

const { classes, cx } = useStyles();
const { children, isFetching, onClose, open, title, wide, ...rest } = props;
const titleID = convertForAria(title);
export const Drawer = React.forwardRef<HTMLDivElement, DrawerProps>(
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 indentation but is a minor change

this should remove A LOT of warnings through the APP with mounted drawers

data: data,
error: isErrorKubernetesACL,
isLoading: isLoadingKubernetesACL,
} = useKubernetesControlPlaneACLQuery(clusterId, showControlPlaneACL);
Copy link
Contributor Author

@abailly-akamai abailly-akamai Nov 27, 2024

Choose a reason for hiding this comment

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

We are already fetching this in the summary, so this query is moot. Error handling is also handled in the summary. We can just receive the acl Data as a prop and use the data for the drawer. This is a place where it does make sense to do so

/>
)}
control={control}
name="acl.enabled"
name="acl.revision-id"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

diff looks that way, but none of this was changed

@@ -196,15 +196,15 @@ export const useAllKubernetesClusterAPIEndpointsQuery = (id: number) => {
});
};

export const useKubenetesKubeConfigQuery = (
export const useKubernetesKubeConfigQuery = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

that typo bothered me!

@abailly-akamai abailly-akamai marked this pull request as ready for review November 27, 2024 18:13
@abailly-akamai abailly-akamai requested a review from a team as a code owner November 27, 2024 18:13
@abailly-akamai abailly-akamai requested review from bnussman-akamai and coliu-akamai and removed request for a team November 27, 2024 18:13
Comment on lines -30 to -36
// refetchOnMount isnt good enough for this query because
// it is already mounted in the rendered Drawer
React.useEffect(() => {
if (open && !isLoading && !isFetching) {
refetch();
}
}, [open]);
Copy link
Member

@bnussman-akamai bnussman-akamai Nov 27, 2024

Choose a reason for hiding this comment

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

Was this removal intentional?

Wondering if we should adopt this pattern here so we can actually use React Query's refetchOnMount

If I'm remembering correctly, we wanted the refetching of the bube config to intentionally be aggressive so that there would be less of a chance of the user seeing an old kube config in the case they re-generate it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it seemed like a bad pattern to me - i'll look around and test this some more.

less of a chance of the user seeing an old kube config in the case they re-generate it

is there a reason why this does not get invalidated properly?

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 this is cleaner? 06b5690

Also makes sure this issue wouldn't be happening in other places it is used

Copy link
Member

@bnussman-akamai bnussman-akamai Nov 27, 2024

Choose a reason for hiding this comment

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

We do invalidate the kube config but, if I remember correctly, the kube config takes some time (a few minutes) on the backend to actually be regenerated

Copy link
Member

Choose a reason for hiding this comment

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

That works too!

Copy link

github-actions bot commented Nov 27, 2024

Coverage Report:
Base Coverage: 86.95%
Current Coverage: 86.92%

@abailly-akamai abailly-akamai requested a review from a team as a code owner November 28, 2024 17:12
@abailly-akamai abailly-akamai requested review from cliu-akamai and removed request for a team November 28, 2024 17:12
@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 462 passing tests on test run #7 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing462 Passing2 Skipped105m 20s

expect(backupItem).toBeVisible();
}
});
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 a pattern we ought to employ instead of await in loops to avoid flakiness (esp with dates). Hopefully this fixes this one for good

clusterId: number,
enabled = false
) =>
useQuery<string, APIError[]>({
...kubernetesQueries.cluster(clusterId)._ctx.kubeconfig,
enabled,
refetchOnMount: true,
retry: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should prob be careful with retry: true as it will fetch indefinitely and not return the error

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

thank you!

✅ confirmed lke drawers
✅ managed monitor history drawer

@coliu-akamai coliu-akamai added the Approved Multiple approvals and ready to merge! label Dec 2, 2024
@abailly-akamai abailly-akamai merged commit 2581eb5 into linode:develop Dec 2, 2024
23 checks passed
Copy link

cypress bot commented Dec 2, 2024

Cloud Manager E2E    Run #6906

Run Properties:  status check passed Passed #6906  •  git commit 2581eb55a2: tech-story: [M3-8939] - Get rid of `DrawerContent` (#11338)
Project Cloud Manager E2E
Branch Review develop
Run status status check passed Passed #6906
Run duration 29m 51s
Commit git commit 2581eb55a2: tech-story: [M3-8939] - Get rid of `DrawerContent` (#11338)
Committer Alban Bailly
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 5
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 465
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Tech Debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants