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

refactor: [M3-5181] - React Query for Events #9949

Merged
merged 54 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
eeb1b48
events landing
bnussman Nov 30, 2023
66ab52f
add linode events support with filter
bnussman Nov 30, 2023
5a36fcd
clean up
bnussman Nov 30, 2023
1ea1623
add poller
bnussman Nov 30, 2023
9406162
add event handlers and cache updater
bnussman Nov 30, 2023
f84beff
hook up toasts
bnussman Nov 30, 2023
3b0b1b8
fix bug by removing early return and start refactoring
bnussman Dec 1, 2023
37b94b5
refactor event consumers
bnussman Dec 1, 2023
f32ecad
finish general refactor
bnussman Dec 1, 2023
802e6c3
optimize
bnussman Dec 1, 2023
4c033dc
Merge branch 'develop' into react-query-events-poc
bnussman Dec 1, 2023
9a9637a
fixes and clean up
bnussman Dec 1, 2023
5dec126
fix cache updater bug
bnussman Dec 1, 2023
69b9293
Merge branch 'develop' into react-query-events-poc
bnussman Dec 1, 2023
0a15104
make the query updater update all queries
bnussman Dec 1, 2023
9b4ed1b
poc: use cursor based pagination
bnussman Dec 1, 2023
d20da52
Merge branch 'develop' into react-query-events-poc
bnussman Dec 1, 2023
e2513db
Merge branch 'develop' into react-query-events-poc
bnussman Dec 14, 2023
eaeba01
remove old code
bnussman Dec 14, 2023
10fb540
use `id` for cusour based pagination and clean up
bnussman Dec 14, 2023
fab6a54
move things around to minimize re-renders
bnussman Dec 14, 2023
da30f27
handle accounts with no events and fix queryKey bug
bnussman Dec 14, 2023
7f2911d
fix incorrect query key causing `useInProgressEvents` not to work
bnussman Dec 14, 2023
bd73b74
add comments
bnussman Dec 15, 2023
99dd84b
comment and test filtering
bnussman Dec 15, 2023
8c2972f
Merge branch 'develop' into react-query-events-poc
bnussman Dec 15, 2023
62ed209
explain pagination approach
bnussman Dec 15, 2023
94c0980
clean up and test `EventsLanding`
bnussman Dec 18, 2023
9bbc27b
remove `src/__data__/events.ts`
bnussman Jan 5, 2024
7d9db1d
remove more unused helper functions
bnussman Jan 5, 2024
0a93db9
reorganize helper functions
bnussman Jan 5, 2024
4d83772
move `generatePollingFilter` to `event.helpers.ts`
bnussman Jan 5, 2024
99218bd
extract helper into `getExistingEventDataForPollingFilterGenerator` a…
bnussman Jan 5, 2024
d76f7e8
handle and test in-progress event edge case
bnussman Jan 5, 2024
9ae89a6
Merge branch 'develop' into react-query-events-poc
bnussman Jan 11, 2024
c003474
remove outdated comment
bnussman Jan 11, 2024
8562e49
Merge branch 'develop' into react-query-events-poc
bnussman Jan 17, 2024
7675ec5
don't pass an empty object if we don't have a `pageParam`
bnussman Jan 17, 2024
7bf1c84
improve interval defaults
bnussman Jan 17, 2024
e4a9efe
disable query that is for reading data only
bnussman Jan 17, 2024
8306304
Merge branch 'develop' into react-query-events-poc
bnussman Jan 19, 2024
ff3b051
make polling backoff match existing backoff
bnussman Jan 19, 2024
3197846
clean up interval hooks
bnussman Jan 19, 2024
8d7436e
simplify polling interval
bnussman Jan 19, 2024
3e99b0f
fixing duplicate pull due to rules of hooks
bnussman Jan 22, 2024
ad58673
Merge branch 'develop' into react-query-events-poc
bnussman Jan 22, 2024
c0e0c34
clean up new polling interval
bnussman Jan 22, 2024
527ab37
add changesets
bnussman Jan 23, 2024
f4ad829
Merge branch 'develop' into react-query-events-poc
bnussman Jan 23, 2024
7a9fdbf
clean up mount timestamp
bnussman Jan 23, 2024
9086b93
clean up query key for poller
bnussman Jan 23, 2024
126f7b8
rename `resetEventsPolling` to `checkForNewEvents`
bnussman Jan 23, 2024
3c8886a
Apply suggestions from @jdamore-linode
bnussman-akamai Jan 26, 2024
97b7455
Update packages/manager/src/queries/events/events.ts
bnussman-akamai Jan 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-9949-fixed-1706018014628.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Fixed
---

