Skip to content
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
6 changes: 6 additions & 0 deletions src/app/config/antd/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Language } from '@shared/config';

export const ANTD_LOCALES = {
[Language.EN]: () => import('antd/es/locale/en_US'),
[Language.RU]: () => import('antd/es/locale/ru_RU'),
};
22 changes: 19 additions & 3 deletions src/app/config/antd/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import { ConfigProvider } from 'antd';
import React, { PropsWithChildren } from 'react';
import React, { PropsWithChildren, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Locale } from 'antd/lib/locale-provider';
import { Language } from '@shared/config';

import { getValidateMessages } from './utils';
import { ANTD_LOCALES } from './constants';

export const AntdConfigProvider = ({ children }: PropsWithChildren) => {
const { t } = useTranslation('error');
const { t, i18n } = useTranslation('error');
const [locale, setLocale] = useState<Locale>();

return <ConfigProvider form={{ validateMessages: getValidateMessages(t) }}>{children}</ConfigProvider>;
useEffect(() => {
const loadLocale = async () => {
const localeModule = await ANTD_LOCALES[i18n.language as Language]();
setLocale(localeModule.default);
};
loadLocale();
}, [i18n.language]);

return (
<ConfigProvider locale={locale} form={{ validateMessages: getValidateMessages(t) }}>
{children}
</ConfigProvider>
);
};
5 changes: 5 additions & 0 deletions src/app/styles/antd.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@
margin-left: 8px;
}
}

.ant-picker-ranges {
display: flex;
justify-content: space-between;
}
3 changes: 1 addition & 2 deletions src/app/styles/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@
@picker-bg: #f1f3f5;
@tooltip-bg: #000000;

// custom constants
@select-transformation-type-width: 180px;
@line-height-base: 1.5;
3 changes: 3 additions & 0 deletions src/entities/auth/hooks/useLogout/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Language, LANGUAGE_LOCAL_STORAGE_KEY } from '@shared/config';
import { useQueryClient } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';

