Skip to content
Open
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 .changeset/odd-baths-slide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@alfalab/core-components-file-upload-item': patch
'@alfalab/core-components': patch
---

- Добавлен атрибут `data-test-id` к кнопкам с действиями
1 change: 1 addition & 0 deletions packages/file-upload-item/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const FileUploadItemComponent: React.FC<FileUploadItemProps> = ({
backgroundColor,
actionsPresent,
setActionsPresent,
dataTestId,
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { type MouseEvent, useContext } from 'react';

import { IconButton } from '@alfalab/core-components-icon-button';
import { getDataTestId } from '@alfalab/core-components-shared';
import CrossMIcon from '@alfalab/icons-glyph/CrossMIcon';

import { FileUploadItemContext } from '../../../../context/file-upload-item-context';

import styles from '../../actions-control.module.css';

export const DeleteButton = () => {
const { id = '0', disableButtons, onDelete } = useContext(FileUploadItemContext);
const { id = '0', dataTestId, disableButtons, onDelete } = useContext(FileUploadItemContext);

const handleDelete = (e: MouseEvent<HTMLElement>) => {
if (onDelete) {
Expand All @@ -24,6 +25,7 @@ export const DeleteButton = () => {
icon={<CrossMIcon className={styles.deleteIconColor} />}
disabled={disableButtons}
onClick={handleDelete}
dataTestId={getDataTestId(dataTestId, 'delete-button')}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { type MouseEvent, useContext } from 'react';

import { IconButton } from '@alfalab/core-components-icon-button';
import { getDataTestId } from '@alfalab/core-components-shared';
import ArrowDownLineDownCompactMIcon from '@alfalab/icons-glyph/ArrowDownLineDownCompactMIcon';

import { FileUploadItemContext } from '../../../../context/file-upload-item-context';
Expand All @@ -10,6 +11,7 @@ import styles from '../../actions-control.module.css';
export const DownloadButton = () => {
const {
id = '0',
dataTestId,
downloadLink,
download,
disableButtons,
Expand All @@ -35,6 +37,7 @@ export const DownloadButton = () => {
download={download}
target={target}
onClick={handleDownload}
dataTestId={getDataTestId(dataTestId, 'download-button')}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useContext } from 'react';

import { IconButton } from '@alfalab/core-components-icon-button';
import { getDataTestId } from '@alfalab/core-components-shared';
import ArrowsCwCompactMIcon from '@alfalab/icons-glyph/ArrowsCwCompactMIcon';

import { FileUploadItemContext } from '../../../../context/file-upload-item-context';

import styles from '../../actions-control.module.css';

export const RestoreButton = () => {
const { id = '0', disableButtons, onRestore } = useContext(FileUploadItemContext);
const { id = '0', dataTestId, disableButtons, onRestore } = useContext(FileUploadItemContext);

const handleRestore = () => {
if (onRestore) {
Expand All @@ -24,6 +25,7 @@ export const RestoreButton = () => {
icon={<ArrowsCwCompactMIcon className={styles.restoreIconColor} />}
disabled={disableButtons}
onClick={handleRestore}
dataTestId={getDataTestId(dataTestId, 'restore-button')}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type TFileUploadItemContext = {
backgroundColor?: SuperEllipseProps['backgroundColor'];
actionsPresent?: boolean;
setActionsPresent?: (present: boolean) => void;
dataTestId?: string;
};

export const FileUploadItemContext = createContext<TFileUploadItemContext>({
Expand Down Expand Up @@ -67,4 +68,5 @@ export const FileUploadItemContext = createContext<TFileUploadItemContext>({
backgroundColor: undefined,
actionsPresent: false,
setActionsPresent: undefined,
dataTestId: '',
});