From fc9de4e6a53536706a8392d40389ca9a7059472a Mon Sep 17 00:00:00 2001 From: sijumoncy <72241997+sijumoncy@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:21:05 +0530 Subject: [PATCH 1/3] spinner added for import project --- renderer/src/components/LoadingSpinner/LoadingSpinner.js | 8 ++++++-- renderer/src/layouts/projects/ImportProjectPopUp.js | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/renderer/src/components/LoadingSpinner/LoadingSpinner.js b/renderer/src/components/LoadingSpinner/LoadingSpinner.js index f520f306c..595e0cab2 100644 --- a/renderer/src/components/LoadingSpinner/LoadingSpinner.js +++ b/renderer/src/components/LoadingSpinner/LoadingSpinner.js @@ -1,7 +1,11 @@ -export default function LoadingSpinner() { +export default function LoadingSpinner({ + height = 'h-10', + width = 'w-10', + colorTW = 'text-primary', +}) { return (
- + diff --git a/renderer/src/layouts/projects/ImportProjectPopUp.js b/renderer/src/layouts/projects/ImportProjectPopUp.js index 7224a951c..55879aedb 100644 --- a/renderer/src/layouts/projects/ImportProjectPopUp.js +++ b/renderer/src/layouts/projects/ImportProjectPopUp.js @@ -18,6 +18,7 @@ import * as logger from '../../logger'; import ConfirmationModal from '../editor/ConfirmationModal'; import burrito from '../../lib/BurritoTemplete.json'; import { mergeProject } from './Import/mergeProject'; +import { LoadingSpinner } from '@/components/LoadingSpinner'; export default function ImportProjectPopUp(props) { const { @@ -325,7 +326,9 @@ export default function ImportProjectPopUp(props) { className="py-2 px-7 rounded shadow bg-success text-white uppercase text-xs tracking-widest font-semibold" onClick={() => importProject()} > - {t('btn-import')} + {importProgress.importStarted + ? + : t('btn-import')} )}
From a442fbfd04c793b54e2288fb2b12476b8efac20c Mon Sep 17 00:00:00 2001 From: sijumoncy <72241997+sijumoncy@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:28:04 +0530 Subject: [PATCH 2/3] spninner added for export --- renderer/src/layouts/projects/Export/ExportProjectPopUp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renderer/src/layouts/projects/Export/ExportProjectPopUp.js b/renderer/src/layouts/projects/Export/ExportProjectPopUp.js index 46969e530..e1e072a7c 100644 --- a/renderer/src/layouts/projects/Export/ExportProjectPopUp.js +++ b/renderer/src/layouts/projects/Export/ExportProjectPopUp.js @@ -11,6 +11,7 @@ import updateTranslationSB from '@/core/burrito/updateTranslationSB'; import updateObsSB from '@/core/burrito/updateObsSB'; import { SnackBar } from '@/components/SnackBar'; // import useSystemNotification from '@/components/hooks/useSystemNotification'; +import { LoadingSpinner } from '@/components/LoadingSpinner'; import CloseIcon from '@/illustrations/close-button-black.svg'; import { validate } from '../../../util/validate'; import * as logger from '../../../logger'; @@ -311,7 +312,7 @@ export default function ExportProjectPopUp(props) { type="button" className="py-2 px-7 rounded shadow bg-success text-white uppercase text-xs tracking-widest font-semibold" > - {t('btn-export')} + {exportStart ? : t('btn-export')} From cba56f03c0d78e8462d6bf6a85b7614b7f4e8789 Mon Sep 17 00:00:00 2001 From: sijumoncy <72241997+sijumoncy@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:18:42 +0530 Subject: [PATCH 3/3] chapter level import error --- renderer/src/core/burrito/importBurrito.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/renderer/src/core/burrito/importBurrito.js b/renderer/src/core/burrito/importBurrito.js index bb8ee8189..75277de44 100644 --- a/renderer/src/core/burrito/importBurrito.js +++ b/renderer/src/core/burrito/importBurrito.js @@ -173,6 +173,16 @@ const updateAudioDir = async (dir, path, fs, status) => { } }; +const checkTheProjectIsAudioChapterLevel = async (metadata) => { + const chapterPathRegex = /^[0-9]{1,3}\.(mp3|wav)/gm; + const chapterLevel = Object.keys(metadata.ingredients).some((path) => { + const pathArr = path.split('/'); + const fileName = pathArr[pathArr.length - 1]; + return chapterPathRegex.test(fileName); +}); + return chapterLevel; +}; + // Core Function Handle Burrito Import for all type of Projects const importBurrito = async (filePath, currentUser, updateBurritoVersion, concatedLangs = []) => { logger.debug('importBurrito.js', 'Inside importBurrito'); @@ -187,6 +197,15 @@ const importBurrito = async (filePath, currentUser, updateBurritoVersion, concat logger.debug('importBurrito.js', 'Project has Burrito file metadata.json.'); let sb = fs.readFileSync(path.join(filePath, 'metadata.json')); let metadata = JSON.parse(sb); + // check if its an audio import and not the import burrito is for chapter level export + if (metadata.type?.flavorType?.flavor?.name === 'audioTranslation') { + const chapterLevel = await checkTheProjectIsAudioChapterLevel(metadata); + if (chapterLevel) { + logger.error('importBurrito.js', 'Import not supported for chapter level audio projects'); + status.push({ type: 'error', value: 'Import not supported for chapter level audio projects' }); + return status; + } + } // Fixing the issue of previous version of AG. The dateCreated was left empty and it will fail the validation. if (!metadata?.meta?.dateCreated) { const agId = Object.keys(metadata?.identification?.primary?.scribe);