-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Added URL routing to staff modal email notification tab #25572
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: main
Are you sure you want to change the base?
Changes from all commits
2b58ab4
aeb6202
d983acb
c073a8e
0052cd3
994848f
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 |
|---|---|---|
|
|
@@ -162,7 +162,17 @@ export interface UserDetailProps { | |
| } | ||
|
|
||
| const UserDetailModalContent: React.FC<{user: User}> = ({user}) => { | ||
| const {updateRoute} = useRouting(); | ||
| const {updateRoute, route} = useRouting(); | ||
|
|
||
| const getTabFromPath = (path: string): string => { | ||
| const lastSegment = path.split('/').pop() || ''; | ||
|
|
||
| if (lastSegment === 'social-links' || lastSegment === 'email-notifications') { | ||
| return lastSegment; | ||
| } | ||
|
|
||
| return 'profile'; | ||
| }; | ||
| const {ownerUser} = useStaffUsers(); | ||
| const {currentUser} = useGlobalData(); | ||
| const handleError = useHandleError(); | ||
|
|
@@ -402,7 +412,15 @@ const UserDetailModalContent: React.FC<{user: User}> = ({user}) => { | |
|
|
||
| const suspendedText = formState.status === 'inactive' ? ' (Suspended)' : ''; | ||
|
|
||
| const [selectedTab, setSelectedTab] = useState<string>('profile'); | ||
| const initialTab = getTabFromPath(route); | ||
| const [selectedTab, setSelectedTab] = useState<string>(initialTab); | ||
|
|
||
| const handleTabChange = (newTabId: string) => { | ||
| const urlSegment = newTabId === 'profile' ? '' : `/${newTabId}`; | ||
|
|
||
| updateRoute(`staff/${user.slug}${urlSegment}`); | ||
| setSelectedTab(newTabId); | ||
| }; | ||
|
Comment on lines
+415
to
+423
Contributor
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. Browser back/forward navigation won't update the selected tab. The Apply this fix to synchronize const initialTab = getTabFromPath(route);
const [selectedTab, setSelectedTab] = useState<string>(initialTab);
+
+ // Sync selectedTab with route changes from browser navigation
+ useEffect(() => {
+ const tabFromRoute = getTabFromPath(route);
+ setSelectedTab(tabFromRoute);
+ }, [route]);
const handleTabChange = (newTabId: string) => {You'll need to add -import React, {useCallback, useState} from 'react';
+import React, {useCallback, useEffect, useState} from 'react';
🤖 Prompt for AI Agents |
||
|
|
||
| return ( | ||
| <Modal | ||
|
|
@@ -546,7 +564,7 @@ const UserDetailModalContent: React.FC<{user: User}> = ({user}) => { | |
| contents: <EmailNotificationsTab setUserData={setUserData} user={formState} /> | ||
| } | ||
| ]} | ||
| onTabChange={setSelectedTab} | ||
| onTabChange={handleTabChange} | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,7 +198,7 @@ table.body a.small { | |
| </tr> | ||
| <tr> | ||
| <td style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 12px; vertical-align: top;\\"> | ||
| <p class=\\"small\\" style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 18px; font-size: 12px; color: #7C8B9A; font-weight: normal; margin: 0;\\">Don’t want to receive these emails? Manage your preferences <a class=\\"small\\" href=\\"http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs\\" style=\\"text-decoration: underline; color: #7C8B9A; font-size: 12px;\\">here</a>.</p> | ||
| <p class=\\"small\\" style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 18px; font-size: 12px; color: #7C8B9A; font-weight: normal; margin: 0;\\">Don’t want to receive these emails? Manage your preferences <a class=\\"small\\" href=\\"http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs/email-notifications\\" style=\\"text-decoration: underline; color: #7C8B9A; font-size: 12px;\\">here</a>.</p> | ||
| </td> | ||
| </tr> | ||
|
|
||
|
|
@@ -229,7 +229,7 @@ You have been recommended by Other Ghost Site. | |
| --- | ||
|
|
||
| Sent to [email protected] from 127.0.0.1. | ||
| If you would no longer like to receive these notifications you can adjust your settings at http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs. | ||
| If you would no longer like to receive these notifications you can adjust your settings at http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs/email-notifications. | ||
| " | ||
| `; | ||
|
|
||
|
|
@@ -446,7 +446,7 @@ table.body a.small { | |
| </tr> | ||
| <tr> | ||
| <td style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 12px; vertical-align: top;\\"> | ||
| <p class=\\"small\\" style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 18px; font-size: 12px; color: #7C8B9A; font-weight: normal; margin: 0;\\">Don’t want to receive these emails? Manage your preferences <a class=\\"small\\" href=\\"http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs\\" style=\\"text-decoration: underline; color: #7C8B9A; font-size: 12px;\\">here</a>.</p> | ||
| <p class=\\"small\\" style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 18px; font-size: 12px; color: #7C8B9A; font-weight: normal; margin: 0;\\">Don’t want to receive these emails? Manage your preferences <a class=\\"small\\" href=\\"http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs/email-notifications\\" style=\\"text-decoration: underline; color: #7C8B9A; font-size: 12px;\\">here</a>.</p> | ||
| </td> | ||
| </tr> | ||
|
|
||
|
|
@@ -669,7 +669,7 @@ table.body a.small { | |
| </tr> | ||
| <tr> | ||
| <td style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 12px; vertical-align: top;\\"> | ||
| <p class=\\"small\\" style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 18px; font-size: 12px; color: #7C8B9A; font-weight: normal; margin: 0;\\">Don’t want to receive these emails? Manage your preferences <a class=\\"small\\" href=\\"http://127.0.0.1:2369/ghost/#/settings/staff/smith-wellingsworth\\" style=\\"text-decoration: underline; color: #7C8B9A; font-size: 12px;\\">here</a>.</p> | ||
| <p class=\\"small\\" style=\\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 18px; font-size: 12px; color: #7C8B9A; font-weight: normal; margin: 0;\\">Don’t want to receive these emails? Manage your preferences <a class=\\"small\\" href=\\"http://127.0.0.1:2369/ghost/#/settings/staff/smith-wellingsworth/email-notifications\\" style=\\"text-decoration: underline; color: #7C8B9A; font-size: 12px;\\">here</a>.</p> | ||
| </td> | ||
| </tr> | ||
|
|
||
|
|
@@ -700,7 +700,7 @@ You have been recommended by Other Ghost Site. | |
| --- | ||
|
|
||
| Sent to [email protected] from 127.0.0.1. | ||
| If you would no longer like to receive these notifications you can adjust your settings at http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs. | ||
| If you would no longer like to receive these notifications you can adjust your settings at http://127.0.0.1:2369/ghost/#/settings/staff/joe-bloggs/email-notifications. | ||
| " | ||
| `; | ||
|
|
||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 85
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 85
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 163
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 85
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 228
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 3115
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 1367
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 1751
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 40
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 40
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 1648
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 447
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 819
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 167
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 628
🏁 Script executed:
# See the full user-detail-modal.tsx to understand the complete picture wc -l apps/admin-x-settings/src/components/settings/general/user-detail-modal.tsxRepository: TryGhost/Ghost
Length of output: 137
🏁 Script executed:
Repository: TryGhost/Ghost
Length of output: 413
Remove the unused
/staff/:slug/editroute or document its purpose.The route
'staff/:slug/edit': 'UserDetailModal'defined in settings-router.tsx is never navigated to by the application. ThegetTabFromPathfunction doesn't recognize 'edit' as a segment, causing it to default to 'profile', but more importantly, no code in the codebase ever generates navigation to this URL. ThehandleTabChangefunction navigates to either the basestaff/{slug}(for profile tab) orstaff/{slug}/{tab}(for other tabs), but never includes an 'edit' segment. This route appears to be dead code and should either be removed or its purpose documented if it exists for backwards compatibility.🤖 Prompt for AI Agents