Skip to content

Commit

Permalink
updated disable condition (#415)
Browse files Browse the repository at this point in the history
* updated disable condition

* updated the code

* updated code

* updated code
  • Loading branch information
abilpraju-aot authored Jan 15, 2025
1 parent 40fb668 commit 2a656f9
Showing 1 changed file with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const ImportModal: React.FC<ImportModalProps> = React.memo(
const redColor = computedStyle.getPropertyValue("--ff-red-000");
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [uploadProgress, setUploadProgress] = useState(0);
const hasVersion = (item) => item?.majorVersion != null || item?.minorVersion != null;
const skipImport = t("Skip, do not import");
const [selectedLayoutVersion, setSelectedLayoutVersion] = useState<{
value: any;
Expand All @@ -94,7 +95,6 @@ export const ImportModal: React.FC<ImportModalProps> = React.memo(

const [showFileItems, setShowFileItems] = useState(false);
const [inprogress, setInprogress] = useState(true);

const layoutOptions = [
{ value: true, label: t("Skip, do not import") },
{
Expand Down Expand Up @@ -165,29 +165,19 @@ export const ImportModal: React.FC<ImportModalProps> = React.memo(
inprogress ||
importLoader ||
(importError && primaryButtonText !== "Try Again") ||
(showFileItems &&
(showFileItems && fileItems &&
selectedFlowVersion?.label === skipImport &&
selectedLayoutVersion?.label === skipImport);


useEffect(() => {
if (
fileItems &&
!importError &&
Object.values(fileItems).some(
(item) => item?.majorVersion != null || item?.minorVersion != null
)
) {
setShowFileItems(true);
} else if (
processVersion?.majorVersion != null ||
processVersion?.minorVersion != null
) {
setShowFileItems(true);
} else {
setShowFileItems(false);
}
}, [importError, fileItems]);

useEffect(() => {
const fileItemsHasVersion = fileItems && Object.values(fileItems).some(hasVersion);
const processVersionHasVersion = hasVersion(processVersion);
if (fileItemsHasVersion || processVersionHasVersion) {
setShowFileItems(true);
} else {
setShowFileItems(false);
}
}, [importError, fileItems, processVersion]);

useEffect(() => {
if (!showModal) {
Expand Down

0 comments on commit 2a656f9

Please sign in to comment.