Skip to content

Commit 91522a3

Browse files
author
Zabilsya
committed
[DOP-23575] add Fieldset component and improve some details
1 parent 9ada0cd commit 91522a3

File tree

43 files changed

+275
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+275
-198
lines changed

src/app/layouts/PrivateLayout/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ import { Layout } from 'antd';
33
import { Outlet } from 'react-router-dom';
44
import { Header, Sidebar } from '@widgets/layout';
55
import { SpinOverlay } from '@shared/ui';
6+
import { useSelectedGroup } from '@entities/group';
67

78
import classes from './styles.module.less';
89

910
const { Content } = Layout;
1011

1112
export const PrivateLayout = () => {
13+
const { isLoading } = useSelectedGroup();
14+
15+
if (isLoading) {
16+
return <SpinOverlay />;
17+
}
18+
1219
return (
1320
<Layout className={classes.layout}>
1421
<Header />

src/app/styles/antd.less

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
font-weight: 700;
2323
}
2424

25-
.ant-table-cell {
25+
.ant-table-cell,
26+
.ant-form-item-explain-error {
2627
word-break: break-word;
2728
}
2829

@@ -33,3 +34,9 @@
3334
justify-content: center;
3435
align-items: center;
3536
}
37+
38+
.ant-menu {
39+
position: sticky;
40+
top: 0;
41+
height: auto;
42+
}

src/app/styles/variables.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@border-radius-base: 8px;
22

3+
@layout-sider-background: @white;
4+
35
@menu-item-font-size: 16px;
46
@menu-inline-toplevel-item-height: 48px;
57

@@ -12,3 +14,11 @@
1214
@descriptions-title-margin-bottom: 16px;
1315

1416
@modal-header-title-font-size: 18px;
17+
18+
@typography-title-margin-bottom: 0;
19+
20+
// @form-item-margin-bottom: 0;
21+
22+
@input-bg: #f1f3f5;
23+
@select-background: #f1f3f5;
24+
@picker-bg: #f1f3f5;

src/entities/connection/ui/ConnectionTypeForm/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Form, Select } from 'antd';
33
import { CONNECTION_TYPE_SELECT_OPTIONS } from '@entities/connection';
4+
import { Fieldset } from '@shared/ui';
45

