Skip to content

Commit

Permalink
feat: optimize code
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe committed Jul 17, 2024
1 parent c9441dd commit 8506b42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const FeatureCards = ({
const itemsPerRow = 4;
const groupedCardForDisplay = useMemo(() => {
const grouped: Array<{ category?: AppCategory; navLinks: ChromeNavLink[][] }> = [];
// The navLinks has already been sorted based on link / category's order,
// so it is safe to group the links here.
navLinks.forEach((link) => {
let lastGroup = grouped.length ? grouped[grouped.length - 1] : undefined;
if (!lastGroup || lastGroup.category !== link.category) {
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export class ManagementPlugin implements Plugin<ManagementSetup, ManagementStart
.toPromise();
const navLinks = navGroupMap[DEFAULT_NAV_GROUPS.settingsAndSetup.id]?.navLinks;
const fulfilledNavLink = fulfillRegistrationLinksToChromeNavLinks(
(navLinks || []).filter((navLink) => navLink.id !== settingsLandingPageId),
navLinks || [],
coreStart.chrome.navLinks.getAll()
);
).filter((navLink) => navLink.id !== settingsLandingPageId && !navLink.hidden);

return renderApp({
mountElement: params.element,
Expand Down Expand Up @@ -157,9 +157,9 @@ export class ManagementPlugin implements Plugin<ManagementSetup, ManagementStart
.toPromise();
const navLinks = navGroupMap[DEFAULT_NAV_GROUPS.dataAdministration.id]?.navLinks;
const fulfilledNavLink = fulfillRegistrationLinksToChromeNavLinks(
(navLinks || []).filter((navLink) => navLink.id !== dataAdministrationLandingPageId),
navLinks || [],
coreStart.chrome.navLinks.getAll()
);
).filter((navLink) => navLink.id !== dataAdministrationLandingPageId && !navLink.hidden);

return renderApp({
mountElement: params.element,
Expand Down

0 comments on commit 8506b42

Please sign in to comment.