Skip to content

Commit

Permalink
ignore tour errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Oct 2, 2024
1 parent a3a9a7a commit c1f51bd
Show file tree
Hide file tree
Showing 24 changed files with 97 additions and 56 deletions.
15 changes: 15 additions & 0 deletions react/src/components/HiddenFormItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Form, FormItemProps } from 'antd';
import React, { useEffect } from 'react';

interface HiddenFormItemProps extends Omit<FormItemProps, 'children'> {
value: any;
}
const HiddenFormItem: React.FC<HiddenFormItemProps> = ({ value, ...props }) => {
const form = Form.useFormInstance();
useEffect(() => {
form.setFieldValue(props.name, value);
}, [value, form, props.name]);
return <Form.Item {...props} hidden />;
};

export default HiddenFormItem;
54 changes: 34 additions & 20 deletions react/src/components/SessionOwnerSetterCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import BAICard, { BAICardProps } from '../BAICard';
import { useCurrentDomainValue } from '../hooks';
import { useCurrentUserRole } from '../hooks/backendai';
import { useTanQuery } from '../hooks/reactQueryAlias';
import BAISelect from './BAISelect';
import Flex from './Flex';
import HiddenFormItem from './HiddenFormItem';
import ResourceGroupSelect from './ResourceGroupSelect';
import { SessionOwnerSetterCardQuery } from './__generated__/SessionOwnerSetterCardQuery.graphql';
import {
Expand All @@ -26,16 +26,26 @@ import React, { Suspense, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { fetchQuery, useRelayEnvironment } from 'react-relay';

export interface SessionOwnerSetterFormValues {
owner?: {
email: string;
accesskey: string;
project: string;
resourceGroup: string;
enabled: boolean;
domainName: string;
};
}

const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
const { t } = useTranslation();
const { token } = theme.useToken();
const form = Form.useFormInstance();
const form = Form.useFormInstance<SessionOwnerSetterFormValues>();

const isActive = Form.useWatch(['owner', 'enabled'], form);

const [fetchingEmail, setFetchingEmail] = useState<string>();
const relayEvn = useRelayEnvironment();
const domainName = useCurrentDomainValue();

const { data, isFetching } = useTanQuery({
queryKey: ['SessionOwnerSetterCard', 'ownerInfo', fetchingEmail],
Expand All @@ -44,14 +54,12 @@ const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
if (!email) return;

const query = graphql`
query SessionOwnerSetterCardQuery(
$email: String!
$domainName: String!
) {
query SessionOwnerSetterCardQuery($email: String!) {
keypairs(email: $email) {
access_key
}
user(domain_name: $domainName, email: $email) {
user(email: $email) {
domain_name
groups {
name
id
Expand All @@ -61,7 +69,6 @@ const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
`;
return fetchQuery<SessionOwnerSetterCardQuery>(relayEvn, query, {
email,
domainName,
}).toPromise();
},
enabled: !!fetchingEmail,
Expand Down Expand Up @@ -93,6 +100,10 @@ const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
}
{...props}
>
<HiddenFormItem
name={['owner', 'domainName']}
value={owner?.domain_name}
/>
<Form.Item dependencies={[['owner', 'enabled']]} noStyle>
{({ getFieldValue }) => {
return (
Expand Down Expand Up @@ -135,8 +146,8 @@ const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
form.setFieldsValue({
owner: {
accesskey: '',
group: undefined,
'scaling-group': undefined,
project: undefined,
resourceGroup: undefined,
},
});
}}
Expand Down Expand Up @@ -173,7 +184,7 @@ const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
<Row gutter={token.marginSM}>
<Col span={12}>
<Form.Item
name={['owner', 'group']}
name={['owner', 'project']}
label={t('session.launcher.OwnerGroup')}
rules={[
{
Expand All @@ -194,7 +205,7 @@ const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
</Form.Item>
</Col>
<Col span={12}>
<Form.Item dependencies={[['owner', 'group']]} noStyle>
<Form.Item dependencies={[['owner', 'project']]} noStyle>
{({ getFieldValue }) => {
return (
<Suspense
Expand All @@ -212,17 +223,20 @@ const SessionOwnerSetterCard: React.FC<CardProps> = (props) => {
}
>
<Form.Item
name={['owner', 'scaling-group']}
name={['owner', 'resourceGroup']}
label={t('session.launcher.OwnerResourceGroup')}
rules={[
{
required: getFieldValue(['owner', 'enabled']),
},
]}
>
{getFieldValue(['owner', 'group']) ? (
{getFieldValue(['owner', 'project']) ? (
<ResourceGroupSelect
projectName={getFieldValue(['owner', 'group'])}
projectName={getFieldValue([
'owner',
'project',
])}
disabled={
_.isEmpty(fetchingEmail) || isFetching
}
Expand Down Expand Up @@ -262,8 +276,8 @@ export const SessionOwnerSetterPreviewCard: React.FC<BAICardProps> = (
status={
form.getFieldError(['owner', 'email']).length > 0 ||
form.getFieldError(['owner', 'accesskey']).length > 0 ||
form.getFieldError(['owner', 'group']).length > 0 ||
form.getFieldError(['owner', 'scaling-group']).length > 0
form.getFieldError(['owner', 'project']).length > 0 ||
form.getFieldError(['owner', 'resourceGroup']).length > 0
? 'error'
: undefined
}
Expand All @@ -278,10 +292,10 @@ export const SessionOwnerSetterPreviewCard: React.FC<BAICardProps> = (
{form.getFieldValue(['owner', 'accesskey'])}
</Descriptions.Item>
<Descriptions.Item label={t('session.launcher.OwnerGroup')}>
{form.getFieldValue(['owner', 'group'])}
{form.getFieldValue(['owner', 'project'])}
</Descriptions.Item>
<Descriptions.Item label={t('session.launcher.OwnerResourceGroup')}>
{form.getFieldValue(['owner', 'scaling-group'])}
{form.getFieldValue(['owner', 'resourceGroup'])}
</Descriptions.Item>
</Descriptions>
</BAICard>
Expand Down
42 changes: 27 additions & 15 deletions react/src/pages/SessionLauncherPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import SessionLauncherValidationTour from '../components/SessionLauncherErrorTou
import SessionNameFormItem, {
SessionNameFormItemValue,
} from '../components/SessionNameFormItem';
import SessionOwnerSetterCard from '../components/SessionOwnerSetterCard';
import SessionOwnerSetterCard, {
SessionOwnerSetterFormValues,
} from '../components/SessionOwnerSetterCard';
import { SessionOwnerSetterPreviewCard } from '../components/SessionOwnerSetterCard';
import SourceCodeViewer from '../components/SourceCodeViewer';
import VFolderTableFormItem, {
Expand Down Expand Up @@ -153,7 +155,8 @@ export type SessionLauncherFormValue = SessionLauncherValue &
ImageEnvironmentFormInput &
ResourceAllocationFormValue &
VFolderTableFormValues &
PortSelectFormValues;
PortSelectFormValues &
SessionOwnerSetterFormValues;

type SessionMode = 'normal' | 'inference' | 'import';

Expand Down Expand Up @@ -427,9 +430,18 @@ const SessionLauncherPage = () => {
: {}),

// TODO: support change owner
group_name: currentProject.name,
domain: baiClient._config.domainName,
scaling_group: values.resourceGroup,
...(values.owner?.enabled
? {
group_name: values.owner.project,
domain: values.owner.domainName,
scaling_group: values.owner.project,
owner_access_key: values.owner.accesskey,
}
: {
group_name: currentProject.name,
domain: baiClient._config.domainName,
scaling_group: values.resourceGroup,
}),
///////////////////////////

cluster_mode: values.cluster_mode,
Expand Down Expand Up @@ -1757,16 +1769,16 @@ const SessionLauncherPage = () => {
}}
/> */}
{currentStep === steps.length - 1 ? (
// <ErrorBoundary fallback={null}>
<SessionLauncherValidationTour
open={validationTourOpen}
onClose={() => {
setValidationTourOpen(false);
}}
scrollIntoViewOptions
/>
) : // </ErrorBoundary>
undefined}
<ErrorBoundary fallback={null}>
<SessionLauncherValidationTour
open={validationTourOpen}
onClose={() => {
setValidationTourOpen(false);
}}
scrollIntoViewOptions
/>
</ErrorBoundary>
) : undefined}
</Flex>
);
};
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Gesamtzuweisung",
"SetSessionOwner": "Sitzungsinhaber",
"OwnerAccessKey": "Zugriffsschlüssel für den Besitzer",
"OwnerGroup": "Eigentümergruppe",
"OwnerGroup": "Projekt des Eigentümers",
"OwnerResourceGroup": "Eigentümerressourcengruppe Owner",
"LaunchSessionWithAccessKey": "Sitzung im Namen des Zugriffsschlüssels starten",
"OwnerEmail": "Eigentümer-E-Mail",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Συνολική κατανομή",
"SetSessionOwner": "Κάτοχος συνεδρίας",
"OwnerAccessKey": "Κλειδί πρόσβασης κατόχου",
"OwnerGroup": "Ομάδα ιδιοκτητών",
"OwnerGroup": "Έργο ιδιοκτήτη",
"OwnerResourceGroup": "Ομάδα πόρων κατόχου",
"LaunchSessionWithAccessKey": "Εκκίνηση περιόδου λειτουργίας εκ μέρους του κλειδιού πρόσβασης",
"OwnerEmail": "Ηλεκτρονικό ταχυδρομείο κατόχου",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"TotalAllocation": "Total Allocation",
"SetSessionOwner": "Session owner",
"OwnerAccessKey": "Owner access key",
"OwnerGroup": "Owner group",
"OwnerGroup": "Owner project",
"OwnerResourceGroup": "Owner resource group",
"LaunchSessionWithAccessKey": "Launch session on behalf of the access key",
"OwnerEmail": "Owner Email",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@
"OpenMPOptimization": "Optimización OpenMP/OpenBLAS",
"OwnerAccessKey": "Clave de acceso del propietario",
"OwnerEmail": "Correo electrónico del propietario",
"OwnerGroup": "Grupo de propietarios",
"OwnerGroup": "Proyecto propietario",
"OwnerResourceGroup": "Grupo de recursos propietario",
"PleaseWaitInitializing": "Por favor, espere mientras se inicializa...",
"PortsTitleWithRange": "Valor del puerto (entre 1024 ~ 65535)",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@
"OpenMPOptimization": "OpenMP/OpenBLAS-optimointi",
"OwnerAccessKey": "Omistajan käyttöoikeusavain",
"OwnerEmail": "Omistajan sähköpostiosoite",
"OwnerGroup": "Omistajaryhmä",
"OwnerGroup": "Omistajan hanke",
"OwnerResourceGroup": "Omistajan resurssiryhmä",
"PleaseWaitInitializing": "Odota alustuksen aikana...",
"PortsTitleWithRange": "Portin arvo (välillä 1024 ~ 65535)",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Allocation totale",
"SetSessionOwner": "Propriétaire de la session",
"OwnerAccessKey": "Clé d'accès propriétaire",
"OwnerGroup": "Groupe de propriétaires",
"OwnerGroup": "Projet du propriétaire",
"OwnerResourceGroup": "Groupe de ressources propriétaire",
"LaunchSessionWithAccessKey": "Session de lancement au nom de la clé d'accès",
"OwnerEmail": "Courriel du propriétaire",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"TotalAllocation": "Alokasi Total",
"SetSessionOwner": "Pemilik sesi",
"OwnerAccessKey": "Kunci akses pemilik",
"OwnerGroup": "Grup pemilik",
"OwnerGroup": "Proyek pemilik",
"OwnerResourceGroup": "Grup sumber daya pemilik",
"LaunchSessionWithAccessKey": "Luncurkan sesi atas nama kunci akses",
"OwnerEmail": "Email Pemilik",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Allocazione totale",
"SetSessionOwner": "Titolare della sessione Session",
"OwnerAccessKey": "Chiave di accesso del proprietario",
"OwnerGroup": "Gruppo di proprietari",
"OwnerGroup": "Progetto del proprietario",
"OwnerResourceGroup": "Gruppo di risorse proprietario",
"LaunchSessionWithAccessKey": "Avvia sessione per conto della chiave di accesso",
"OwnerEmail": "Email del proprietario",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "総割り当て",
"SetSessionOwner": "セッションオーナー",
"OwnerAccessKey": "所有者アクセスキー",
"OwnerGroup": "オーナーグループ",
"OwnerGroup": "オーナー・プロジェクト",
"OwnerResourceGroup": "オーナーリソースグループ",
"LaunchSessionWithAccessKey": "アクセスキーに代わってセッションを起動します",
"OwnerEmail": "所有者の電子メール",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"TotalAllocation": "총 자원 할당량",
"SetSessionOwner": "세션 소유자 설정",
"OwnerAccessKey": "소유자 접근키",
"OwnerGroup": "소유자 그룹",
"OwnerGroup": "소유자 프로젝트",
"OwnerResourceGroup": "소유자 자원 그룹",
"LaunchSessionWithAccessKey": "지정한 키로 세션 시작",
"OwnerEmail": "사용자 E-Mail",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/mn.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Нийт хуваарилалт",
"SetSessionOwner": "Session эзэмшигч",
"OwnerAccessKey": "Эзэмшигчийн нэвтрэх түлхүүр",
"OwnerGroup": "Эзэмшигчийн бүлэг",
"OwnerGroup": "Эзэмшигч төсөл",
"OwnerResourceGroup": "Эзэмшигчийн нөөцийн бүлэг",
"LaunchSessionWithAccessKey": "Хандалтын (access) түлхүүрээр session эхлүүлэх",
"OwnerEmail": "Эзэмшигчийн имэйл",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Jumlah Peruntukan",
"SetSessionOwner": "Pemilik sesi",
"OwnerAccessKey": "Kunci akses pemilik",
"OwnerGroup": "Kumpulan pemilik",
"OwnerGroup": "Projek pemilik",
"OwnerResourceGroup": "Kumpulan sumber pemilik",
"LaunchSessionWithAccessKey": "Lancarkan sesi atas nama kunci akses",
"OwnerEmail": "E-mel Pemilik",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Całkowity przydział",
"SetSessionOwner": "Właściciel sesji",
"OwnerAccessKey": "Klucz dostępu właściciela",
"OwnerGroup": "Grupa właścicieli",
"OwnerGroup": "Projekt właściciela",
"OwnerResourceGroup": "Grupa zasobów właściciela",
"LaunchSessionWithAccessKey": "Uruchom sesję w imieniu klucza dostępu",
"OwnerEmail": "E-mail właściciela",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Alocação Total",
"SetSessionOwner": "Proprietário da sessão",
"OwnerAccessKey": "Chave de acesso do proprietário",
"OwnerGroup": "Grupo proprietário",
"OwnerGroup": "Projeto do proprietário",
"OwnerResourceGroup": "Grupo de recursos do proprietário",
"LaunchSessionWithAccessKey": "Inicie a sessão em nome da chave de acesso",
"OwnerEmail": "Email do proprietário",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Alocação Total",
"SetSessionOwner": "Proprietário da sessão",
"OwnerAccessKey": "Chave de acesso do proprietário",
"OwnerGroup": "Grupo proprietário",
"OwnerGroup": "Projeto do proprietário",
"OwnerResourceGroup": "Grupo de recursos do proprietário",
"LaunchSessionWithAccessKey": "Inicie a sessão em nome da chave de acesso",
"OwnerEmail": "Email do proprietário",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"TotalAllocation": "Итого распределено",
"SetSessionOwner": "Владелец сеанса",
"OwnerAccessKey": "Ключ доступа владельца",
"OwnerGroup": "Группа владельцев",
"OwnerGroup": "Проект владельца",
"OwnerResourceGroup": "Группа ресурсов владельца",
"LaunchSessionWithAccessKey": "Запускаем сессию от имени ключа доступа",
"OwnerEmail": "Электронная почта владельца",
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"TotalAllocation": "การจัดสรรทั้งหมด",
"SetSessionOwner": "เจ้าของเซสชัน",
"OwnerAccessKey": "คีย์การเข้าถึงของเจ้าของ",
"OwnerGroup": "กลุ่มของเจ้าของ",
"OwnerGroup": "เจ้าของโครงการ",
"OwnerResourceGroup": "กลุ่มทรัพยากรของเจ้าของ",
"LaunchSessionWithAccessKey": "เปิดเซสชันในนามของคีย์การเข้าถึง",
"OwnerEmail": "อีเมลเจ้าของ",
Expand Down
Loading

0 comments on commit c1f51bd

Please sign in to comment.