Expand All @@ -6,7 +7,9 @@ export const useLogout = () => {
const queryClient = useQueryClient();

const logout = () => {
const language = localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY) || Language.EN;
localStorage.clear();
localStorage.setItem(LANGUAGE_LOCAL_STORAGE_KEY, language);
queryClient.clear();
navigate('/login');
};
Expand Down
1 change: 1 addition & 0 deletions src/entities/connection/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export type CreateConnectionRequest = {

export type UpdateConnectionRequest = {
id: number;
group_id: number;
name: string;
description: string;
} & ConnectionData;
Expand Down
2 changes: 1 addition & 1 deletion src/entities/group/api/hooks/useDeleteGroupUser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useDeleteGroupUser = (data: DeleteGroupUserRequest): UseMutationRes
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [GroupQueryKey.GET_GROUP_USERS, data.groupId] });
notification.success({
message: t('deleteGroupSuccess', { ns: 'group' }),
message: t('deleteUserFromGroupSuccess', { ns: 'group' }),
});
},
onError: (error) => {
Expand Down
7 changes: 6 additions & 1 deletion src/entities/group/ui/GroupWarningAlert/styles.module.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.alert {
width: 500px;
width: fit-content;
padding: 20px 32px 20px 24px !important;

:global(.ant-alert-message) {
font-weight: 700;
}
}
5 changes: 4 additions & 1 deletion src/entities/run/ui/RunStatusBadge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React, { memo } from 'react';
import { Badge } from 'antd';
import { RUN_STATUS_DISPLAY } from '@entities/run';
import { useTranslation } from 'react-i18next';

import { RunStatusBadgeProps } from './types';
import { getRunStatusColor } from './utils';

export const RunStatusBadge = memo(({ status }: RunStatusBadgeProps) => {
const statusText = RUN_STATUS_DISPLAY[status];
const { t } = useTranslation('run');
const statusText = t(RUN_STATUS_DISPLAY[status]);

return <Badge count={statusText} status={getRunStatusColor(status)} />;
});
2 changes: 1 addition & 1 deletion src/entities/transfer/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface GetTransferRequest {

export interface CreateTransferRequest extends Omit<Transfer, 'id'> {}

export interface UpdateTransferRequest extends Omit<Transfer, 'group_id'> {}
export interface UpdateTransferRequest extends Transfer {}

export interface DeleteTransferRequest {
id: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const TransformationFormComponent = <T extends TransformationType>({
transformationType,
...props
}: TransformationFormProps<T>) => {
const { t } = useTranslation('transformation');
const { t } = useTranslation();
const { isDisplayed } = useShowButtons();

const formInstance = Form.useFormInstance();
Expand Down Expand Up @@ -44,7 +44,7 @@ const TransformationFormComponent = <T extends TransformationType>({
/>
))}
<Button className="nodrag" size="large" type="primary" onClick={() => add()} hidden={!isDisplayed}>
{t('addItem')}
{t('add')}
</Button>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TransformationFilterColumnsType } from '@entities/transformation';
import { useTranslation } from 'react-i18next';

import { FilterColumnsValueProps } from './types';
import classes from './styles.module.less';

export const FilterColumnsValue = ({ name, type }: FilterColumnsValueProps) => {
const { t } = useTranslation('transformation');
Expand All @@ -14,13 +15,13 @@ export const FilterColumnsValue = ({ name, type }: FilterColumnsValueProps) => {
return null;
case TransformationFilterColumnsType.RENAME:
return (
<Form.Item label={t('value')} name={[name, 'to']} rules={[{ required: true }]}>
<Form.Item className={classes.control} label={t('value')} name={[name, 'to']} rules={[{ required: true }]}>
<Input className="nodrag" size="large" />
</Form.Item>
);
case TransformationFilterColumnsType.CAST:
return (
<Form.Item label={t('value')} name={[name, 'as_type']} rules={[{ required: true }]}>
<Form.Item className={classes.control} label={t('value')} name={[name, 'as_type']} rules={[{ required: true }]}>
<Input className="nodrag" size="large" />
</Form.Item>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.control {
width: 250px;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.control {
width: calc(100% - @select-transformation-type-width);
flex-grow: 1;
width: 250px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ export const FilterFileSizeValue = memo(({ name }: FilterFileSizeValueProps) =>

return (
<>
<Form.Item label={t('value')} name={[name, 'extra_value']} rules={[{ required: true }]}>
<Form.Item className={classes.value} label={t('value')} name={[name, 'extra_value']} rules={[{ required: true }]}>
<InputNumber className="nodrag" size="large" min={0} />
</Form.Item>
<Form.Item
className={classes.select}
label={t('fileSizeUnit')}
name={[name, 'unit']}
rules={[{ required: true }]}
>
<Form.Item className={classes.unit} label={t('fileSizeUnit')} name={[name, 'unit']} rules={[{ required: true }]}>
<Select size="large" className="nodrag" options={fileSizeUnitSelectOptions} placeholder={t('selectUnit')} />
</Form.Item>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.select {
width: 120px;
.unit {
width: 175px;
}

.value {
width: 250px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TransformationFilterRowsType } from '@entities/transformation';
import { useTranslation } from 'react-i18next';

import { FilterRowsValueProps } from './types';
import classes from './styles.module.less';

export const FilterRowsValue = ({ name, type }: FilterRowsValueProps) => {
const { t } = useTranslation('transformation');
Expand All @@ -15,7 +16,7 @@ export const FilterRowsValue = ({ name, type }: FilterRowsValueProps) => {
return null;
default:
return (
<Form.Item label={t('value')} name={[name, 'value']} rules={[{ required: true }]}>
<Form.Item className={classes.control} label={t('value')} name={[name, 'value']} rules={[{ required: true }]}>
<Input className="nodrag" size="large" />
</Form.Item>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.control {
width: 250px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useMemo, useState } from 'react';
import { DeleteOutlined } from '@ant-design/icons';
import { Select } from '@shared/ui';
import { useTranslation } from 'react-i18next';
import clsx from 'clsx';

import { TransformationsFormNestedType, TransformationType } from '../../../../types';
import { FilterComponent } from '../FilterComponent';
Expand Down Expand Up @@ -53,12 +54,18 @@ export const TransformationFormItem = <T extends TransformationType>({
size="large"
options={nestedTypesSelectOptions}
onChange={setType}
placeholder={t('selectType')}
placeholder={t('selectOption')}
/>
</Form.Item>
<FilterComponent name={name} nestedType={type} transformationType={transformationType} />
{onRemove && (
<Button className="nodrag" type="primary" danger onClick={handleRemove}>
<Button
className={clsx('nodrag', [classes.deleteButton])}
type="primary"
size="large"
danger
onClick={handleRemove}
>
<DeleteOutlined />
</Button>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
.root {
display: flex;
align-items: center;
align-items: flex-start;
gap: 12px;

&:first-of-type {
align-items: flex-start;
}

.column {
min-width: 300px;
width: 250px;
}

.type {
min-width: @select-transformation-type-width;
min-width: 180px;
flex-grow: 1;
}

.deleteButton {
margin-top: calc(1rem * @line-height-base);
}
}
4 changes: 2 additions & 2 deletions src/features/auth/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Login = () => {

return (
<div className={classes.wrapper}>
<Title>{t('signIn')}</Title>
<Title>{t('auth')}</Title>
<ManagedForm mutationFunction={authService.login} onSuccess={onSuccess}>
<Form.Item label={t('username')} name="username" rules={[{ required: true }]}>
<Input size="large" />
Expand All @@ -28,7 +28,7 @@ export const Login = () => {
<Input.Password size="large" />
</Form.Item>

<ControlButtons isCancelButtonHidden />
<ControlButtons isCancelButtonHidden submitButtonText={t('signIn')} />
</ManagedForm>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/Login/styles.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: flex;
flex-direction: column;
gap: 32px;
width: 360px;
width: 420px;
padding: 32px;
background-color: @white;
border-radius: 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getConnectionListColumns = (t: TFunction<'shared'>) => {
{
title: t('id'),
dataIndex: 'id',
width: 150,
width: 160,
},
{
title: t('name'),
Expand Down
2 changes: 1 addition & 1 deletion src/features/connection/UpdateConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const UpdateConnection = ({ connection, group }: UpdateConnectionProps) =
const navigate = useNavigate();

const handleUpdateConnection = (values: UpdateConnectionForm) => {
return connectionService.updateConnection(Object.assign({ id: connectionId, ...values }));
return connectionService.updateConnection(Object.assign({ id: connectionId, group_id, ...values }));
};

const onSuccess = (response: Connection) => {
Expand Down
2 changes: 1 addition & 1 deletion src/features/connection/UpdateConnection/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Connection, UpdateConnectionRequest } from '@entities/connection';
import { GroupData } from '@entities/group';

export type UpdateConnectionForm = Omit<UpdateConnectionRequest, 'id'>;
export type UpdateConnectionForm = Omit<UpdateConnectionRequest, 'id' | 'group_id'>;

export interface UpdateConnectionProps {
connection: Connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getGroupListColumns = (t: TFunction) => {
title: t('id'),
dataIndex: 'id',
render: (name, record) => record.data.id,
width: 150,
width: 160,
},
{
title: t('name'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GroupUser } from '@entities/group';
import { USER_ROLE_DISPLAY } from '@shared/constants';
import { PaginationResponse } from '@shared/types';
import { TableColumns } from '@shared/ui';
import { TFunction } from 'i18next';
Expand All @@ -8,15 +9,17 @@ export const getGroupUserListColumns = (t: TFunction) => {
{
title: t('id'),
dataIndex: 'id',
width: 150,
width: 160,
},
{
title: t('username', { ns: 'auth' }),
dataIndex: 'username',
width: 400,
},
{
title: t('role', { ns: 'group' }),
dataIndex: 'role',
render: (name, record) => t(USER_ROLE_DISPLAY[record.role], { ns: 'auth' }),
width: 200,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getQueueListColumns = (t: TFunction) => {
{
title: t('id'),
dataIndex: 'id',
width: 150,
width: 160,
},
{
title: t('name'),
Expand Down
2 changes: 1 addition & 1 deletion src/features/run/RunList/utils/getRunListColumns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const getRunListColumns = (t: TFunction<'run'>) => {
title: t('id', { ns: 'shared' }),
dataIndex: 'id',
render: (id, record) => <Link to={`/transfers/runs/${record.id}`}>{id}</Link>,
width: 80,
width: 160,
},
{
title: t('status'),
Expand Down
Loading