-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(settings): Remove usage of deprecatedRouteProps
from TeamDetails
settings view & its children
#101134
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
base: master
Are you sure you want to change the base?
ref(settings): Remove usage of deprecatedRouteProps
from TeamDetails
settings view & its children
#101134
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import {cloneElement, isValidElement, useState} from 'react'; | ||
import {useState} from 'react'; | ||
import {Outlet} from 'react-router-dom'; | ||
import styled from '@emotion/styled'; | ||
|
||
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; | ||
|
@@ -11,22 +12,23 @@ import LoadingIndicator from 'sentry/components/loadingIndicator'; | |
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; | ||
import {t, tct} from 'sentry/locale'; | ||
import {space} from 'sentry/styles/space'; | ||
import type {Team} from 'sentry/types/organization'; | ||
import useApi from 'sentry/utils/useApi'; | ||
import {useLocation} from 'sentry/utils/useLocation'; | ||
import useOrganization from 'sentry/utils/useOrganization'; | ||
import {useParams} from 'sentry/utils/useParams'; | ||
import {useTeamsById} from 'sentry/utils/useTeamsById'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
export type TeamDetailsOutletContext = { | ||
team: Team; | ||
}; | ||
|
||
function TeamDetails({children}: Props) { | ||
export default function TeamDetails() { | ||
const api = useApi(); | ||
const params = useParams<{teamId: string}>(); | ||
const location = useLocation(); | ||
const orgSlug = useOrganization().slug; | ||
const [requesting, setRequesting] = useState(false); | ||
const params = useParams<{teamId: string}>(); | ||
const {teams, isLoading, isError} = useTeamsById({slugs: [params.teamId]}); | ||
const team = teams.find(({slug}) => slug === params.teamId); | ||
|
||
|
@@ -110,7 +112,7 @@ function TeamDetails({children}: Props) { | |
</Tabs> | ||
</TabsContainer> | ||
|
||
{isValidElement(children) ? cloneElement<any>(children, {team}) : null} | ||
<Outlet context={{team} satisfies TeamDetailsOutletContext} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the pattern we want? i.e. define a type for the outlet context and then assert that type on the object given to |
||
</div> | ||
) : ( | ||
<Alert.Container> | ||
|
@@ -140,8 +142,6 @@ const TabsContainer = styled('div')` | |
margin-bottom: ${space(2)}; | ||
`; | ||
|
||
export default TeamDetails; | ||
|
||
const RequestAccessWrapper = styled('div')` | ||
display: flex; | ||
justify-content: space-between; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,8 @@ describe('TeamMembers', () => { | |
|
||
it('can add member to team with open membership', async () => { | ||
const org = OrganizationFixture({access: [], openMembership: true}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way we can enforce the types match when |
||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -83,7 +84,8 @@ describe('TeamMembers', () => { | |
|
||
it('can add multiple members with one click on dropdown', async () => { | ||
const org = OrganizationFixture({access: [], openMembership: true}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -99,7 +101,8 @@ describe('TeamMembers', () => { | |
|
||
it('can add member to team with team:admin permission', async () => { | ||
const org = OrganizationFixture({access: ['team:admin'], openMembership: false}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -114,7 +117,8 @@ describe('TeamMembers', () => { | |
|
||
it('can add member to team with org:write permission', async () => { | ||
const org = OrganizationFixture({access: ['org:write'], openMembership: false}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -129,7 +133,8 @@ describe('TeamMembers', () => { | |
|
||
it('can request access to add member to team without permission', async () => { | ||
const org = OrganizationFixture({access: [], openMembership: false}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -149,7 +154,8 @@ describe('TeamMembers', () => { | |
openMembership: false, | ||
}), | ||
}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -169,7 +175,8 @@ describe('TeamMembers', () => { | |
openMembership: true, | ||
}), | ||
}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -186,7 +193,8 @@ describe('TeamMembers', () => { | |
const {organization: org} = initializeOrg({ | ||
organization: OrganizationFixture({access: [], openMembership: true}), | ||
}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -203,7 +211,8 @@ describe('TeamMembers', () => { | |
const {organization: org} = initializeOrg({ | ||
organization: OrganizationFixture({access: [], openMembership: false}), | ||
}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: org, | ||
}); | ||
|
@@ -221,7 +230,8 @@ describe('TeamMembers', () => { | |
url: `/organizations/${organization.slug}/members/${members[0]!.id}/teams/${team.slug}/`, | ||
method: 'DELETE', | ||
}); | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization, | ||
}); | ||
|
@@ -251,7 +261,8 @@ describe('TeamMembers', () => { | |
}); | ||
const organizationMember = OrganizationFixture({access: []}); | ||
|
||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: organizationMember, | ||
}); | ||
|
@@ -283,7 +294,8 @@ describe('TeamMembers', () => { | |
body: [...members, owner], | ||
}); | ||
|
||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization, | ||
}); | ||
|
@@ -309,7 +321,8 @@ describe('TeamMembers', () => { | |
|
||
const orgWithTeamRoles = OrganizationFixture({features: ['team-roles']}); | ||
|
||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization: orgWithTeamRoles, | ||
}); | ||
|
@@ -354,7 +367,8 @@ describe('TeamMembers', () => { | |
body: team2, | ||
}); | ||
|
||
render(<TeamMembers team={team2} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team: team2}, | ||
initialRouterConfig, | ||
organization, | ||
}); | ||
|
@@ -399,7 +413,8 @@ describe('TeamMembers', () => { | |
body: team2, | ||
}); | ||
|
||
render(<TeamMembers team={team2} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team: team2}, | ||
initialRouterConfig, | ||
organization, | ||
}); | ||
|
@@ -411,7 +426,8 @@ describe('TeamMembers', () => { | |
}); | ||
|
||
it('renders a "Pending" tag for pending team members', async () => { | ||
render(<TeamMembers team={team} />, { | ||
render(<TeamMembers />, { | ||
outletContext: {team}, | ||
initialRouterConfig, | ||
organization, | ||
}); | ||
|
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.
TeamNotificationSettings
makes its own API request to fetch the team - I believe this is unnecessary and it can be folded into the same pattern as the other children withuseOutletContext
. @scttcper mind confirming?