feat: refactor conversations page into a workbench layout and implement workspace switching
- Migrate ConversationsPage to use ConversationWorkbench component. - Create WorkbenchLayout to handle authentication and layout for workbench. - Add WorkbenchPage to render ConversationWorkbench. - Implement WorkspaceSwitcher for switching between dashboard and workbench. - Update AuthProvider to manage authentication for both dashboard and workbench routes. - Enhance WorkbenchHeader with user menu and workspace switcher. - Add tests for workspace switcher and auth provider functionality. - Update translations for workspace labels in English and Chinese. - Exclude e2e tests from TypeScript compilation.
This commit is contained in:
@@ -35,7 +35,10 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const [session, setSession] = useState<AuthSession | null>(null)
|
||||
const [ready, setReady] = useState(false)
|
||||
const isDashboardLoginRoute = pathname?.startsWith("/dashboard/login") ?? false
|
||||
const requiresAuth = (pathname?.startsWith("/dashboard") ?? false) && !isDashboardLoginRoute
|
||||
const requiresAuth =
|
||||
((pathname?.startsWith("/dashboard") ?? false) ||
|
||||
(pathname?.startsWith("/workbench") ?? false)) &&
|
||||
!isDashboardLoginRoute
|
||||
|
||||
const refreshProfile = useCallback(async () => {
|
||||
const stored = readSession()
|
||||
@@ -52,16 +55,21 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
user: profile.user,
|
||||
permissions: profile.permissions,
|
||||
roles: profile.roles,
|
||||
accessToken: profile.accessToken || stored.accessToken,
|
||||
expiresAt: profile.expiresAt || stored.expiresAt,
|
||||
}
|
||||
writeSession(nextSession)
|
||||
setSession(nextSession)
|
||||
} catch {
|
||||
clearSession()
|
||||
setSession(null)
|
||||
if (requiresAuth) {
|
||||
startTransition(() => {
|
||||
router.replace("/dashboard/login")
|
||||
})
|
||||
} catch (error) {
|
||||
const errorCode = (error as Error & { errorCode?: number }).errorCode
|
||||
if (errorCode === 3000 || errorCode === 3002) {
|
||||
clearSession()
|
||||
setSession(null)
|
||||
if (requiresAuth) {
|
||||
startTransition(() => {
|
||||
router.replace("/dashboard/login")
|
||||
})
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
setReady(true)
|
||||
|
||||
Reference in New Issue
Block a user