Removed incorrect `_initial` property on `Event` type ([#9949](https://github.com/linode/manager/pull/9949))
1 change: 0 additions & 1 deletion packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ export interface Event {
time_remaining: null | string;
username: string | null;
secondary_entity: Entity | null;
_initial?: boolean;
message: string | null;
}
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

React Query for Events ([#9949](https://github.com/linode/manager/pull/9949))
1 change: 0 additions & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"rxjs": "^5.5.6",
Copy link
Contributor

Choose a reason for hiding this comment

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

Glad we can still remove this 🎉

Copy link
Member Author

Choose a reason for hiding this comment

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

Me too 😮‍💨

"sanitize-html": "^2.11.0",
"search-string": "^3.1.0",
"simple-git": "^3.19.0",
Expand Down
22 changes: 10 additions & 12 deletions packages/manager/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ import { GoTo } from './GoTo';
import { MainContent } from './MainContent';
import { SplashScreen } from './components/SplashScreen';
import { useAdobeAnalytics } from './hooks/useAdobeAnalytics';
import { useEventHandlers } from './hooks/useEventHandlers';
import { useGlobalKeyboardListener } from './hooks/useGlobalKeyboardListener';
import { useInitialRequests } from './hooks/useInitialRequests';
import { useNewRelic } from './hooks/useNewRelic';
import { useToastNotifications } from './hooks/useToastNotifications';
import { useEventsPoller } from './queries/events/events';
import { useSetupFeatureFlags } from './useSetupFeatureFlags';

// Ensure component's display name is 'App'
Expand All @@ -31,14 +29,6 @@ const BaseApp = withDocumentTitleProvider(

const { areFeatureFlagsLoading } = useSetupFeatureFlags();

const { goToOpen, setGoToOpen } = useGlobalKeyboardListener();

useEventHandlers();
useToastNotifications();

useAdobeAnalytics();
useNewRelic();

if (isLoading || areFeatureFlagsLoading) {
return <SplashScreen />;
}
Expand All @@ -56,11 +46,19 @@ const BaseApp = withDocumentTitleProvider(
Opens an external site in a new window
</span>
</div>
<GoTo onClose={() => setGoToOpen(false)} open={goToOpen} />
<GoTo />
<DocumentTitleSegment segment="Akamai Cloud Manager" />
<MainContent />
<GlobalListeners />
</ErrorBoundary>
);
})
)
);

const GlobalListeners = () => {
useEventsPoller();
useAdobeAnalytics();
useNewRelic();
return null;
};
22 changes: 12 additions & 10 deletions packages/manager/src/GoTo.tsx
Copy link
Contributor

Choose a reason for hiding this comment

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

Changes here aren't directly related to the ticket; should we move them to another PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I probably should have done that. I chose to move some state around to reduce the number of renders caused by state changes in App.tsx. I think the change is pretty safe so I'm okay with leaving it if everyone else is

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Dialog from '@mui/material/Dialog';
import { Theme } from '@mui/material/styles';
import { makeStyles } from 'tss-react/mui';
import * as React from 'react';
import { useHistory } from 'react-router-dom';
import { makeStyles } from 'tss-react/mui';

import EnhancedSelect, { Item } from 'src/components/EnhancedSelect/Select';

import { useAccountManagement } from './hooks/useAccountManagement';
import { useFlags } from './hooks/useFlags';
import { useGlobalKeyboardListener } from './hooks/useGlobalKeyboardListener';

const useStyles = makeStyles()((theme: Theme) => ({
input: {
Expand Down Expand Up @@ -53,20 +54,21 @@ const useStyles = makeStyles()((theme: Theme) => ({
},
}));

interface Props {
onClose: () => void;
open: boolean;
}

export const GoTo = React.memo((props: Props) => {
export const GoTo = React.memo(() => {
const { classes } = useStyles();
const routerHistory = useHistory();
const { _hasAccountAccess, _isManagedAccount } = useAccountManagement();
const flags = useFlags();

const { goToOpen, setGoToOpen } = useGlobalKeyboardListener();

const onClose = () => {
setGoToOpen(false);
};

const onSelect = (item: Item<string>) => {
routerHistory.push(item.value);
props.onClose();
onClose();
};

const links = React.useMemo(
Expand Down Expand Up @@ -169,8 +171,8 @@ export const GoTo = React.memo((props: Props) => {
return (
<Dialog
classes={dialogClasses}
onClose={props.onClose}
open={props.open}
onClose={onClose}
open={goToOpen}
title="Go To..."
>
{/* I was about to put a "@todo" item for mobile display, but realized
Expand Down
6 changes: 4 additions & 2 deletions packages/manager/src/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ const Help = React.lazy(() =>
const SearchLanding = React.lazy(
() => import('src/features/Search/SearchLanding')
);
const EventsLanding = React.lazy(
() => import('src/features/Events/EventsLanding')
const EventsLanding = React.lazy(() =>
import('src/features/Events/EventsLanding').then((module) => ({
default: module.EventsLanding,
}))
);
const AccountActivationLanding = React.lazy(
() => import('src/components/AccountActivation/AccountActivationLanding')
Expand Down
Loading