2024-03-21 14:09:55 +00:00
|
|
|
// (c) Copyright Ascensio System SIA 2009-2024
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// This program is a free software product.
|
|
|
|
// You can redistribute it and/or modify it under the terms
|
|
|
|
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
|
|
|
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
|
|
|
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
|
|
|
// any third-party rights.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
|
|
|
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// The interactive user interfaces in modified source and object code versions of the Program must
|
|
|
|
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
|
|
|
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
|
|
|
// trademark law for use of our trademarks.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
|
|
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
|
|
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
|
2024-01-31 12:12:40 +00:00
|
|
|
import React, { useState } from "react";
|
|
|
|
|
|
|
|
import { ModalDialog, ModalDialogType } from "../../components/modal-dialog";
|
|
|
|
import { RadioButtonGroup } from "../../components/radio-button-group";
|
|
|
|
import { Button, ButtonSize } from "../../components/button";
|
|
|
|
import { Text } from "../../components/text";
|
|
|
|
import { ConflictResolveType } from "../../enums";
|
|
|
|
|
|
|
|
import StyledModalDialog from "./ConflictResolve.styled";
|
|
|
|
import { ConflictResolveProps } from "./ConflictResolve.types";
|
|
|
|
|
|
|
|
const ConflictResolve = (props: ConflictResolveProps) => {
|
|
|
|
const {
|
|
|
|
isLoading,
|
|
|
|
visible,
|
|
|
|
onClose,
|
|
|
|
onSubmit,
|
|
|
|
messageText,
|
|
|
|
selectActionText,
|
|
|
|
submitButtonLabel,
|
|
|
|
cancelButtonLabel,
|
|
|
|
overwriteDescription,
|
|
|
|
overwriteTitle,
|
|
|
|
duplicateDescription,
|
|
|
|
duplicateTitle,
|
|
|
|
skipDescription,
|
|
|
|
skipTitle,
|
|
|
|
headerLabel,
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const [resolveType, setResolveType] = useState<ConflictResolveType>(
|
|
|
|
ConflictResolveType.Overwrite,
|
|
|
|
);
|
|
|
|
|
|
|
|
const onSelectResolveType = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
const target = e.target;
|
|
|
|
|
2024-03-13 09:47:59 +00:00
|
|
|
const type = Number(target.value) as ConflictResolveType;
|
|
|
|
setResolveType(type);
|
2024-01-31 12:12:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const onSubmitAction = () => {
|
|
|
|
onSubmit(resolveType);
|
|
|
|
};
|
|
|
|
|
|
|
|
const radioOptions = [
|
|
|
|
{
|
|
|
|
label: (
|
|
|
|
<div>
|
|
|
|
<Text className="radio-option-title">{overwriteTitle}</Text>
|
|
|
|
<Text className="radio-option-description">
|
|
|
|
{overwriteDescription}
|
|
|
|
</Text>
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
value: ConflictResolveType.Overwrite as unknown as string,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: (
|
|
|
|
<div>
|
|
|
|
<Text className="radio-option-title">{duplicateTitle}</Text>
|
|
|
|
<Text className="radio-option-description">
|
|
|
|
{duplicateDescription}
|
|
|
|
</Text>
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
|
|
|
|
value: ConflictResolveType.Duplicate as unknown as string,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: (
|
|
|
|
<div>
|
|
|
|
<Text className="radio-option-title">{skipTitle}</Text>
|
|
|
|
<Text className="radio-option-description">{skipDescription}</Text>
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
value: ConflictResolveType.Skip as unknown as string,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<StyledModalDialog
|
|
|
|
isLoading={isLoading}
|
|
|
|
visible={visible}
|
|
|
|
onClose={onClose}
|
|
|
|
isLarge
|
|
|
|
zIndex={312}
|
|
|
|
displayType={ModalDialogType.modal}
|
|
|
|
>
|
|
|
|
<ModalDialog.Header>{headerLabel}</ModalDialog.Header>
|
|
|
|
<ModalDialog.Body>
|
|
|
|
<Text className="message">{messageText}</Text>
|
|
|
|
<Text className="select-action">{selectActionText}</Text>
|
|
|
|
<RadioButtonGroup
|
|
|
|
className="conflict-resolve-radio-button"
|
|
|
|
orientation="vertical"
|
|
|
|
fontSize="13px"
|
|
|
|
fontWeight={400}
|
|
|
|
name="group"
|
|
|
|
onClick={onSelectResolveType}
|
|
|
|
options={radioOptions}
|
|
|
|
selected={ConflictResolveType.Overwrite as unknown as string}
|
|
|
|
/>
|
|
|
|
</ModalDialog.Body>
|
|
|
|
<ModalDialog.Footer>
|
|
|
|
<Button
|
|
|
|
key="OkButton"
|
|
|
|
label={submitButtonLabel}
|
|
|
|
size={ButtonSize.normal}
|
|
|
|
primary
|
|
|
|
onClick={onSubmitAction}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
key="CancelButton"
|
|
|
|
label={cancelButtonLabel}
|
|
|
|
size={ButtonSize.normal}
|
|
|
|
onClick={onClose}
|
|
|
|
/>
|
|
|
|
</ModalDialog.Footer>
|
|
|
|
</StyledModalDialog>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ConflictResolve;
|