remove HomeDirSelector, use HOME_DIR for super admin file browser root
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Breadcrumb } from './components/Breadcrumb';
|
||||
import { Toolbar } from './components/Toolbar';
|
||||
import { HomeDirSelector } from './components/HomeDirSelector';
|
||||
import { UploadProgress } from './components/UploadProgress';
|
||||
import { FileViewContainer } from './components/FileViewContainer';
|
||||
import { TaskRunnerDialog } from './components/TaskRunnerDialog';
|
||||
@@ -26,7 +25,6 @@ export const FileBrowserApp = ({ basePath = '/', rootOverride, initialPath, defa
|
||||
return (
|
||||
<div className="flex flex-col h-full overflow-hidden">
|
||||
<Toolbar fileBrowserManager={fileBrowserManager} />
|
||||
<HomeDirSelector fileBrowserManager={fileBrowserManager} basePath={basePath} />
|
||||
<Breadcrumb
|
||||
path={fileBrowserManager.currentPath}
|
||||
onNavigate={handleNavigate} basePath={basePath} />
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
import { Home, FolderRoot, Code } from 'lucide-react';
|
||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
||||
import type { UseFileBrowserAppType } from '../useFileBrowserApp';
|
||||
|
||||
type HomeDirSelectorProps = {
|
||||
fileBrowserManager: UseFileBrowserAppType;
|
||||
basePath: string;
|
||||
};
|
||||
|
||||
export const HomeDirSelector = ({ fileBrowserManager, basePath }: HomeDirSelectorProps) => {
|
||||
const { user, homeRoot, setHomeRoot, currentPath, setCurrentPath } = fileBrowserManager;
|
||||
|
||||
if (basePath !== '/' || user?.role !== 'Super Admin') return null;
|
||||
|
||||
return (
|
||||
<div className="shrink-0 border-b border-duck-dark/10 px-4 py-2">
|
||||
<RadioGroup
|
||||
value={homeRoot}
|
||||
onValueChange={(v) => {
|
||||
setHomeRoot(v as 'home' | '~' | 'officer.dev');
|
||||
if (currentPath !== '/') setCurrentPath('/');
|
||||
}}
|
||||
className="flex items-center gap-4"
|
||||
>
|
||||
<label className="flex items-center gap-1.5 cursor-pointer text-sm text-duck-dark/70">
|
||||
<RadioGroupItem value="home" />
|
||||
<Home className="h-3.5 w-3.5" />
|
||||
Home dir
|
||||
</label>
|
||||
<label className="flex items-center gap-1.5 cursor-pointer text-sm text-duck-dark/70">
|
||||
<RadioGroupItem value="~" />
|
||||
<FolderRoot className="h-3.5 w-3.5" />~
|
||||
</label>
|
||||
<label className="flex items-center gap-1.5 cursor-pointer text-sm text-duck-dark/70">
|
||||
<RadioGroupItem value="officer.dev" />
|
||||
<Code className="h-3.5 w-3.5" />
|
||||
officer.dev
|
||||
</label>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
+2
-2
@@ -6,7 +6,7 @@ type TaskRunnerDialogProps = {
|
||||
};
|
||||
|
||||
export const TaskRunnerDialog = ({ fileBrowserManager }: TaskRunnerDialogProps) => {
|
||||
const { runningTask, setRunningTask, refresh, homeRoot, currentPath, getEntryAbsPath } = fileBrowserManager;
|
||||
const { runningTask, setRunningTask, refresh, currentPath, getEntryAbsPath } = fileBrowserManager;
|
||||
|
||||
if (!runningTask) return null;
|
||||
|
||||
@@ -23,7 +23,7 @@ export const TaskRunnerDialog = ({ fileBrowserManager }: TaskRunnerDialogProps)
|
||||
entryName={runningTask.entry.name}
|
||||
entryFullPath={getEntryAbsPath(runningTask.entry.name)}
|
||||
entryType={runningTask.entry.type}
|
||||
cwd={{ root: homeRoot, path: currentPath.replace(/^\//, '') }}
|
||||
cwd={{ root: 'home', path: currentPath.replace(/^\//, '') }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ export const useFileBrowserApp = (basePath: string, rootOverride?: string, initi
|
||||
const { user } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [homeRoot, setHomeRoot] = useUserState<HomeRoot>('files/homeRoot', 'home');
|
||||
const homeRoot = 'home';
|
||||
const [globalPath, setGlobalPath] = useUserState<string>('files/currentPath', '/');
|
||||
const [localPath, setLocalPath] = useState(initialPath ?? basePath);
|
||||
const scoped = basePath !== '/';
|
||||
@@ -655,7 +655,7 @@ export const useFileBrowserApp = (basePath: string, rootOverride?: string, initi
|
||||
// Auth
|
||||
user,
|
||||
// Navigation
|
||||
homeRoot, setHomeRoot,
|
||||
homeRoot,
|
||||
currentPath, setCurrentPath,
|
||||
// Directory listing
|
||||
visibleEntries, loading, refresh,
|
||||
@@ -731,4 +731,3 @@ export type UseFileBrowserAppType = ReturnType<typeof useFileBrowserApp>;
|
||||
|
||||
type ClipboardState = { paths: string[]; mode: 'copy' | 'cut' } | null;
|
||||
|
||||
type HomeRoot = 'home' | '~' | 'officer.dev';
|
||||
|
||||
Reference in New Issue
Block a user