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
16 changes: 0 additions & 16 deletions src/app/(withHeader)/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
font-family: var(--font-geist-sans);
}

@media (prefers-color-scheme: dark) {
.page {
--gray-rgb: 255, 255, 255;
--gray-alpha-200: rgb(var(--gray-rgb), 0.145);
--gray-alpha-100: rgb(var(--gray-rgb), 0.06);
--button-primary-hover: #ccc;
--button-secondary-hover: #1a1a1a;
}
}

.main {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -162,12 +152,6 @@ a.secondary {
}
}

@media (prefers-color-scheme: dark) {
.logo {
filter: invert();
}
}

.page__search {
max-width: 42rem;
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/(withHeader)/script/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { runScriptValidationSchema } from '@/app/(withHeader)/script/[id]/page.u
import { useStartScript } from '@/hooks/script/useStartScript';
import { useCustomToast } from '@/hooks/other/useCustomToast';
import { notifyMutationError } from '@/utils/notifyMutationError';
import { getTypeLabelRu } from '@/utils/send';
import { Loading } from '@/shared/Loading';
import { CsvUploader } from '@/components/CsvUploader';

Expand Down Expand Up @@ -200,7 +201,7 @@ export default function Page() {
formikName={`in_params[${id}].data`}
key={id}
typeOfCard='input'
type={item.type}
type={getTypeLabelRu(item.type)}
name={item.name}
description={item.desc || ''}
unit={item.unit || ''}
Expand All @@ -217,7 +218,7 @@ export default function Page() {
<ScriptParametrLayout
key={id}
typeOfCard='output'
type={item.type}
type={getTypeLabelRu(item.type)}
name={item.name}
description={item.desc || ''}
unit={item.unit || ''}
Expand Down
16 changes: 8 additions & 8 deletions src/app/(withHeader)/script/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ export default function CreatePage() {

createScript(
{
name: values.name,
desc: values.desc,
name: values.name.trim(),
desc: values.desc?.trim() ?? '',
archiveID: String(file_id),
in: values.inputParams.map((param) => ({
name: param.name,
desc: param.desc,
unit: param.measure,
name: param.name.trim(),
desc: param.desc?.trim() ?? '',
unit: param.measure?.trim() ?? '',
type: getSendValues(param.type) as ValueType,
})),
out: values.outputParams.map((param) => ({
name: param.name,
desc: param.desc,
unit: param.measure,
name: param.name.trim(),
desc: param.desc?.trim() ?? '',
unit: param.measure?.trim() ?? '',
type: getSendValues(param.type) as ValueType,
})),
},
Expand Down
27 changes: 16 additions & 11 deletions src/app/(withHeader)/script/create/page.usecase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import cn from 'classnames';
import { AddParametrIcon } from '@/components/icons/AddParametricon';
import * as Yup from 'yup';

const trimString = (v: unknown) => (typeof v === 'string' ? v.trim() : v);

export const pageCreateUsecase = {
main: {
header: <p className='layout__title-sm'>Основная информация</p>,
Expand All @@ -13,7 +15,7 @@ export const pageCreateUsecase = {
placeholder: 'Введите название скрипта',
},
scriptCode: {
title: 'Tar-архив (.tar, .tar.gz, .tgz) *',
title: 'tar-архив (.tar, .tar.gz, .tgz) *',
placeholder: 'Выберите tar-архив',
},

Expand Down Expand Up @@ -42,29 +44,32 @@ export const pageCreateUsecase = {

const ParametrSheme = Yup.object().shape({
name: Yup.string()
.min(1, 'Название должно иметь хотя бы 2 символа')
.transform(trimString)
.min(1, 'Название должно иметь хотя бы 1 символ')
.max(50, 'Название должно быть меньше 50 символов')
.required('Название обязательно'),
desc: Yup.string()
.min(1, 'Описание должно иметь хотя бы 2 символа')
.max(50, 'Описание должно быть меньше 50 символов')
.required('Описание обязательно'),
.transform(trimString)
.max(80, 'Описание должно быть меньше 80 символов')
.optional(),
type: Yup.string()
.min(1, 'Тип должен иметь хотя бы 2 символа')
.transform(trimString)
.min(1, 'Тип должен иметь хотя бы 1 символ')
.max(50, 'Тип должен быть меньше 50 символов')
.required('Тип обязателен'),
measure: Yup.string()
.min(1, 'Единица измерения должна иметь хотя бы 2 символа')
.transform(trimString)
.max(50, 'Единица измерения должна быть меньше 50 символов')
.required('Единица измерения обязательна'),
.optional(),
});

export const ScriptSchema = Yup.object().shape({
name: Yup.string()
.min(1, 'Название должно иметь хотя бы 2 символа')
.max(50, 'Название должно быть меньше 50 символов')
.transform(trimString)
.min(1, 'Название должно иметь хотя бы 1 символ')
.max(80, 'Название должно быть меньше 80 символов')
.required('Название обязательно'),
desc: Yup.string().max(50, 'Описание должно быть меньше 50 символов'),
desc: Yup.string().transform(trimString).max(1000, 'Описание должно быть меньше 1000 символов'),
inputParams: Yup.array().of(ParametrSheme),
outputParams: Yup.array().of(ParametrSheme),
file: Yup.mixed().required('Скрипт обязателен'),
Expand Down
3 changes: 3 additions & 0 deletions src/app/(withHeader)/users/handle/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import style from './page.module.css';
import { UserTable } from '@/components/UserTable';
import { pageSelectStyles, roleUsecase } from '@/components/Filter/Filter.usecase';
import { useGetAllUsers } from '@/hooks/user/useGetAllUsers';
import { useGetUserMe } from '@/hooks/user/useGetUserMe';
import { usePatchUser } from '@/hooks/user/usePatchUser';
import { useDeleteUser } from '@/hooks/user/useDeleteUser';
import { useCustomToast } from '@/hooks/other/useCustomToast';
Expand All @@ -24,6 +25,7 @@ const ITEMS_PER_PAGE = 8;

export default function HandlePage() {
const { data: usersData, isLoading, refetch } = useGetAllUsers();
const { data: currentUser } = useGetUserMe();
const { mutate: patchUser } = usePatchUser();
const { mutate: deleteUser } = useDeleteUser();
const notify = useCustomToast();
Expand Down Expand Up @@ -155,6 +157,7 @@ export default function HandlePage() {
) : paginatedUsers.length > 0 ? (
<UserTable
users={paginatedUsers}
currentUserId={currentUser?.id}
onEditUser={handleEditUser}
onDeleteUser={handleDeleteUser}
/>
Expand Down
13 changes: 0 additions & 13 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@
--shadow-lg: 0px 4px 8px 0px #00000040;
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

html,
body {
max-width: 100vw;
Expand Down Expand Up @@ -105,12 +98,6 @@ a {
text-decoration: none;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
}

.layout__title {
font-size: var(--font-size-lg);
font-weight: 700;
Expand Down
26 changes: 26 additions & 0 deletions src/components/UserTable/UserTable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@
border-bottom: 1px solid var(--color-gray-border);
}

.currentUserRow {
position: relative;
background: linear-gradient(
90deg,
rgb(124 58 237 / 8%) 0%,
rgb(124 58 237 / 4%) 8%,
white 20%,
white 100%
);
border-left: 3px solid var(--color-purple-main);
}

.currentUserRow::before {
content: 'Вы';
position: absolute;
top: 0.75rem;
right: 1rem;
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
font-weight: 600;
color: var(--color-purple-main);
background: rgb(124 58 237 / 12%);
border-radius: 0.5rem;
letter-spacing: 0.02em;
}

.rowCell {
padding: 1rem 1.5rem;
flex: 1;
Expand Down
1 change: 1 addition & 0 deletions src/components/UserTable/UserTable.props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { HTMLAttributes } from 'react';

export interface Props extends HTMLAttributes<HTMLDivElement> {
users: User[];
currentUserId?: string;
className?: string;
onEditUser: (user: User) => void;
onDeleteUser: (userId: string) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { HTMLAttributes } from 'react';

export interface Props extends HTMLAttributes<HTMLDivElement> {
user: User;
isCurrentUser?: boolean;
onEditUser: (user: User) => void;
onDeleteUser: (userId: string) => void;
}
7 changes: 5 additions & 2 deletions src/components/UserTable/components/UserRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { PasswordCell } from '../cells/PasswordCell';
import { RoleCell } from '../cells/RoleCell';
import { ActionsCell } from '../cells/ActionsCell';
import { validateEmail, validateFullname, validatePassword } from '@/utils/validators';
import cn from 'classnames';
import generalStyle from './../../UserTable.module.css';

export const UserRow: FC<Props> = ({ user, onEditUser, onDeleteUser }) => {
export const UserRow: FC<Props> = ({ user, isCurrentUser, onEditUser, onDeleteUser }) => {
const [isEditing, setIsEditing] = useState(false);
const [editData, setEditData] = useState<EditUserData>({
name: user.name,
Expand Down Expand Up @@ -133,7 +134,9 @@ export const UserRow: FC<Props> = ({ user, onEditUser, onDeleteUser }) => {
};

return (
<div className={generalStyle.tableRow}>
<div
className={cn(generalStyle.tableRow, isCurrentUser && generalStyle.currentUserRow)}
data-current-user={isCurrentUser || undefined}>
<UserInfoCell
isEditing={isEditing}
editData={editData}
Expand Down
18 changes: 15 additions & 3 deletions src/components/UserTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ type DialogState = {
onConfirm: () => void;
} | null;

export const UserTable: FC<Props> = ({ users, className, onEditUser, onDeleteUser }) => {
export const UserTable: FC<Props> = ({
users,
currentUserId,
className,
onEditUser,
onDeleteUser,
}) => {
const [dialog, setDialog] = useState<DialogState>(null);

const orderedUsers =
currentUserId != null
? [...users].sort((a, b) => (a.id === currentUserId ? -1 : b.id === currentUserId ? 1 : 0))
: users;

const handleEditUser = (user: User) => {
setDialog({
visible: true,
Expand All @@ -34,7 +45,7 @@ export const UserTable: FC<Props> = ({ users, className, onEditUser, onDeleteUse
};

const handleDeleteUser = (userId: string) => {
const user = users.find((u) => u.id === userId);
const user = orderedUsers.find((u) => u.id === userId);
if (!user) {
return;
}
Expand Down Expand Up @@ -68,10 +79,11 @@ export const UserTable: FC<Props> = ({ users, className, onEditUser, onDeleteUse
)}
<div className={styles.usersTable}>
<UserTableHeader />
{users.map((user) => (
{orderedUsers.map((user) => (
<UserRow
key={user.id}
user={user}
isCurrentUser={user.id === currentUserId}
onEditUser={handleEditUser}
onDeleteUser={handleDeleteUser}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ScriptParametrLayout: FC<ScriptParametrWithTypeOfCard> = ({
<p className={styles.ScriptParametrLayout__title_input}>{name}</p>
<div className={styles.ScriptParametrLayout__type_measure_input}>
<p className={styles.ScriptParametrLayout__type_input}>{type}</p>
<p className={styles.ScriptParametrLayout__measure_input}>{unit}</p>
{unit && <p className={styles.ScriptParametrLayout__measure_input}>{unit}</p>}
</div>
</div>
<FastField name={formikName || ''}>
Expand All @@ -47,7 +47,7 @@ export const ScriptParametrLayout: FC<ScriptParametrWithTypeOfCard> = ({
<p className={'layout__title-xs'}>{name}</p>
<div className={styles.ScriptParametrLayout__type_measure_input}>
<p className={styles.ScriptParametrLayout__type_input}>{type}</p>
<p className={styles.ScriptParametrLayout__measure_input}>{unit}</p>
{unit && <p className={styles.ScriptParametrLayout__measure_input}>{unit}</p>}
</div>
</div>
<p className={styles.ScriptParametrLayout__translation_input}>{description}</p>
Expand Down
15 changes: 14 additions & 1 deletion src/utils/send.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ParametrType } from '@/shared/consts/parametr';
import { PipelineStatus } from '@/shared/consts/pipeline';
import { JobState } from '@/shared/api/generated/data-contracts';
import { JobState, ValueType } from '@/shared/api/generated/data-contracts';
import type { Job } from '@/shared/api/generated/data-contracts';

export const getSendValues = (value: string) => {
Expand All @@ -15,6 +15,19 @@ export const getSendValues = (value: string) => {
return 'error';
};

export const getTypeLabelRu = (value: string) => {
switch (value) {
case ValueType.Real:
return 'Вещественное';
case ValueType.Integer:
return 'Целое';
case ValueType.String:
return 'Строка';
default:
return value;
}
};

export const getStatus = (state: JobState, code: number | undefined) => {
switch (state) {
case JobState.Running:
Expand Down