Skip to content
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

feat(FR-503): open kernel log modal in Kernel list #3100

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { useCurrentProjectValue } from '../../hooks/useCurrentProject';
import BAITable from '../BAITable';
import DoubleTag from '../DoubleTag';
import Flex from '../Flex';
import ContainerLogModal from './ContainerLogModal';
import { ConnectedKernelListLegacyQuery } from './__generated__/ConnectedKernelListLegacyQuery.graphql';
import {
ConnectedKernelListQuery,
ConnectedKernelListQuery$data,
} from './__generated__/ConnectedKernelListQuery.graphql';
import { Tag, Typography } from 'antd';
import { Button, Tag, Tooltip, Typography } from 'antd';
import { ColumnType } from 'antd/lib/table';
import graphql from 'babel-plugin-relay/macro';
import _ from 'lodash';
import { ScrollTextIcon } from 'lucide-react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLazyLoadQuery } from 'react-relay';

Expand Down Expand Up @@ -57,6 +60,7 @@ const ConnectedKernelList: React.FC<ConnectedKernelListProps> = ({
}) => {
const { t } = useTranslation();
const currentProject = useCurrentProjectValue();
const [kernelIdForLogModal, setKernelIdForLogModal] = useState<string>();

// get the project id of the session for <= v24.12.0.
const { session_for_project_id } =
Expand Down Expand Up @@ -94,6 +98,7 @@ const ConnectedKernelList: React.FC<ConnectedKernelListProps> = ({
}
count
}
...ContainerLogModalFragment
}
}
`,
Expand Down Expand Up @@ -127,6 +132,15 @@ const ConnectedKernelList: React.FC<ConnectedKernelListProps> = ({
<Typography.Text copyable ellipsis>
{row_id}
</Typography.Text>
<Tooltip title={t('session.SeeContainerLogs')}>
<Button
icon={<ScrollTextIcon />}
type="link"
onClick={() => {
setKernelIdForLogModal(row_id);
}}
/>
</Tooltip>
</>
),
},
Expand Down Expand Up @@ -211,6 +225,16 @@ const ConnectedKernelList: React.FC<ConnectedKernelListProps> = ({
// TODO: implement pagination when compute_session_node query supports pagination
pagination={false}
/>
{kernelIdForLogModal && (
<ContainerLogModal
open={!!kernelIdForLogModal}
sessionFrgmt={session || null}
defaultKernelId={kernelIdForLogModal}
onCancel={() => {
setKernelIdForLogModal(undefined);
}}
/>
)}
</Flex>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import { useFragment } from 'react-relay';

interface ContainerLogModalProps extends BAIModalProps {
sessionFrgmt: ContainerLogModalFragment$key | null;
defaultKernelId?: string;
}

const ContainerLogModal: React.FC<ContainerLogModalProps> = ({
sessionFrgmt,
defaultKernelId,
...modalProps
}) => {
const baiClient = useSuspendedBackendaiClient();
Expand Down Expand Up @@ -55,7 +57,8 @@ const ContainerLogModal: React.FC<ContainerLogModalProps> = ({

const kernelNodes = session?.kernel_nodes?.edges?.map((e) => e?.node) || [];
const [selectedKernelId, setSelectedKernelId] = useState(
_.find(kernelNodes, (e) => e?.cluster_role === 'main')?.row_id ||
defaultKernelId ||
_.find(kernelNodes, (e) => e?.cluster_role === 'main')?.row_id ||
kernelNodes[0]?.row_id,
);

Expand Down
Loading