Skip to content

Commit ae33949

Browse files
committed
Unify and slightly reword account deletion
The `DeletionCard` was duplicated across the `Profile` for self hosted users, as well as the `Admin` for SaaS. This now uses the same component for both, and slightly rewords the text.
1 parent dd109a6 commit ae33949

File tree

10 files changed

+40
-104
lines changed

10 files changed

+40
-104
lines changed

src/pages/AccountSettings/tabs/Admin/Admin.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { useParams } from 'react-router-dom'
22

33
import { useUser } from 'services/user'
44

5-
import DeletionCard from './DeletionCard'
65
import DetailsSection from './DetailsSection'
76
import GithubIntegrationSection from './GithubIntegrationSection'
87
import ManageAdminCard from './ManageAdminCard'
98
import StudentSection from './StudentSection'
109

10+
import DeletionCard from '../DeletionCard'
11+
1112
function Admin() {
1213
const { owner } = useParams()
1314
const { data: currentUser } = useUser()

src/pages/AccountSettings/tabs/Admin/Admin.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ vi.mock('./GithubIntegrationSection', () => ({
1414
default: () => 'GithubIntegrationSection',
1515
}))
1616
vi.mock('./ManageAdminCard', () => ({ default: () => 'ManageAdminCard' }))
17-
vi.mock('./DeletionCard', () => ({ default: () => 'DeletionCard' }))
17+
vi.mock('../DeletionCard', () => ({ default: () => 'DeletionCard' }))
1818

1919
const user = {
2020
me: {

src/pages/AccountSettings/tabs/Admin/DeletionCard/DeletionCard.tsx

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/pages/AccountSettings/tabs/Admin/DeletionCard/DeletionCard.test.tsx renamed to src/pages/AccountSettings/tabs/DeletionCard/DeletionCard.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('DeletionCard', () => {
2222
render(<DeletionCard isPersonalSettings={true} />, { wrapper })
2323

2424
const message = screen.getByText(
25-
/Erase all my personal content and projects./
25+
/Erase my personal account and all my repositories./
2626
)
2727
expect(message).toBeInTheDocument()
2828
})
@@ -33,7 +33,7 @@ describe('DeletionCard', () => {
3333
render(<DeletionCard isPersonalSettings={false} />, { wrapper })
3434

3535
const message = screen.getByText(
36-
/Erase all my organization content and projects./
36+
/Erase organization and all its repositories./
3737
)
3838
expect(message).toBeInTheDocument()
3939
})
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import Card from 'old_ui/Card'
2+
import A from 'ui/A'
3+
4+
interface DeletionCardProps {
5+
isPersonalSettings: boolean
6+
}
7+
8+
function DeletionCard({ isPersonalSettings }: DeletionCardProps) {
9+
return (
10+
<div className="flex flex-col gap-4">
11+
<h2 className="text-lg font-semibold">
12+
{isPersonalSettings ? 'Delete account' : 'Delete organization'}
13+
</h2>
14+
<Card>
15+
<p>
16+
{isPersonalSettings
17+
? 'Erase my personal account and all my repositories. '
18+
: 'Erase organization and all its repositories. '}
19+
<A
20+
to={{ pageName: 'support' }}
21+
hook="contact-support-link"
22+
isExternal
23+
>
24+
Contact support
25+
</A>
26+
</p>
27+
</Card>
28+
</div>
29+
)
30+
}
31+
32+
export default DeletionCard

src/pages/AccountSettings/tabs/Profile/DeletionCard/DeletionCard.test.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/pages/AccountSettings/tabs/Profile/DeletionCard/DeletionCard.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/pages/AccountSettings/tabs/Profile/DeletionCard/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/pages/AccountSettings/tabs/Profile/Profile.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { SelfHostedCurrentUserQueryOpts } from 'services/selfHosted/SelfHostedCu
66

77
import ActivationBanner from './ActivationBanner'
88
import AdminBanner from './AdminBanner'
9-
import DeletionCard from './DeletionCard'
109
import NameEmailCard from './NameEmailCard'
1110

11+
import DeletionCard from '../DeletionCard'
12+
1213
function Profile({ provider, owner }) {
1314
const yamlTab = `/account/${provider}/${owner}/yaml/`
1415
const { data: currentUser } = useSuspenseQueryV5(
@@ -27,7 +28,7 @@ function Profile({ provider, owner }) {
2728
{currentUser?.isAdmin && <AdminBanner />}
2829
<ActivationBanner />
2930
<NameEmailCard currentUser={currentUser} provider={provider} />
30-
<DeletionCard />
31+
<DeletionCard isPersonalSettings={isPersonalSettings} />
3132
</div>
3233
)
3334
}

0 commit comments

Comments
 (0)