-
Notifications
You must be signed in to change notification settings - Fork 3.5k
improvement(ui): fix nav loading flash, skeleton mismatches, and React anti-patterns across resource pages #3864
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
Open
waleedlatif1
wants to merge
6
commits into
staging
Choose a base branch
from
feat/kb-loading
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+166
−373
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3865ee7
improvement(ui): fix nav loading flash, skeleton mismatches, and Reac…
waleedlatif1 473cfcc
fix(kb): use active scope in useWorkspaceFileRecord to share cache wi…
waleedlatif1 ac37210
fix(logs,kb,tasks): lazy-init useRef for URL param, add cold-path doc…
waleedlatif1 2af124c
fix(files): redirect to files list when file record not found in viewer
waleedlatif1 4bf57d7
revert(files): remove useEffect redirect from file-viewer, keep simpl…
waleedlatif1 3d5b7f2
fix(scheduled-tasks): correct useMemo dep from schedule?.cronExpressi…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 1 addition & 31 deletions
32
apps/sim/app/workspace/[workspaceId]/files/[fileId]/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,9 @@ | ||
| import type { Metadata } from 'next' | ||
| import { redirect } from 'next/navigation' | ||
| import { getSession } from '@/lib/auth' | ||
| import { verifyWorkspaceMembership } from '@/app/api/workflows/utils' | ||
| import { getUserPermissionConfig } from '@/ee/access-control/utils/permission-check' | ||
| import { Files } from '../files' | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: 'Files', | ||
| robots: { index: false }, | ||
| } | ||
|
|
||
| interface FileDetailPageProps { | ||
| params: Promise<{ | ||
| workspaceId: string | ||
| fileId: string | ||
| }> | ||
| } | ||
|
|
||
| export default async function FileDetailPage({ params }: FileDetailPageProps) { | ||
| const { workspaceId } = await params | ||
| const session = await getSession() | ||
|
|
||
| if (!session?.user?.id) { | ||
| redirect('/') | ||
| } | ||
|
|
||
| const hasPermission = await verifyWorkspaceMembership(session.user.id, workspaceId) | ||
| if (!hasPermission) { | ||
| redirect('/') | ||
| } | ||
|
|
||
| const permissionConfig = await getUserPermissionConfig(session.user.id) | ||
| if (permissionConfig?.hideFilesTab) { | ||
| redirect(`/workspace/${workspaceId}`) | ||
| } | ||
|
|
||
| return <Files /> | ||
| } | ||
| export default Files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 2 additions & 39 deletions
41
apps/sim/app/workspace/[workspaceId]/files/[fileId]/view/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,9 @@ | ||
| import type { Metadata } from 'next' | ||
| import { redirect, unstable_rethrow } from 'next/navigation' | ||
| import { getSession } from '@/lib/auth' | ||
| import { getWorkspaceFile } from '@/lib/uploads/contexts/workspace' | ||
| import { verifyWorkspaceMembership } from '@/app/api/workflows/utils' | ||
| import { FileViewer } from '@/app/workspace/[workspaceId]/files/[fileId]/view/file-viewer' | ||
| import { FileViewer } from './file-viewer' | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: 'File', | ||
| robots: { index: false }, | ||
| } | ||
|
|
||
| interface FileViewerPageProps { | ||
| params: Promise<{ | ||
| workspaceId: string | ||
| fileId: string | ||
| }> | ||
| } | ||
|
|
||
| export default async function FileViewerPage({ params }: FileViewerPageProps) { | ||
| const { workspaceId, fileId } = await params | ||
|
|
||
| const session = await getSession() | ||
| if (!session?.user?.id) { | ||
| redirect('/') | ||
| } | ||
|
|
||
| const hasPermission = await verifyWorkspaceMembership(session.user.id, workspaceId) | ||
| if (!hasPermission) { | ||
| redirect(`/workspace/${workspaceId}`) | ||
| } | ||
|
|
||
| let fileRecord: Awaited<ReturnType<typeof getWorkspaceFile>> | ||
| try { | ||
| fileRecord = await getWorkspaceFile(workspaceId, fileId) | ||
| } catch (error) { | ||
| unstable_rethrow(error) | ||
| redirect(`/workspace/${workspaceId}`) | ||
| } | ||
|
|
||
| if (!fileRecord) { | ||
| redirect(`/workspace/${workspaceId}`) | ||
| } | ||
|
|
||
| return <FileViewer file={fileRecord} /> | ||
| } | ||
| export default FileViewer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,9 @@ | ||
| import type { Metadata } from 'next' | ||
| import { redirect } from 'next/navigation' | ||
| import { getSession } from '@/lib/auth' | ||
| import { verifyWorkspaceMembership } from '@/app/api/workflows/utils' | ||
| import { getUserPermissionConfig } from '@/ee/access-control/utils/permission-check' | ||
| import { Files } from './files' | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: 'Files', | ||
| robots: { index: false }, | ||
| } | ||
|
|
||
| interface FilesPageProps { | ||
| params: Promise<{ | ||
| workspaceId: string | ||
| }> | ||
| } | ||
|
|
||
| export default async function FilesPage({ params }: FilesPageProps) { | ||
| const { workspaceId } = await params | ||
| const session = await getSession() | ||
|
|
||
| if (!session?.user?.id) { | ||
| redirect('/') | ||
| } | ||
|
|
||
| const hasPermission = await verifyWorkspaceMembership(session.user.id, workspaceId) | ||
| if (!hasPermission) { | ||
| redirect('/') | ||
| } | ||
|
|
||
| const permissionConfig = await getUserPermissionConfig(session.user.id) | ||
| if (permissionConfig?.hideFilesTab) { | ||
| redirect(`/workspace/${workspaceId}`) | ||
| } | ||
|
|
||
| return <Files /> | ||
| } | ||
| export default Files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,8 @@ | ||
| import type { Metadata } from 'next' | ||
| import { redirect } from 'next/navigation' | ||
| import { getSession } from '@/lib/auth' | ||
| import { verifyWorkspaceMembership } from '@/app/api/workflows/utils' | ||
| import { Home } from './home' | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: 'Home', | ||
| } | ||
|
|
||
| interface HomePageProps { | ||
| params: Promise<{ | ||
| workspaceId: string | ||
| }> | ||
| } | ||
|
|
||
| export default async function HomePage({ params }: HomePageProps) { | ||
| const { workspaceId } = await params | ||
| const session = await getSession() | ||
|
|
||
| if (!session?.user?.id) { | ||
| redirect('/') | ||
| } | ||
|
|
||
| const hasPermission = await verifyWorkspaceMembership(session.user.id, workspaceId) | ||
| if (!hasPermission) { | ||
| redirect('/') | ||
| } | ||
|
|
||
| return <Home key='home' /> | ||
| } | ||
| export default Home | ||
waleedlatif1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.