Skip to content

Commit

Permalink
Copy entries follow-up (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
bt4R9 authored Nov 23, 2023
1 parent 6b6e619 commit 575996f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"label_current-entry": "Selected object",
"label_dashboards": "Dashboards",
"label_datasets": "Datasets",
"label_entry-already-in-workbook": "Copied with other objects",
"label_linked-objects": "Linked objects",
"label_no-linked-objects": "Empty",
"label_objects": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"label_current-entry": "Выбранный объект",
"label_dashboards": "Дашборды",
"label_datasets": "Датасеты",
"label_entry-already-in-workbook": "Скопирован с другими объектами",
"label_linked-objects": "Связанные объекты",
"label_no-linked-objects": "Пусто",
"label_objects": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import block from 'bem-cn-lite';
import {I18n} from 'i18n';
import {useDispatch, useSelector} from 'react-redux';
import {useHistory} from 'react-router-dom';
import {EntryScope} from 'shared';
import {ErrorContent} from 'ui/index';

import type {AppDispatch} from '../../store';
Expand Down Expand Up @@ -70,6 +71,11 @@ export const CopyEntriesToWorkbookDialog: React.FC<Props> = ({open, entryId, onC
const requestError = targetEntryError || relationsError;

const isError = !isLoading && requestError !== null;
const hasFileConnection = relations?.some(
(entry) =>
entry.scope === EntryScope.Connection &&
(entry.type === 'file' || entry.type === 'gsheets_v2'),
);

React.useEffect(() => {
const promises: CancellablePromise<unknown>[] = [];
Expand Down Expand Up @@ -156,7 +162,7 @@ export const CopyEntriesToWorkbookDialog: React.FC<Props> = ({open, entryId, onC
<Dialog.Footer
textButtonApply={i18n('action_copy')}
propsButtonApply={{
disabled: isLoading || isError,
disabled: hasFileConnection || isLoading || isError,
}}
textButtonCancel={i18n('action_cancel')}
onClickButtonApply={handleButtonApply}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export type EntryRowProps = {

export const EntryRow: React.FC<EntryRowProps> = ({className, entry, isTargetEntry}) => {
const link = navigateHelper.redirectUrlSwitcher(entry);
const isFileConnection = entry.scope === EntryScope.Connection && entry.type === 'file';
const isFileConnection =
entry.scope === EntryScope.Connection &&
(entry.type === 'file' || entry.type === 'gsheets_v2');

return (
<div className={b(null, className)}>
Expand All @@ -49,16 +51,12 @@ export const EntryRow: React.FC<EntryRowProps> = ({className, entry, isTargetEnt
>
{entry.name}
</Link>
{!isTargetEntry && (
{!isTargetEntry && isFileConnection && (
<div className={b('warning')}>
<div className={b('warning-icon')}>
<Icon data={WarningColoredIcon} size={16} />
</div>
<div className={b('warning-text')}>
{isFileConnection
? i18n('label_file-connection-warning')
: i18n('label_entry-already-in-workbook')}
</div>
<div className={b('warning-text')}>{i18n('label_file-connection-warning')}</div>
</div>
)}
</div>
Expand Down

0 comments on commit 575996f

Please sign in to comment.