56
import { ConnectionTypeFormProps } from './types';
67
import { CONNECTION_TYPE_COMPONENT, SensitiveFieldsContext } from './constants';
@@ -10,7 +11,7 @@ export const ConnectionTypeForm = ({ initialType, isRequiredSensitiveFields = tr
1011
const { selectedConnectionType, handleSelectConnectionType } = useSelectConnectionType({ initialType });
1112

1213
return (
13-
<>
14+
<Fieldset title="Connection settings">
1415
<Form.Item label="Type" name="type" rules={[{ required: true }]}>
1516
<Select
1617
size="large"
@@ -22,6 +23,6 @@ export const ConnectionTypeForm = ({ initialType, isRequiredSensitiveFields = tr
2223
<SensitiveFieldsContext.Provider value={{ isRequired: isRequiredSensitiveFields }}>
2324
{CONNECTION_TYPE_COMPONENT[selectedConnectionType!]}
2425
</SensitiveFieldsContext.Provider>
25-
</>
26+
</Fieldset>
2627
);
2728
};

src/entities/group/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SelectedGroupContextProps } from './types';
66

77
const SELECTED_GROUP_CONTEXT_INITIAL_VALUE: SelectedGroupContextProps = {
88
group: null,
9+
isLoading: true,
910
selectGroup: () => undefined,
1011
cleanGroup: () => undefined,
1112
};

src/entities/group/providers/SelectedGroupProvider/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import React, { PropsWithChildren, useEffect, useState } from 'react';
1+
import React, { PropsWithChildren, useLayoutEffect, useState } from 'react';
22

33
import { Group, useGetInitialGroup } from '../../api';
44
import { SELECTED_GROUP_ID_LOCAL_STORAGE_KEY, SelectedGroupContext } from '../../constants';
55

66
export const SelectedGroupProvider = ({ children }: PropsWithChildren) => {
7-
const { data: initialGroup } = useGetInitialGroup({
7+
const { data: initialGroup, isLoading } = useGetInitialGroup({
88
id: Number(localStorage.getItem(SELECTED_GROUP_ID_LOCAL_STORAGE_KEY)),
99
});
1010

1111
const [selectedGroup, setSelectedGroup] = useState<Group | null>(null);
1212

13-
useEffect(() => {
13+
useLayoutEffect(() => {
1414
if (initialGroup) {
1515
setSelectedGroup(initialGroup);
1616
}
@@ -28,6 +28,7 @@ export const SelectedGroupProvider = ({ children }: PropsWithChildren) => {
2828

2929
const contextValue = {
3030
group: selectedGroup,
31+
isLoading: !selectedGroup && isLoading,
3132
selectGroup: handleSelectGroup,
3233
cleanGroup: handleCleanGroup,
3334
};

src/entities/group/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Group } from './api';
22

33
export interface SelectedGroupContextProps {
44
group: Group | null;
5+
isLoading: boolean;
56
selectGroup: (group: Group) => void;
67
cleanGroup: () => void;
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.wrapper {
22
display: flex;
33
flex-direction: column;
4-
gap: 16px;
4+
gap: 32px;
55
width: 360px;
66
padding: 32px;
77
background-color: @white;
88
border-radius: 16px;
9+
box-shadow: @box-shadow-base;
910
}

src/features/connection/CreateConnection/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { ControlButtons, FormCurrentGroupDescription, ManagedForm } from '@shared/ui';
2+
import { ControlButtons, Fieldset, FormCurrentGroupDescription, ManagedForm } from '@shared/ui';
33
import { Form, Input } from 'antd';
44
import { useNavigate } from 'react-router-dom';
55
import { Connection, ConnectionQueryKey, connectionService, ConnectionTypeForm } from '@entities/connection';
@@ -28,13 +28,15 @@ export const CreateConnection = ({ group }: CreateConnectionProps) => {
2828
successMessage="Connection was created successfully"
2929
keysInvalidateQueries={[[{ queryKey: [ConnectionQueryKey.GET_CONNECTIONS, group.id] }]]}
3030
>
31-
<FormCurrentGroupDescription groupName={group.name} />
32-
<Form.Item label="Name" name="name" rules={[{ required: true }]}>
33-
<Input size="large" />
34-
</Form.Item>
35-
<Form.Item label="Description" name="description" rules={[{ required: true }]}>
36-
<Input size="large" />
37-
</Form.Item>
31+
<Fieldset title="Main info">
32+
<FormCurrentGroupDescription groupName={group.name} />
33+
<Form.Item label="Name" name="name" rules={[{ required: true }]}>
34+
<Input size="large" />
35+
</Form.Item>
36+
<Form.Item label="Description" name="description" rules={[{ required: true }]}>
37+
<Input size="large" />
38+
</Form.Item>
39+
</Fieldset>
3840

3941
<ConnectionTypeForm />
4042

src/features/connection/UpdateConnection/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { ControlButtons, FormCurrentGroupDescription, ManagedForm } from '@shared/ui';
2+
import { ControlButtons, Fieldset, FormCurrentGroupDescription, ManagedForm } from '@shared/ui';
33
import { Form, Input } from 'antd';
44
import { useNavigate } from 'react-router-dom';
55
import { Connection, ConnectionQueryKey, connectionService, ConnectionTypeForm } from '@entities/connection';
@@ -33,15 +33,17 @@ export const UpdateConnection = ({ connection, group }: UpdateConnectionProps) =
3333
[{ queryKey: [ConnectionQueryKey.GET_CONNECTION, connectionId] }],
3434
]}
3535
>
36-
<FormCurrentGroupDescription groupName={group.name} />
36+
<Fieldset title="Main info">
37+
<FormCurrentGroupDescription groupName={group.name} />
3738

38-
<Form.Item label="Name" name="name" rules={[{ required: true }]}>
39-
<Input size="large" />
40-
</Form.Item>
39+
<Form.Item label="Name" name="name" rules={[{ required: true }]}>
40+
<Input size="large" />
41+
</Form.Item>
4142

42-
<Form.Item label="Description" name="description" rules={[{ required: true }]}>
43-
<Input size="large" />
44-
</Form.Item>
43+
<Form.Item label="Description" name="description" rules={[{ required: true }]}>
44+
<Input size="large" />
45+
</Form.Item>
46+
</Fieldset>
4547

4648
<ConnectionTypeForm initialType={connectionInitialValues.type} isRequiredSensitiveFields={false} />
4749

0 commit comments

Comments
 (0)