-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
ref(tsc): convert orgDashboards to FC #84351
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
@@ -123,6 +125,11 @@ describe('Dashboards > Detail', function () { | |||
}); | |||
|
|||
it('assigns unique IDs to all widgets so grid keys are unique', async function () { | |||
const router = RouterFixture({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to update all these routers bc they all depend on OrgDashboards
Bundle ReportChanges will decrease total bundle size by 80.01kB (-0.24%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: app-webpack-bundle-array-pushAssets Changed:
Files in
Files in
Files in
|
const location = useLocation(); | ||
const organization = useOrganization(); | ||
const navigate = useNavigate(); | ||
const {dashboardId} = useParams<{dashboardId: string}>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orgId
wasn't used, so I removed it from the params
useEffect(() => { | ||
if (dashboardId && !isEqual(dashboardId, selectedDashboard?.id)) { | ||
setSelectedDashboardState(null); | ||
} | ||
} | ||
|
||
getEndpoints(): ReturnType<DeprecatedAsyncComponent['getEndpoints']> { | ||
const {organization, params} = this.props; | ||
const url = `/organizations/${organization.slug}/dashboards/`; | ||
const endpoints: ReturnType<DeprecatedAsyncComponent['getEndpoints']> = [ | ||
['dashboards', url], | ||
]; | ||
|
||
if (params.dashboardId) { | ||
endpoints.push(['selectedDashboard', `${url}${params.dashboardId}/`]); | ||
}, [dashboardId, selectedDashboard]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this replaces the componentDidUpdate
endpoints.push(['selectedDashboard', `${url}${params.dashboardId}/`]); | ||
}, [dashboardId, selectedDashboard]); | ||
|
||
// If we don't have a selected dashboard, and one isn't going to arrive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken from old line 125
useEffect(() => { | ||
if (dashboardId || selectedDashboard) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaces the onRequestSuccess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stateKey === 'selectedDashboard'
--> selectedDashboard
}, [dashboardId, location, navigate, selectedDashboard]); | ||
|
||
useEffect(() => { | ||
if (!organization.features.includes('dashboards-basic')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved from old line 187
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(had to put the navigate
in a useEffect
)
let dashboard = selectedDashboard; | ||
if (isDashboardsError || isSelectedDashboardError) { | ||
const notFound = | ||
dashboardsError?.status === 404 || selectedDashboardError?.status === 404; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're checking for an error status you'll want retry: false
in the useApiQuery (honestly we should probably have a default setting that doesn't retry for 404s but we don't right now)
|
||
const { | ||
data: fetchedSelectedDashboard, | ||
isPending: isSelectedDashboardPending, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the query is disabled, this will always be true. If that's not intended use isLoading
instead (which will only be true when it's actively fetching)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to isLoading
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to see this converted! Caching feels good for this page
ref https://github.com/getsentry/frontend-tsc/issues/2