Skip to content

Commit

Permalink
feat: open folder explorer in vfolder table component and session lau…
Browse files Browse the repository at this point in the history
…ncher
  • Loading branch information
ironAiken2 committed Oct 7, 2024
1 parent 23b5f81 commit 01135ca
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 8 deletions.
1 change: 1 addition & 0 deletions react/src/components/MainLayout/WebUISider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ const WebUISider: React.FC<WebUISiderProps> = (props) => {
// TODO: After 'SessionListPage' is completed and used as the main page, remove this code
// and change 'job' key to 'session'
location.pathname.split('/')[1] === 'session' ? 'job' : '',
location.pathname.split('/')[1] === 'service' ? 'serving' : '',
]}
items={
// TODO: add plugin menu
Expand Down
37 changes: 29 additions & 8 deletions react/src/components/VFolderTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { useCurrentProjectValue } from '../hooks/useCurrentProject';
import { useEventNotStable } from '../hooks/useEventNotStable';
import { useShadowRoot } from './DefaultProviders';
import Flex from './Flex';
import { useFolderExplorerOpener } from './FolderExplorerOpener';
import HiddenFormItem from './HiddenFormItem';

Check warning on line 11 in react/src/components/VFolderTable.tsx

View workflow job for this annotation

GitHub Actions / coverage

'HiddenFormItem' is defined but never used
import TextHighlighter from './TextHighlighter';
import VFolderPermissionTag from './VFolderPermissionTag';
import { VFolder } from './VFolderSelect';
Expand Down Expand Up @@ -52,6 +54,11 @@ export interface VFolderSelectValue {

export interface AliasMap {
[key: string]: string;
// [key: string]: {
// id: string,
// name: string,
// alias: string,
// };
}

type DataIndex = keyof VFolder;
Expand Down Expand Up @@ -135,6 +142,7 @@ const VFolderTable: React.FC<VFolderTableProps> = ({
const { t } = useTranslation();
const baiRequestWithPromise = useBaiSignedRequestWithPromise();
const currentProject = useCurrentProjectValue();
const { open } = useFolderExplorerOpener();
const [fetchKey, updateFetchKey] = useUpdatableState('first');
const [isPendingRefetch, startRefetchTransition] = useTransition();
const { data: allFolderList } = useSuspenseTanQuery({
Expand Down Expand Up @@ -311,15 +319,27 @@ const VFolderTable: React.FC<VFolderTableProps> = ({
direction="column"
align="stretch"
gap={'xxs'}
style={
showAliasInput && isCurrentRowSelected
? { display: 'inline-flex', height: 70, width: '100%' }
: {
maxWidth: 200,
}
}
style={{
...(showAliasInput && isCurrentRowSelected
? { width: '100%' }
: { maxWidth: 200 }),
}}
>
<TextHighlighter keyword={searchKey}>{value}</TextHighlighter>
<Flex
onClick={() => {
record.id && open(record.id);
}}
style={{
width: 'fit-content',
cursor: 'pointer',
}}
>
<Typography.Text
style={{ whiteSpace: 'pre-line', wordBreak: 'break-all' }}
>
<TextHighlighter keyword={searchKey}>{value}</TextHighlighter>
</Typography.Text>
</Flex>
{showAliasInput && isCurrentRowSelected && (
<Form.Item
noStyle
Expand Down Expand Up @@ -399,6 +419,7 @@ const VFolderTable: React.FC<VFolderTableProps> = ({
record.name,
internalForm.getFieldValue(getRowKey(record)),
)}
style={{ margin: 0 }}
>
<Input
onClick={(e) => {
Expand Down
34 changes: 34 additions & 0 deletions react/src/pages/SessionLauncherPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import EnvVarFormList, {
EnvVarFormListValue,
} from '../components/EnvVarFormList';
import Flex from '../components/Flex';
import { useFolderExplorerOpener } from '../components/FolderExplorerOpener';
import ImageEnvironmentSelectFormItems, {
ImageEnvironmentFormInput,
} from '../components/ImageEnvironmentSelectFormItems';
Expand Down Expand Up @@ -53,6 +54,7 @@ import { useThemeMode } from '../hooks/useThemeMode';
import customCSS from './SessionLauncherPage.css?raw';
import {
DoubleRightOutlined,
FolderOutlined,
LeftOutlined,
PlayCircleFilled,
PlayCircleOutlined,
Expand Down Expand Up @@ -178,6 +180,7 @@ const SessionLauncherPage = () => {
const mainContentDivRef = useAtomValue(mainContentDivRefState);
const baiClient = useSuspendedBackendaiClient();
const currentUserRole = useCurrentUserRole();
const { open } = useFolderExplorerOpener();

Check warning on line 183 in react/src/pages/SessionLauncherPage.tsx

View workflow job for this annotation

GitHub Actions / coverage

'open' is assigned a value but never used

const [isStartingSession, setIsStartingSession] = useState(false);
const INITIAL_FORM_VALUES: SessionLauncherValue = useMemo(
Expand Down Expand Up @@ -1542,6 +1545,32 @@ const SessionLauncherPage = () => {
{
dataIndex: 'name',
title: t('data.folders.Name'),
render: (value, record) => {
return (
<Flex
onClick={() => {
// record?.id && open(record.id);
}}
style={{ width: 'fit-content' }}
>
<Button
type="link"
icon={<FolderOutlined />}
style={{ paddingLeft: 0 }}
>
<Typography.Text
style={{
whiteSpace: 'pre-line',
wordBreak: 'break-all',
textAlign: 'start',
}}
>
{value}
</Typography.Text>
</Button>
</Flex>
);
},
},
{
dataIndex: 'alias',
Expand All @@ -1565,10 +1594,15 @@ const SessionLauncherPage = () => {
dataSource={_.map(
form.getFieldValue('mounts'),
(v) => {
console.log(
'mounts form value: ',
form.getFieldValue('mounts'),
);
return {
name: v,
alias:
form.getFieldValue('vfoldersAliasMap')?.[v],
id: v.id,
};
},
)}
Expand Down

0 comments on commit 01135ca

Please sign in to comment.