-
+ customData.length > 1 ? (
+
+ {({ open }) => (
+
+
- language?.ang}
- displayValue={(selectedList) => `${selectedList.length > 0 ? `${selectedList[0][filterParams]}${multiSelect ? '... click for more' : '' }` : ''}`}
- placeholder={placeholder}
- aria-label="custom-dropdown"
- onFocus={() => !open && setIsActive(true)}
- onBlur={() => setIsActive(false)}
- onChange={(event) => setQuery(event.target.value)}
- />
- {dropArrow && (
-
-
-
- )}
-
+
language?.ang}
+ displayValue={(selectedList) => `${selectedList.length > 0 ? `${selectedList[0][filterParams]}${multiSelect ? '... click for more' : '' }` : ''}`}
+ placeholder={placeholder}
+ aria-label="custom-dropdown"
+ onFocus={() => !open && setIsActive(true)}
+ onBlur={() => setIsActive(false)}
+ onChange={(event) => setQuery(event.target.value)}
+ />
+ {dropArrow && (
+
+
+
+ )}
+
-
-
-
- {selectedList.length > 0 && !query.length > 0 &&
}
- {filteredData.length > 0
+
+
+
+ {selectedList.length > 0 && !query.length > 0 &&
}
+ {filteredData.length > 0
? filteredData.map((data) => (
//
{data[filterParams] }
{' '}
{showLangCode.show && (
-
- (
- {data[showLangCode.langkey]}
- )
-
+
+ (
+ {data[showLangCode.langkey]}
+ )
+
)}
)) : query?.length > 2 && No Match Found }
-
-
- {/* selected list */}
-
- )}
-
- ) : (
- // only one item in dropdown
-
-
-
+
+
+ {/* selected list */}
+ )}
+
+ ) : (
+ // only one item in dropdown
+
+ )
);
}
diff --git a/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js b/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js
index 1a91c426f..46cb20cb9 100644
--- a/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js
+++ b/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js
@@ -6,195 +6,195 @@ import { isElectron } from '@/core/handleElectron';
import * as logger from '../../../logger';
import packageInfo from '../../../../../package.json';
import {
- createDirectory, newPath, sbStorageRemove, sbStorageList, sbStorageDownload,
+ createDirectory, newPath, sbStorageRemove, sbStorageList, sbStorageDownload,
} from '../../../../../supabase';
const JSZip = require('jszip');
const DownloadCreateSBforHelps = async (projectResource, setLoading, update = false, offlineResource = false) => {
- if (isElectron()) {
- try {
- logger.debug('DownloadCreateSBforHelps.js', 'Download Started');
- setLoading(true);
- await localForage.getItem('userProfile').then(async (user) => {
- logger.debug('DownloadCreateSBforHelps.js', 'In helps-resource download user fetch - ', user?.username);
- const fs = window.require('fs');
- const path = require('path');
- const newpath = localStorage.getItem('userPath');
- const folder = path.join(newpath, packageInfo.name, 'users', `${user?.username}`, 'resources');
- // const currentUser = user?.username;
- // const key = currentUser + projectResource.name + projectResource.owner + moment().format();
- // const id = uuidv5(key, environment.uuidToken);
- // check for existing resources
- const existingResource = fs.readdirSync(folder, { withFileTypes: true });
- const downloadProjectName = `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`;
- existingResource?.forEach((element) => {
- if (downloadProjectName === element.name) {
- throw new Error('Resource Already Exist');
- }
- });
+ if (isElectron()) {
+ try {
+ logger.debug('DownloadCreateSBforHelps.js', 'Download Started');
+ setLoading(true);
+ await localForage.getItem('userProfile').then(async (user) => {
+ logger.debug('DownloadCreateSBforHelps.js', 'In helps-resource download user fetch - ', user?.username);
+ const fs = window.require('fs');
+ const path = require('path');
+ const newpath = localStorage.getItem('userPath');
+ const folder = path.join(newpath, packageInfo.name, 'users', `${user?.username}`, 'resources');
+ // const currentUser = user?.username;
+ // const key = currentUser + projectResource.name + projectResource.owner + moment().format();
+ // const id = uuidv5(key, environment.uuidToken);
+ // check for existing resources
+ const existingResource = fs.readdirSync(folder, { withFileTypes: true });
+ const downloadProjectName = `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`;
+ existingResource?.forEach((element) => {
+ if (downloadProjectName === element.name) {
+ throw new Error('Resource Already Exist');
+ }
+ });
- // check if resource already exist in offline
- if (!update && offlineResource) {
- // eslint-disable-next-line array-callback-return
- const resourceExist = offlineResource.filter((offline) => {
- if (offline?.projectDir === `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`) {
- return offline;
- }
- });
- if (resourceExist.length > 0) {
- throw new Error('Resource Already Exist');
- // eslint-disable-next-line no-throw-literal
- // throw 'Resource Already Exist';
- }
- }
+ // check if resource already exist in offline
+ if (!update && offlineResource) {
+ // eslint-disable-next-line array-callback-return
+ const resourceExist = offlineResource.filter((offline) => {
+ if (offline?.projectDir === `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`) {
+ return offline;
+ }
+ });
+ if (resourceExist.length > 0) {
+ throw new Error('Resource Already Exist');
+ // eslint-disable-next-line no-throw-literal
+ // throw 'Resource Already Exist';
+ }
+ }
- // eslint-disable-next-line no-async-promise-executor
- // return new Promise(async (resolve) => {
- // const json = {};
- // download and unzip the content
- await fetch(projectResource?.zipball_url)
- .then((res) => res.arrayBuffer())
- .then(async (blob) => {
- logger.debug('DownloadCreateSBforHelps.js', 'In resource download - downloading zip content ');
- if (!fs.existsSync(folder)) {
- fs.mkdirSync(folder, { recursive: true });
- }
- // wririntg zip to local
- await fs.writeFileSync(path.join(folder, `${projectResource?.name}.zip`), Buffer.from(blob));
- logger.debug('DownloadCreateSBforHelps.js', 'In resource download - downloading zip content completed ');
+ // eslint-disable-next-line no-async-promise-executor
+ // return new Promise(async (resolve) => {
+ // const json = {};
+ // download and unzip the content
+ await fetch(projectResource?.zipball_url)
+ .then((res) => res.arrayBuffer())
+ .then(async (blob) => {
+ logger.debug('DownloadCreateSBforHelps.js', 'In resource download - downloading zip content ');
+ if (!fs.existsSync(folder)) {
+ fs.mkdirSync(folder, { recursive: true });
+ }
+ // wririntg zip to local
+ await fs.writeFileSync(path.join(folder, `${projectResource?.name}.zip`), Buffer.from(blob));
+ logger.debug('DownloadCreateSBforHelps.js', 'In resource download - downloading zip content completed ');
- // extract zip
- logger.debug('DownloadCreateSBforHelps.js', 'In resource download - Unzip downloaded resource');
- const filecontent = await fs.readFileSync(path.join(folder, `${projectResource?.name}.zip`));
- const result = await JSZip.loadAsync(filecontent);
- const keys = Object.keys(result.files);
+ // extract zip
+ logger.debug('DownloadCreateSBforHelps.js', 'In resource download - Unzip downloaded resource');
+ const filecontent = await fs.readFileSync(path.join(folder, `${projectResource?.name}.zip`));
+ const result = await JSZip.loadAsync(filecontent);
+ const keys = Object.keys(result.files);
- // eslint-disable-next-line no-restricted-syntax
- for (const key of keys) {
- const item = result.files[key];
- if (item.dir) {
- fs.mkdirSync(path.join(folder, item.name), { recursive: true });
- } else {
- // eslint-disable-next-line no-await-in-loop
- const bufferContent = Buffer.from(await item.async('arraybuffer'));
- fs.writeFileSync(path.join(folder, item.name), bufferContent);
- }
- }
- // let resourceMeta = {};
- await fetch(projectResource.metadata_json_url)
- .then((res) => res.json())
- .then(async (data) => {
- // adding offline true tag in meta for identification
- data.agOffline = true;
- data.meta = projectResource;
- data.lastUpdatedAg = moment().format();
- await fs.writeFileSync(path.join(folder, projectResource?.name, 'metadata.json'), JSON.stringify(data));
- }).catch((err) => {
- logger.debug('DownloadCreateSBforHelps.js', 'failed to save yml metadata.json : ', err);
- });
+ // eslint-disable-next-line no-restricted-syntax
+ for (const key of keys) {
+ const item = result.files[key];
+ if (item.dir) {
+ fs.mkdirSync(path.join(folder, item.name), { recursive: true });
+ } else {
+ // eslint-disable-next-line no-await-in-loop
+ const bufferContent = Buffer.from(await item.async('arraybuffer'));
+ fs.writeFileSync(path.join(folder, item.name), bufferContent);
+ }
+ }
+ // let resourceMeta = {};
+ await fetch(projectResource.metadata_json_url)
+ .then((res) => res.json())
+ .then(async (data) => {
+ // adding offline true tag in meta for identification
+ data.agOffline = true;
+ data.meta = projectResource;
+ data.lastUpdatedAg = moment().format();
+ await fs.writeFileSync(path.join(folder, projectResource?.name, 'metadata.json'), JSON.stringify(data));
+ }).catch((err) => {
+ logger.debug('DownloadCreateSBforHelps.js', 'failed to save yml metadata.json : ', err);
+ });
- // finally remove zip and rename base folder to projectname_id
- logger.debug('DownloadCreateSBforHelps.js', 'deleting zip file - rename project with project + id in scribe format');
- if (fs.existsSync(folder)) {
- fs.renameSync(path.join(folder, projectResource?.name), path.join(folder, `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`));
- fs.unlinkSync(path.join(folder, `${projectResource?.name}.zip`), (err) => {
- if (err) {
- logger.debug('DownloadCreateSBforHelps.js', 'error in deleting zip');
- throw new Error(`Removing Resource Zip Failed : ${projectResource?.name}.zip`);
- }
- });
- if (update && update?.status) {
- // if updation delete old resource
- try {
- fs.rmSync(path.join(folder, `${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`), { recursive: true });
- update && update?.setIsOpen(false);
- } catch (err) {
- logger.debug('DownloadCreateSBforHelps.js', 'error in deleting prev resource');
- setLoading(false);
- throw new Error(`Removing Previous Resource Failed : ${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`);
- }
- }
- }
- });
- logger.debug('DownloadCreateSBforHelps.js', 'download completed');
- setLoading(false);
- });
- } catch (err) {
- setLoading(false);
- throw err;
- }
- } else {
- const userProfile = await localForage.getItem('userProfile');
- const username = userProfile?.user?.email;
- try {
- setLoading(true);
- const folder = `${newPath}/${username}/resources`;
- const { data: existingResource } = await sbStorageDownload(folder);
- const downloadProjectName = `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`;
- existingResource?.forEach((element) => {
- if (downloadProjectName === element.name) {
- throw new Error('Resource Already Exist');
+ // finally remove zip and rename base folder to projectname_id
+ logger.debug('DownloadCreateSBforHelps.js', 'deleting zip file - rename project with project + id in scribe format');
+ if (fs.existsSync(folder)) {
+ fs.renameSync(path.join(folder, projectResource?.name), path.join(folder, `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`));
+ fs.unlinkSync(path.join(folder, `${projectResource?.name}.zip`), (err) => {
+ if (err) {
+ logger.debug('DownloadCreateSBforHelps.js', 'error in deleting zip');
+ throw new Error(`Removing Resource Zip Failed : ${projectResource?.name}.zip`);
}
- });
-
- await fetch(projectResource?.zipball_url).then((res) => res.arrayBuffer()).then(async (blob) => {
- const { data: folderExist } = await sbStorageList(folder);
- if (!folderExist) {
- await createDirectory({ path: folder });
+ });
+ if (update && update?.status) {
+ // if updation delete old resource
+ try {
+ fs.rmSync(path.join(folder, `${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`), { recursive: true });
+ update && update?.setIsOpen(false);
+ } catch (err) {
+ logger.debug('DownloadCreateSBforHelps.js', 'error in deleting prev resource');
+ setLoading(false);
+ throw new Error(`Removing Previous Resource Failed : ${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`);
}
- // writing zip to local
- await createDirectory({ path: `${folder}/${projectResource?.name}.zip}`, payload: Buffer.from(blob) });
+ }
+ }
+ });
+ logger.debug('DownloadCreateSBforHelps.js', 'download completed');
+ setLoading(false);
+ });
+ } catch (err) {
+ setLoading(false);
+ throw err;
+ }
+ } else {
+ const userProfile = await localForage.getItem('userProfile');
+ const username = userProfile?.user?.email;
+ try {
+ setLoading(true);
+ const folder = `${newPath}/${username}/resources`;
+ const { data: existingResource } = await sbStorageDownload(folder);
+ const downloadProjectName = `${projectResource?.name}_${projectResource?.owner}_${projectResource?.release?.tag_name}`;
+ existingResource?.forEach((element) => {
+ if (downloadProjectName === element.name) {
+ throw new Error('Resource Already Exist');
+ }
+ });
- // extract zip
- const { data: filecontent, error: fileContentError } = await sbStorageDownload(`${folder}/${projectResource?.name}.zip}`);
- if (fileContentError) {
- // eslint-disable-next-line no-console
- console.log('Failed to download zip file', fileContentError);
- }
+ await fetch(projectResource?.zipball_url).then((res) => res.arrayBuffer()).then(async (blob) => {
+ const { data: folderExist } = await sbStorageList(folder);
+ if (!folderExist) {
+ await createDirectory({ path: folder });
+ }
+ // writing zip to local
+ await createDirectory({ path: `${folder}/${projectResource?.name}.zip}`, payload: Buffer.from(blob) });
- const result = await JSZip.loadAsync(filecontent);
- const keys = Object.keys(result.files);
+ // extract zip
+ const { data: filecontent, error: fileContentError } = await sbStorageDownload(`${folder}/${projectResource?.name}.zip}`);
+ if (fileContentError) {
+ // eslint-disable-next-line no-console
+ console.log('Failed to download zip file', fileContentError);
+ }
- for (const key of keys) {
- const item = result.files[key];
- if (item.dir) {
- await createDirectory({ path: `${folder}/${item.name}` });
- } else {
- const bufferContent = Buffer.from(await item.async('arraybuffer'));
- await createDirectory({ path: `${folder}/${item.name}`, payload: bufferContent });
- }
- }
+ const result = await JSZip.loadAsync(filecontent);
+ const keys = Object.keys(result.files);
- await fetch(projectResource.metadata_json_url).then((res) => res.json()).then(async (data) => {
- data.agOffline = true;
- data.meta = projectResource;
- data.lastUpdatedAg = moment().format();
- await createDirectory({ path: `${folder}/${projectResource?.name}/metadata.json`, payload: JSON.stringify(data) });
- }).catch((err) => {
- // eslint-disable-next-line no-console
- console.log('DownloadCreateSBforHelps.js', 'failed to save yml metadata.json : ', err);
- });
+ for (const key of keys) {
+ const item = result.files[key];
+ if (item.dir) {
+ await createDirectory({ path: `${folder}/${item.name}` });
+ } else {
+ const bufferContent = Buffer.from(await item.async('arraybuffer'));
+ await createDirectory({ path: `${folder}/${item.name}`, payload: bufferContent });
+ }
+ }
- // finally remove zip and rename base folder to projectname_id
- if (folderExist) {
- if (update && update?.status) {
- // if updation delete old resource
- try {
- sbStorageRemove(`folder/${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`);
- update && update?.setIsOpen(false);
- } catch (err) {
- logger.debug('DownloadCreateSBforHelps.js', 'error in deleting prev resource');
- setLoading(false);
- throw new Error(`Removing Previous Resource Failed : ${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`);
- }
- }
- }
- });
- } catch (error) {
- setLoading(false);
+ await fetch(projectResource.metadata_json_url).then((res) => res.json()).then(async (data) => {
+ data.agOffline = true;
+ data.meta = projectResource;
+ data.lastUpdatedAg = moment().format();
+ await createDirectory({ path: `${folder}/${projectResource?.name}/metadata.json`, payload: JSON.stringify(data) });
+ }).catch((err) => {
+ // eslint-disable-next-line no-console
+ console.log('DownloadCreateSBforHelps.js', 'failed to save yml metadata.json : ', err);
+ });
+
+ // finally remove zip and rename base folder to projectname_id
+ if (folderExist) {
+ if (update && update?.status) {
+ // if updation delete old resource
+ try {
+ sbStorageRemove(`folder/${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`);
+ update && update?.setIsOpen(false);
+ } catch (err) {
+ logger.debug('DownloadCreateSBforHelps.js', 'error in deleting prev resource');
+ setLoading(false);
+ throw new Error(`Removing Previous Resource Failed : ${projectResource?.name}_${projectResource?.owner}_${update?.prevVersion}`);
+ }
+ }
}
+ });
+ } catch (error) {
+ setLoading(false);
}
+ }
};
export default DownloadCreateSBforHelps;
diff --git a/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js b/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js
index e7f9a8c07..cf75e64ea 100644
--- a/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js
+++ b/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js
@@ -95,28 +95,28 @@ function DownloadResourcePopUp({ selectResource, isOpenDonwloadPopUp, setIsOpenD
} else {
// nothing selected default will be bible || obs
switch (selectResource) {
- case 'bible':
- url += '&subject=Bible';
- break;
- case 'obs':
- url += `&subject=${subjectTypeArray.obs[0].name}`;
- break;
- default:
- break;
- }
- }
- } else {
- // initial load
- switch (selectResource) {
case 'bible':
- url = `${baseUrl}&lang=en&subject=${subjectTypeArray.bible[0].name}`;
- // setSelectedTypeFilter([subjectTypeArray.bible[0]]);
+ url += '&subject=Bible';
break;
case 'obs':
- url = `${baseUrl}&subject=${subjectTypeArray.obs[0].name}&lang=en`;
+ url += `&subject=${subjectTypeArray.obs[0].name}`;
break;
default:
break;
+ }
+ }
+ } else {
+ // initial load
+ switch (selectResource) {
+ case 'bible':
+ url = `${baseUrl}&lang=en&subject=${subjectTypeArray.bible[0].name}`;
+ // setSelectedTypeFilter([subjectTypeArray.bible[0]]);
+ break;
+ case 'obs':
+ url = `${baseUrl}&subject=${subjectTypeArray.obs[0].name}&lang=en`;
+ break;
+ default:
+ break;
}
}
// pre-release items
diff --git a/renderer/src/components/Resources/ResourceUtils/RemoveResource.js b/renderer/src/components/Resources/ResourceUtils/RemoveResource.js
index 16840768b..8a3609d60 100644
--- a/renderer/src/components/Resources/ResourceUtils/RemoveResource.js
+++ b/renderer/src/components/Resources/ResourceUtils/RemoveResource.js
@@ -18,8 +18,8 @@ const path = require('path');
const ResourceResetAfterCheckSameOnRefResourceAgSettings = async (setResetResourceOnDeleteOffline, resource) => {
logger.debug('RemoveResource.js', 'Search for multiple pane open same resource before download');
const refsHistory = [];
- localForage.getItem('currentProject').then(async (projectName) => {
- const _projectname = await splitStringByLastOccurence(projectName, '_');
+ localForage.getItem('currentProject').then(async (projectName) => {
+ const _projectname = await splitStringByLastOccurence(projectName, '_');
// const _projectname = projectName?.split('_');
localForage.getItem('projectmeta').then((value) => {
Object.entries(value).forEach(
@@ -53,40 +53,40 @@ const ResourceResetAfterCheckSameOnRefResourceAgSettings = async (setResetResour
);
if (resourcePane.length > 0) {
// read Scribe-settings
- if (resourcePane.includes('01')) {
- logger.debug('RemoveResource.js', 'Referesh pane 01 contains current deleted resource');
- setResetResourceOnDeleteOffline((prev) => ({
- ...prev,
- referenceColumnOneData1Reset: true,
+ if (resourcePane.includes('01')) {
+ logger.debug('RemoveResource.js', 'Referesh pane 01 contains current deleted resource');
+ setResetResourceOnDeleteOffline((prev) => ({
+ ...prev,
+ referenceColumnOneData1Reset: true,
+ }
+ ));
}
- ));
- }
- if (resourcePane.includes('02')) {
- logger.debug('RemoveResource.js', 'Referesh pane 02 contains current deleted resource');
- setResetResourceOnDeleteOffline((prev) => ({
- ...prev,
- referenceColumnOneData2Reset: true,
+ if (resourcePane.includes('02')) {
+ logger.debug('RemoveResource.js', 'Referesh pane 02 contains current deleted resource');
+ setResetResourceOnDeleteOffline((prev) => ({
+ ...prev,
+ referenceColumnOneData2Reset: true,
+ }
+ ));
}
- ));
- }
- if (resourcePane.includes('11')) {
- logger.debug('RemoveResource.js', 'Referesh pane 11 contains current deleted resource');
- setResetResourceOnDeleteOffline((prev) => ({
- ...prev,
- referenceColumnTwoData1Reset: true,
+ if (resourcePane.includes('11')) {
+ logger.debug('RemoveResource.js', 'Referesh pane 11 contains current deleted resource');
+ setResetResourceOnDeleteOffline((prev) => ({
+ ...prev,
+ referenceColumnTwoData1Reset: true,
+ }
+ ));
}
- ));
- }
- if (resourcePane.includes('12')) {
- logger.debug('RemoveResource.js', 'Referesh pane 12 contains current deleted resource');
- setResetResourceOnDeleteOffline((prev) => ({
- ...prev,
- referenceColumnTwoData2Reset: true,
+ if (resourcePane.includes('12')) {
+ logger.debug('RemoveResource.js', 'Referesh pane 12 contains current deleted resource');
+ setResetResourceOnDeleteOffline((prev) => ({
+ ...prev,
+ referenceColumnTwoData2Reset: true,
+ }
+ ));
}
- ));
}
}
- }
});
});
};
@@ -94,109 +94,109 @@ const ResourceResetAfterCheckSameOnRefResourceAgSettings = async (setResetResour
function RemoveResource({
resource, selectResource, setRenderApp,
}) {
- logger.warn('removeResource.js', 'inside remove resource');
- const { t } = useTranslation();
- const [snackBar, setOpenSnackBar] = React.useState(false);
- const [snackText, setSnackText] = React.useState('');
- // eslint-disable-next-line no-unused-vars
- const [notify, setNotify] = React.useState();
- const [openModal, setOpenModal] = React.useState(false);
+ logger.warn('removeResource.js', 'inside remove resource');
+ const { t } = useTranslation();
+ const [snackBar, setOpenSnackBar] = React.useState(false);
+ const [snackText, setSnackText] = React.useState('');
+ // eslint-disable-next-line no-unused-vars
+ const [notify, setNotify] = React.useState();
+ const [openModal, setOpenModal] = React.useState(false);
- // React.useEffect(() => {
- // }, []);
+ // React.useEffect(() => {
+ // }, []);
- const {
- // state: {
- // resetResourceOnDeleteOffline,
- // },
- actions: {
- setResetResourceOnDeleteOffline,
- },
- } = useContext(ReferenceContext);
+ const {
+ // state: {
+ // resetResourceOnDeleteOffline,
+ // },
+ actions: {
+ setResetResourceOnDeleteOffline,
+ },
+ } = useContext(ReferenceContext);
- const handleRemoveResourceResources = async () => {
- logger.warn('removeResource.js', 'inside removing resource call');
- localForage.getItem('userProfile').then(async (user) => {
- logger.debug('DownloadResourcePopUp.js', 'In resource download user fetch - ', user?.username);
- const fs = window.require('fs');
- const newpath = localStorage.getItem('userPath');
- const folder = path.join(newpath, packageInfo.name, 'users', `${user?.username}`, 'resources');
- let resourceName = null;
- switch (selectResource) {
- case 'obs':
- case 'bible':
- case 'audio':
- resourceName = resource?.projectDir;
- break;
- case 'tn':
- case 'tw':
- case 'ta':
- case 'tq':
- case 'obs-tn':
- case 'obs-tq':
- resourceName = resource?.projectDir;
- break;
- default:
- break;
- }
- await fs.rmdir(path.join(folder, resourceName), { recursive: true }, async (err) => {
- if (err) {
- setOpenSnackBar(true);
- setNotify('failure');
- setSnackText('Remove Resource Failed');
- // throw new Error(`Remove Resource failed : ${err}`);
- }
- // console.log('resource remove success');
- // read Scribe-settings of the project
- await ResourceResetAfterCheckSameOnRefResourceAgSettings(setResetResourceOnDeleteOffline, resource);
- // handleRowSelect(null, null, null, null, '');
- setRenderApp(true);
- setOpenSnackBar(true);
- setNotify('success');
- setSnackText('Removed Resource Successfully');
- });
- });
- };
-
- return (
- <>
-
setOpenModal(true)}
- >
-
-
+ const handleRemoveResourceResources = async () => {
+ logger.warn('removeResource.js', 'inside removing resource call');
+ localForage.getItem('userProfile').then(async (user) => {
+ logger.debug('DownloadResourcePopUp.js', 'In resource download user fetch - ', user?.username);
+ const fs = window.require('fs');
+ const newpath = localStorage.getItem('userPath');
+ const folder = path.join(newpath, packageInfo.name, 'users', `${user?.username}`, 'resources');
+ let resourceName = null;
+ switch (selectResource) {
+ case 'obs':
+ case 'bible':
+ case 'audio':
+ resourceName = resource?.projectDir;
+ break;
+ case 'tn':
+ case 'tw':
+ case 'ta':
+ case 'tq':
+ case 'obs-tn':
+ case 'obs-tq':
+ resourceName = resource?.projectDir;
+ break;
+ default:
+ break;
+ }
+ await fs.rmdir(path.join(folder, resourceName), { recursive: true }, async (err) => {
+ if (err) {
+ setOpenSnackBar(true);
+ setNotify('failure');
+ setSnackText('Remove Resource Failed');
+ // throw new Error(`Remove Resource failed : ${err}`);
+ }
+ // console.log('resource remove success');
+ // read Scribe-settings of the project
+ await ResourceResetAfterCheckSameOnRefResourceAgSettings(setResetResourceOnDeleteOffline, resource);
+ // handleRowSelect(null, null, null, null, '');
+ setRenderApp(true);
+ setOpenSnackBar(true);
+ setNotify('success');
+ setSnackText('Removed Resource Successfully');
+ });
+ });
+ };
-
+ setOpenModal(true)}
+ >
+
+
- handleRemoveResourceResources()}
- />
+
+
+ handleRemoveResourceResources()}
+ />
- >
- );
+ >
+ );
}
RemoveResource.propTypes = {
- resource: PropTypes.object,
- selectResource: PropTypes.string,
- setRenderApp: PropTypes.func,
- };
+ resource: PropTypes.object,
+ selectResource: PropTypes.string,
+ setRenderApp: PropTypes.func,
+};
export default RemoveResource;
diff --git a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js
index 9352feb6e..e04670632 100644
--- a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js
+++ b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js
@@ -46,16 +46,16 @@ export const createDownloadedResourceSB = async (username, resourceMeta, project
// console.log('unique id : ', id);
let json = {};
switch (selectResource) {
- case 'bible':
- // json = { ...Textburrito };
- json = Textburrito;
- break;
- case 'obs':
- // json = { ...OBSburrito };
- json = OBSburrito;
- break;
- default:
- throw new Error(' can not process : Invalid Type od Resource requested');
+ case 'bible':
+ // json = { ...Textburrito };
+ json = Textburrito;
+ break;
+ case 'obs':
+ // json = { ...OBSburrito };
+ json = OBSburrito;
+ break;
+ default:
+ throw new Error(' can not process : Invalid Type od Resource requested');
// break;
}
return new Promise((resolve) => {
@@ -380,24 +380,24 @@ export const handleDownloadResources = async (resourceData, selectResource, acti
// ingredients add to burrito
switch (selectResource) {
- case 'bible':
- if (currentResourceMeta.format && currentResourceMeta.format === 'scripture burrito') {
- resourceBurritoFile.ingredients = currentResourceMeta.ingredients;
- } else {
- resourceBurritoFile = await generateResourceIngredientsTextTransaltion(currentResourceMeta, path, folder, currentResourceProject, resourceBurritoFile);
- }
- customLicenseContent = customLicense;
- break;
- case 'obs':
- if (currentResourceMeta.format && currentResourceMeta.format === 'scripture burrito') {
- resourceBurritoFile.ingredients = currentResourceMeta.ingredients;
- } else {
- resourceBurritoFile = await generateResourceIngredientsOBS(currentResourceMeta, path, folder, currentResourceProject, resourceBurritoFile, keys);
- }
- customLicenseContent = OBSLicense;
- break;
- default:
- throw new Error('Cannot process : Invalid Type of requested Resource');
+ case 'bible':
+ if (currentResourceMeta.format && currentResourceMeta.format === 'scripture burrito') {
+ resourceBurritoFile.ingredients = currentResourceMeta.ingredients;
+ } else {
+ resourceBurritoFile = await generateResourceIngredientsTextTransaltion(currentResourceMeta, path, folder, currentResourceProject, resourceBurritoFile);
+ }
+ customLicenseContent = customLicense;
+ break;
+ case 'obs':
+ if (currentResourceMeta.format && currentResourceMeta.format === 'scripture burrito') {
+ resourceBurritoFile.ingredients = currentResourceMeta.ingredients;
+ } else {
+ resourceBurritoFile = await generateResourceIngredientsOBS(currentResourceMeta, path, folder, currentResourceProject, resourceBurritoFile, keys);
+ }
+ customLicenseContent = OBSLicense;
+ break;
+ default:
+ throw new Error('Cannot process : Invalid Type of requested Resource');
}
logger.debug('passed ingredients creations ---------->');
@@ -493,7 +493,7 @@ export const handleDownloadResources = async (resourceData, selectResource, acti
};
export const handleDownloadWebResources = async (resourceData, selectResource, action, update = false) => {
- // eslint-disable-next-line no-console
+ // eslint-disable-next-line no-console
console.log({
resourceData,
selectResource,
@@ -585,27 +585,27 @@ export const handleDownloadWebResources = async (resourceData, selectResource, a
// ingredients add to burrito
switch (selectResource) {
- case 'bible':
- resourceBurritoFile = await generateResourceIngredientsTextTransaltion(
- currentResourceMeta,
- // supabaseStorage(),
- folder,
- currentResourceProject,
- resourceBurritoFile,
- );
- customLicenseContent = customLicense;
- break;
- case 'obs':
- resourceBurritoFile = await generateWebResourceIngredientsOBS(
- currentResourceMeta,
- currentResourceProject,
- resourceBurritoFile,
- Object.keys(zip.files),
- );
- customLicenseContent = OBSLicense;
- break;
- default:
- throw new Error('Cannot process: Invalid type of resource requested');
+ case 'bible':
+ resourceBurritoFile = await generateResourceIngredientsTextTransaltion(
+ currentResourceMeta,
+ // supabaseStorage(),
+ folder,
+ currentResourceProject,
+ resourceBurritoFile,
+ );
+ customLicenseContent = customLicense;
+ break;
+ case 'obs':
+ resourceBurritoFile = await generateWebResourceIngredientsOBS(
+ currentResourceMeta,
+ currentResourceProject,
+ resourceBurritoFile,
+ Object.keys(zip.files),
+ );
+ customLicenseContent = OBSLicense;
+ break;
+ default:
+ throw new Error('Cannot process: Invalid type of resource requested');
}
if (!licenseFileFound) {
@@ -657,7 +657,7 @@ export const handleDownloadWebResources = async (resourceData, selectResource, a
await sbStorageUpdate({ path: `${folder}/${currentResourceProject.name}`, payload: `${folder}/${currentProjectName}`, options: { cacheControl: '3600', upsert: true } });
await sbStorageRemove(`${folder}/${currentProjectName}.zip`);
} else {
- // eslint-disable-next-line no-console
+ // eslint-disable-next-line no-console
console.log('error in storage.list ---------->', error);
}
}
@@ -675,7 +675,7 @@ export const handleDownloadWebResources = async (resourceData, selectResource, a
resourceExistCount = 0;
}
} catch (err) {
- // eslint-disable-next-line no-console
+ // eslint-disable-next-line no-console
console.log('Catching error in download resource', err);
reject(err);
}
diff --git a/renderer/src/components/Resources/ResourceUtils/uploadLocalHelpsResources.js b/renderer/src/components/Resources/ResourceUtils/uploadLocalHelpsResources.js
index 5147d1eb8..4602b3cfb 100644
--- a/renderer/src/components/Resources/ResourceUtils/uploadLocalHelpsResources.js
+++ b/renderer/src/components/Resources/ResourceUtils/uploadLocalHelpsResources.js
@@ -55,16 +55,16 @@ export const uploadLocalHelpsResources = async (fs, path, resourcePath, sourcePa
// copy contents from source to target
await fse.copy(sourcePath, path.join(resourcePath, resourceName))
- .then(async () => {
- logger.debug('uploadLocalHelpsResources.js', 'resource copy from src to trg successfull');
- // write metadata into the target dir
- await fs.writeFileSync(path.join(resourcePath, resourceName, 'metadata.json'), JSON.stringify(metaData));
- logger.debug('uploadLocalHelpsResources.js', 'write metadata is successfull and done uploading');
- raiseSnackbarErroOrWarning({
- type: 'success',
- message: 'Resource uploaded successfully',
+ .then(async () => {
+ logger.debug('uploadLocalHelpsResources.js', 'resource copy from src to trg successfull');
+ // write metadata into the target dir
+ await fs.writeFileSync(path.join(resourcePath, resourceName, 'metadata.json'), JSON.stringify(metaData));
+ logger.debug('uploadLocalHelpsResources.js', 'write metadata is successfull and done uploading');
+ raiseSnackbarErroOrWarning({
+ type: 'success',
+ message: 'Resource uploaded successfully',
+ });
});
- });
} else {
// existing resource with same name
logger.debug('uploadLocalHelpsResources.js', 'resource already exist');
diff --git a/renderer/src/components/Resources/ResourcesPopUp.js b/renderer/src/components/Resources/ResourcesPopUp.js
index 140b1768a..680933b59 100644
--- a/renderer/src/components/Resources/ResourcesPopUp.js
+++ b/renderer/src/components/Resources/ResourcesPopUp.js
@@ -1,6 +1,6 @@
/* eslint-disable no-unused-vars */
import React, {
- useRef, useState, useContext, Fragment,
+ useRef, useState, useContext, Fragment,
} from 'react';
import { XMarkIcon } from '@heroicons/react/24/solid';
import ResourcesSidebar from '@/components/Resources/ResourcesSideBar';
diff --git a/renderer/src/components/Resources/ResourcesSideBar.js b/renderer/src/components/Resources/ResourcesSideBar.js
index b181bbb4e..b3af01b93 100644
--- a/renderer/src/components/Resources/ResourcesSideBar.js
+++ b/renderer/src/components/Resources/ResourcesSideBar.js
@@ -32,18 +32,18 @@ export default function ResourcesSidebar({
useEffect(() => {
if (!selectResource) {
switch (selectedProjectMeta.type.flavorType.flavor.name) {
- case 'textTranslation':
- setSelectResource('bible');
- break;
- case 'textStories':
- setSelectResource('obs');
- break;
- case 'audioTranslation':
- setSelectResource('audio');
- break;
- default:
- setSelectResource('bible');
- break;
+ case 'textTranslation':
+ setSelectResource('bible');
+ break;
+ case 'textStories':
+ setSelectResource('obs');
+ break;
+ case 'audioTranslation':
+ setSelectResource('audio');
+ break;
+ default:
+ setSelectResource('bible');
+ break;
}
setTitle('Bible');
}
diff --git a/renderer/src/components/Resources/useHandleChangeQuery.js b/renderer/src/components/Resources/useHandleChangeQuery.js
index af42841c0..b3874a1e3 100644
--- a/renderer/src/components/Resources/useHandleChangeQuery.js
+++ b/renderer/src/components/Resources/useHandleChangeQuery.js
@@ -41,6 +41,6 @@ const handleChangeQuery = (query, resourceData, selectResource, setFilteredResou
setfilteredBibleObsAudio(resourceArray);
}
}
- };
+};
- export default handleChangeQuery;
+export default handleChangeQuery;
diff --git a/renderer/src/components/Search/SearchForm.js b/renderer/src/components/Search/SearchForm.js
index 90386879e..cf85757ba 100644
--- a/renderer/src/components/Search/SearchForm.js
+++ b/renderer/src/components/Search/SearchForm.js
@@ -27,12 +27,12 @@ function SearchForm({
if (lowercasedValue === '') {
return content;
}
- const filteredData = content.filter(
- (item) => Object.keys(item).some((key) => (excludeColumns.includes(key)
- ? false
- : item[key].toString().toLowerCase().includes(lowercasedValue))),
- );
- return filteredData;
+ const filteredData = content.filter(
+ (item) => Object.keys(item).some((key) => (excludeColumns.includes(key)
+ ? false
+ : item[key].toString().toLowerCase().includes(lowercasedValue))),
+ );
+ return filteredData;
}, [excludeColumns]);
// handle change event of search input
diff --git a/renderer/src/components/Search/SearchStyles.js b/renderer/src/components/Search/SearchStyles.js
index b82e34376..d8079a8a0 100644
--- a/renderer/src/components/Search/SearchStyles.js
+++ b/renderer/src/components/Search/SearchStyles.js
@@ -1,54 +1,54 @@
import { alpha, makeStyles } from '@material-ui/core/styles';
export const searchStyles = makeStyles((theme) => ({
- root: {
- flexGrow: 1,
+ root: {
+ flexGrow: 1,
+ },
+ title: {
+ flexGrow: 1,
+ display: 'none',
+ [theme.breakpoints.up('sm')]: {
+ display: 'block',
},
- title: {
- flexGrow: 1,
- display: 'none',
- [theme.breakpoints.up('sm')]: {
- display: 'block',
- },
- },
- search: {
- float: 'right',
- position: 'relative',
- borderRadius: theme.shape.borderRadius,
- backgroundColor: alpha(theme.palette.common.black, 0.15),
- '&:hover': {
- backgroundColor: alpha(theme.palette.common.black, 0.25),
- },
- marginLeft: 0,
- width: '100%',
- [theme.breakpoints.up('sm')]: {
- marginLeft: theme.spacing(1),
- width: 'auto',
- },
- },
- searchIcon: {
- padding: theme.spacing(0, 2),
- height: '100%',
- position: 'absolute',
- pointerEvents: 'none',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
+ },
+ search: {
+ float: 'right',
+ position: 'relative',
+ borderRadius: theme.shape.borderRadius,
+ backgroundColor: alpha(theme.palette.common.black, 0.15),
+ '&:hover': {
+ backgroundColor: alpha(theme.palette.common.black, 0.25),
},
- inputRoot: {
- color: 'inherit',
+ marginLeft: 0,
+ width: '100%',
+ [theme.breakpoints.up('sm')]: {
+ marginLeft: theme.spacing(1),
+ width: 'auto',
},
- inputInput: {
- padding: theme.spacing(1, 1, 1, 0),
- // vertical padding + font size from searchIcon
- paddingLeft: `calc(1em + ${theme.spacing(4)}px)`,
- transition: theme.transitions.create('width'),
- width: '100%',
- [theme.breakpoints.up('sm')]: {
- width: '12ch',
- '&:focus': {
- width: '20ch',
- },
+ },
+ searchIcon: {
+ padding: theme.spacing(0, 2),
+ height: '100%',
+ position: 'absolute',
+ pointerEvents: 'none',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+ inputRoot: {
+ color: 'inherit',
+ },
+ inputInput: {
+ padding: theme.spacing(1, 1, 1, 0),
+ // vertical padding + font size from searchIcon
+ paddingLeft: `calc(1em + ${theme.spacing(4)}px)`,
+ transition: theme.transitions.create('width'),
+ width: '100%',
+ [theme.breakpoints.up('sm')]: {
+ width: '12ch',
+ '&:focus': {
+ width: '20ch',
},
},
- }));
+ },
+}));
diff --git a/renderer/src/components/Signup/WebSignup.js b/renderer/src/components/Signup/WebSignup.js
index b28351ff7..5d6067387 100644
--- a/renderer/src/components/Signup/WebSignup.js
+++ b/renderer/src/components/Signup/WebSignup.js
@@ -25,7 +25,7 @@ function SignupPage() {
createWebUser(data.user);
router.push('/login');
} else {
- // eslint-disable-next-line no-console
+ // eslint-disable-next-line no-console
console.error('error occured', error);
setStatus(error);
}
diff --git a/renderer/src/components/SnackBar/SnackBar.js b/renderer/src/components/SnackBar/SnackBar.js
index 61350b76a..91d75fae5 100644
--- a/renderer/src/components/SnackBar/SnackBar.js
+++ b/renderer/src/components/SnackBar/SnackBar.js
@@ -1,5 +1,5 @@
import React, {
- Fragment, useEffect, useState,
+ Fragment, useEffect, useState,
} from 'react';
import { XMarkIcon } from '@heroicons/react/24/outline';
import { Popover, Transition } from '@headlessui/react';
@@ -30,14 +30,14 @@ const SnackBar = ({
const intervalId = setInterval(() => {
setTimeLeft(timeLeft - 1);
- if (timeLeft <= 1) {
- closeSnackBar();
- }
+ if (timeLeft <= 1) {
+ closeSnackBar();
+ }
}, 1000);
return () => clearInterval(intervalId);
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [timeLeft]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [timeLeft]);
useEffect(() => {
if (openSnackBar) {
diff --git a/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js b/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js
index 7b68c8adc..a001ae3bb 100644
--- a/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js
+++ b/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js
@@ -49,23 +49,23 @@ function EditorSync({ selectedProject }) {
}
const callFunction = async () => {
- setIsOpen(false);
- try {
- if (selectedUsername?.username) {
- logger.debug('EditorSync.js', 'Call handleEditorSync Function');
- const status = await handleEditorSync(currentProjectMeta, selectedUsername, notifyStatus, addNotification, setPullPopup, setSyncProgress);
- setSyncProgress((prev) => ({ ...prev, uploadDone: status }));
- await notifyStatus('success', 'Sync SuccessFull');
- await addNotification('Sync', 'Project Sync Successfull', 'success');
- setLoadData(true);
- } else {
- throw new Error('Please select a valid account to sync..');
- }
- } catch (err) {
- logger.debug('EditorSync.js', `Error Sync : ${err}`);
- await notifyStatus('failure', (window?.navigator?.onLine) ? (err?.message || err) : 'Check your internet connection');
- await addNotification('Sync', (window?.navigator?.onLine) ? (err?.message || err) : 'Check your internet connection', 'failure');
+ setIsOpen(false);
+ try {
+ if (selectedUsername?.username) {
+ logger.debug('EditorSync.js', 'Call handleEditorSync Function');
+ const status = await handleEditorSync(currentProjectMeta, selectedUsername, notifyStatus, addNotification, setPullPopup, setSyncProgress);
+ setSyncProgress((prev) => ({ ...prev, uploadDone: status }));
+ await notifyStatus('success', 'Sync SuccessFull');
+ await addNotification('Sync', 'Project Sync Successfull', 'success');
+ setLoadData(true);
+ } else {
+ throw new Error('Please select a valid account to sync..');
}
+ } catch (err) {
+ logger.debug('EditorSync.js', `Error Sync : ${err}`);
+ await notifyStatus('failure', (window?.navigator?.onLine) ? (err?.message || err) : 'Check your internet connection');
+ await addNotification('Sync', (window?.navigator?.onLine) ? (err?.message || err) : 'Check your internet connection', 'failure');
+ }
};
useEffect(() => {
@@ -79,59 +79,59 @@ function EditorSync({ selectedProject }) {
useEffect(() => {
if (isOpen) {
(async () => {
- if (!selectedUsername && selectedProject) {
- logger.debug('EditorSync.js', 'In useEffect - get meta, SyncUsersList , lastSyncUser/{}');
- await getProjectMeta(selectedProject);
- const syncUsers = await getGiteaUsersList();
- setUsersList(syncUsers);
- if (currentProjectMeta) {
- const syncObj = await getOrPutLastSyncInAgSettings('get', currentProjectMeta);
- if (syncObj && syncUsers) {
- const currentUserObj = syncUsers?.filter((element) => element.username === syncObj?.username);
- setselectedUsername(currentUserObj[0]);
- } else {
- setselectedUsername(null);
+ if (!selectedUsername && selectedProject) {
+ logger.debug('EditorSync.js', 'In useEffect - get meta, SyncUsersList , lastSyncUser/{}');
+ await getProjectMeta(selectedProject);
+ const syncUsers = await getGiteaUsersList();
+ setUsersList(syncUsers);
+ if (currentProjectMeta) {
+ const syncObj = await getOrPutLastSyncInAgSettings('get', currentProjectMeta);
+ if (syncObj && syncUsers) {
+ const currentUserObj = syncUsers?.filter((element) => element.username === syncObj?.username);
+ setselectedUsername(currentUserObj[0]);
+ } else {
+ setselectedUsername(null);
+ }
}
}
- }
- })();
- }
+ })();
+ }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen]);
return (
<>
{syncProgress.syncStarted ?
- : (
+ : (
// eslint-disable-next-line react/jsx-no-useless-fragment
- <>
- {syncProgress?.uploadDone ? (
-
- )
- : (
- setOpenPdfPopup(true)}
- className={`group ${menuStyles.btn}
- transition-all duration-[${syncProgress?.uploadDone ? '0ms' : '2000ms' }]${
- syncProgress?.uploadDone ? 'opacity-0' : 'opacity-100'}`}
- >
-
+ {syncProgress?.uploadDone ? (
+
-
- )}
- >
- )}
+ )
+ : (
+ setOpenPdfPopup(true)}
+ className={`group ${menuStyles.btn}
+ transition-all duration-[${syncProgress?.uploadDone ? '0ms' : '2000ms' }]${
+ syncProgress?.uploadDone ? 'opacity-0' : 'opacity-100'}`}
+ >
+
+
+ )}
+ >
+ )}
{ usersList?.length !== 0
&& (
-
- Select door43 username
-
- )}
+
+ Select door43 username
+
+ )}
- ) : (
- <>
- { usersList?.length !== 0
+ ) : (
+ <>
+ { usersList?.length !== 0
&& (
-
-
-
- {selectedUsername?.username ? selectedUsername?.username : 'choose..'}
-
-
-
-
-
-
- {usersList?.map((user, userIdx) => (
- `relative cursor-default select-none py-2 pl-10 pr-4 ${
- active ? 'bg-amber-100 text-amber-900' : 'text-gray-900'}`}
- value={user}
- >
- {({ selected }) => (
- <>
-
- {user.username}
-
- {selected ? (
-
-
+
+
+
+ {selectedUsername?.username ? selectedUsername?.username : 'choose..'}
+
+
+
+
+
+
+ {usersList?.map((user, userIdx) => (
+ `relative cursor-default select-none py-2 pl-10 pr-4 ${
+ active ? 'bg-amber-100 text-amber-900' : 'text-gray-900'}`}
+ value={user}
+ >
+ {({ selected }) => (
+ <>
+
+ {user.username}
- ) : null}
- >
- )}
-
- ))}
-
-
-
-
- )}
+ {selected ? (
+
+
+
+ ) : null}
+ >
+ )}
+
+ ))}
+
+
+
+
+ )}
- { usersList?.length !== 0
- ? (
-
-
- Unable to find username? Please login
- {' '}
-
- sync
-
+ { usersList?.length !== 0
+ ? (
+
+
+ Unable to find username? Please login
+ {' '}
+
+ sync
+
+
+
+ ) : (
+
+
+ Sorry, No account found for you..
+
+ please login to start syncing project
-
- ) : (
-
-
- Sorry, No account found for you..
-
- please login to start syncing project
-
-
-
- )}
- >
- )}
+
+
+ )}
+ >
+ )}
{/* ------------------------------------ */}
diff --git a/renderer/src/components/Sync/Gitea/Gitea.js b/renderer/src/components/Sync/Gitea/Gitea.js
index 2f6b58399..6b8aabdbd 100644
--- a/renderer/src/components/Sync/Gitea/Gitea.js
+++ b/renderer/src/components/Sync/Gitea/Gitea.js
@@ -9,7 +9,7 @@ import { environment } from '../../../../environment';
import { createSyncProfile } from '../Scribe/SyncToGiteaUtils';
const Gitea = ({
- setAuth, setRepo, logout, setLogout,
+ setAuth, setRepo, logout, setLogout,
}) => {
const [authentication, setAuthentication] = useState();
const [repository, setRepository] = useState();
diff --git a/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js b/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js
index a8aa7c69d..977d0cb6f 100644
--- a/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js
+++ b/renderer/src/components/Sync/Gitea/GiteaFileBrowser.js
@@ -16,8 +16,8 @@ import { environment } from '../../../../environment';
const GiteaFileBrowser = ({ changeRepo }) => {
const {
states: {
- selectedGiteaProject, syncProgress, refreshGiteaListUI, selectedGiteaProjectBranch,
-},
+ selectedGiteaProject, syncProgress, refreshGiteaListUI, selectedGiteaProjectBranch,
+ },
action: {
setSelectedGiteaProject, setSelectedGiteaProjectBranch,
},
@@ -89,8 +89,8 @@ const GiteaFileBrowser = ({ changeRepo }) => {
// regex is for old sync
// const regex = /.+\/\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]).1$/;
let finalBranches = [];
- // eslint-disable-next-line no-console
- console.log('chedk : ', fetchBranches.some((branch) => branch.name === 'scribe-main'));
+ // eslint-disable-next-line no-console
+ console.log('chedk : ', fetchBranches.some((branch) => branch.name === 'scribe-main'));
if (fetchBranches.some((branch) => branch.name === 'scribe-main')) {
finalBranches.push({ name: 'scribe-main' });
} else {
@@ -122,39 +122,39 @@ const GiteaFileBrowser = ({ changeRepo }) => {
{refreshGiteaListUI.timeOut === true ?
:
{repoComponent}
}
- ))
+ ))
|| (
- <>
-
-
- {repo.owner.username}
-
- {steps.map((label, index) => (
- (steps.length - 1 === index)
- ? (
-
-
- {label.name}
-
- ) : (
-
-
- {label.name}
-
- )
- ))}
-
+ <>
+
+
+ {repo.owner.username}
+
+ {steps.map((label, index) => (
+ (steps.length - 1 === index)
+ ? (
+
+
+ {label.name}
+
+ ) : (
+
+
+ {label.name}
+
+ )
+ ))}
+
- {selectedGiteaProject?.mergeStatus && (
-
- )}
+ />
+ )}
- {/* advanced and some of the functions are for future use - current sycn is project wise and future is file wise */}
- {!advacnedOption
+ {/* advanced and some of the functions are for future use - current sycn is project wise and future is file wise */}
+ {!advacnedOption
&& (
{
/>
{pullBranchNames.length > 0 && (
-
+
)}
- )}
- >
+ )}
+ >
)
);
};
diff --git a/renderer/src/components/Sync/Gitea/ProjectMerge/MergeActions.js b/renderer/src/components/Sync/Gitea/ProjectMerge/MergeActions.js
index 3e27eef01..abd0c1a17 100644
--- a/renderer/src/components/Sync/Gitea/ProjectMerge/MergeActions.js
+++ b/renderer/src/components/Sync/Gitea/ProjectMerge/MergeActions.js
@@ -37,7 +37,7 @@ export async function tryMergeProjects(selectedGiteaProject, ignoreFilesPaths, a
const mergePayload = JSON.stringify({
Do: 'merge',
delete_branch_after_merge: false,
- });
+ });
requestOptions.body = mergePayload;
const urlMerge = `${environment.GITEA_API_ENDPOINT}/repos/${selectedGiteaProject?.repo?.owner?.username}/${selectedGiteaProject?.repo?.name}/pulls/${result.number}/merge`;
const mergeResult = await fetch(urlMerge, requestOptions);
@@ -68,7 +68,7 @@ export async function tryMergeProjects(selectedGiteaProject, ignoreFilesPaths, a
}
}
} catch (err) {
- logger.debug('MergeActions.js', `failed Merge Action ${err}`);
- throw new Error(err?.message || err);
+ logger.debug('MergeActions.js', `failed Merge Action ${err}`);
+ throw new Error(err?.message || err);
}
}
diff --git a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeConst.js b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeConst.js
index 7f5e6081b..5cd676dd8 100644
--- a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeConst.js
+++ b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeConst.js
@@ -1,26 +1,26 @@
export const mergeProgressSteps = [
- {
- label: 'Setting up project',
- description: '',
- },
- {
- label: 'Processing and Validating Project and Upstream',
- description: '',
- },
- {
- label: 'Check for Merging',
- description: '',
- },
- {
- label: 'Backing Up Project',
- description: '',
- },
- {
- label: 'Updating Scribe Project',
- description: '',
- },
- {
- label: 'Finishing Up Merge',
- description: '',
- },
- ];
+ {
+ label: 'Setting up project',
+ description: '',
+ },
+ {
+ label: 'Processing and Validating Project and Upstream',
+ description: '',
+ },
+ {
+ label: 'Check for Merging',
+ description: '',
+ },
+ {
+ label: 'Backing Up Project',
+ description: '',
+ },
+ {
+ label: 'Updating Scribe Project',
+ description: '',
+ },
+ {
+ label: 'Finishing Up Merge',
+ description: '',
+ },
+];
diff --git a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergePopUp.js b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergePopUp.js
index 7cf050127..aa8df6b3f 100644
--- a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergePopUp.js
+++ b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergePopUp.js
@@ -37,9 +37,9 @@ export default function ProjectMergePop({ selectedGiteaProject, setSelectedGitea
const callFunction = async () => {
let updateBurrito = null;
if (model.buttonName === t('btn-update')) {
- updateBurrito = true;
+ updateBurrito = true;
} else {
- updateBurrito = false;
+ updateBurrito = false;
}
// backing up project
const backupProjectName = await backupLocalProject(selectedGiteaProject, { setBackupName, setStepCount });
@@ -56,7 +56,7 @@ export default function ProjectMergePop({ selectedGiteaProject, setSelectedGitea
selectedGiteaProject.localUsername,
ignoreFilesPaths,
t,
- );
+ );
setStepCount((prevStepCount) => prevStepCount + 1);
setMergeDone(true);
}
@@ -66,11 +66,11 @@ export default function ProjectMergePop({ selectedGiteaProject, setSelectedGitea
const checkBurritoVersion = async () => {
if (burrito?.meta?.version !== selectedGiteaProject?.metaDataSB?.meta?.version) {
- setModel({
- openModel: true,
- title: t('modal-title-update-burrito'),
- confirmMessage: t('dynamic-msg-update-burrito-version', { version1: selectedGiteaProject?.metaDataSB?.meta?.version, version2: burrito?.meta?.version }),
- buttonName: t('btn-update'),
+ setModel({
+ openModel: true,
+ title: t('modal-title-update-burrito'),
+ confirmMessage: t('dynamic-msg-update-burrito-version', { version1: selectedGiteaProject?.metaDataSB?.meta?.version, version2: burrito?.meta?.version }),
+ buttonName: t('btn-update'),
});
} else {
await callFunction();
@@ -99,9 +99,9 @@ export default function ProjectMergePop({ selectedGiteaProject, setSelectedGitea
await addNotification('Sync', `Merge failed : ${err?.message || err}`, 'failure');
setMergeDone(false);
} finally {
- await deleteCreatedMergeBranch(selectedGiteaProject, { setModel, setStepCount }, environment.GITEA_API_ENDPOINT);
- setOpenSnackBar(true);
- setStepCount(0);
+ await deleteCreatedMergeBranch(selectedGiteaProject, { setModel, setStepCount }, environment.GITEA_API_ENDPOINT);
+ setOpenSnackBar(true);
+ setStepCount(0);
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -176,41 +176,41 @@ export default function ProjectMergePop({ selectedGiteaProject, setSelectedGitea
{(mergeDone || mergeError || mergeConflict) && (
-
- {t('btn-ok')}
-
- )}
- {(!mergeDone && !mergeConflict && counter > 0) && (
-
-
-
- )}
-
-
- {(mergeDone && counter > 0) && (
- <>
-
- Undo
+ {t('btn-ok')}
-
-
-
- {counter}
+ )}
+ {(!mergeDone && !mergeConflict && counter > 0) && (
+
+
-
- >
- )}
+ )}
+
+
+ {(mergeDone && counter > 0) && (
+ <>
+
+
+ Undo
+
+
+
+ >
+ )}
diff --git a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js
index cb25d7afd..0865e0928 100644
--- a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js
+++ b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js
@@ -53,16 +53,16 @@ export const deleteCreatedMergeBranch = async (selectedGiteaProject, actions, GI
};
const urlDeleteBranch = `${GITEA_BASE_API_URL}/repos/${selectedGiteaProject?.repo?.owner?.username}/${selectedGiteaProject?.repo?.name}/branches/${selectedGiteaProject.branch.name}-merge`;
fetch(urlDeleteBranch, requestOptions)
- .then((response) => response)
- .then((result) => {
- if (result.ok) {
- actions.setStepCount((prevStepCount) => prevStepCount + 1);
- logger.debug('ProjectMErgeUtils.js', 'Deleted Temp Branch Successfully');
- } else {
- throw new Error(result.statusText);
- }
- })
- .catch((error) => logger.debug('ProjectMErgeUtils.js', 'Project Temporary branch deletion Error - ', error));
+ .then((response) => response)
+ .then((result) => {
+ if (result.ok) {
+ actions.setStepCount((prevStepCount) => prevStepCount + 1);
+ logger.debug('ProjectMErgeUtils.js', 'Deleted Temp Branch Successfully');
+ } else {
+ throw new Error(result.statusText);
+ }
+ })
+ .catch((error) => logger.debug('ProjectMErgeUtils.js', 'Project Temporary branch deletion Error - ', error));
};
export const backupLocalProject = async (selectedGiteaProject, actions) => {
@@ -99,9 +99,9 @@ export const undoMergeOrDeleteOldBackup = async (selectedGiteaProject, backupNam
const backupFileList = await fs.readdirSync(projectBackupPath);
const files = backupFileList.filter((filename) => fs.statSync(`${projectBackupPath}/${filename}`).isDirectory());
const backupFileListSorted = files.sort((a, b) => {
- const aStat = fs.statSync(`${projectBackupPath}/${a}`);
- const bStat = fs.statSync(`${projectBackupPath}/${b}`);
- return new Date(bStat.birthtime).getTime() - new Date(aStat.birthtime).getTime();
+ const aStat = fs.statSync(`${projectBackupPath}/${a}`);
+ const bStat = fs.statSync(`${projectBackupPath}/${b}`);
+ return new Date(bStat.birthtime).getTime() - new Date(aStat.birthtime).getTime();
});
if (undo) {
diff --git a/renderer/src/components/Sync/Gitea/SyncFromGitea-backup.js b/renderer/src/components/Sync/Gitea/SyncFromGitea-backup.js
index 4376e621a..cce95c576 100644
--- a/renderer/src/components/Sync/Gitea/SyncFromGitea-backup.js
+++ b/renderer/src/components/Sync/Gitea/SyncFromGitea-backup.js
@@ -21,60 +21,60 @@ export async function downloadFromGitea(repo, auth, setSyncProgress, notifyStatu
logger.debug('SyncFromGitea.js', 'in SyncFromGiea : fetch content branch success');
const readMetaData = await readContent(
{
- config: auth.config,
- owner: auth.user.login,
- repo: repo.name,
- ref: foundSyncBranch?.name,
- filepath: 'metadata.json',
+ config: auth.config,
+ owner: auth.user.login,
+ repo: repo.name,
+ ref: foundSyncBranch?.name,
+ filepath: 'metadata.json',
},
);
const fetchMetaData = await fetch(readMetaData.download_url);
const metaFile = await fetchMetaData.json();
if (metaFile) {
- const sb = Buffer.from(metaFile.data);
- const metaDataSB = JSON.parse(sb);
- logger.debug('SyncFromGitea.js', 'in SyncFromGiea : fetch and parse metaData Success');
- // Validate the burrito
- const success = await validate('metadata', 'gitea/metadata.json', sb, metaDataSB.meta.version);
- // if success proceed else raise error
- if (success) {
- logger.debug('SyncFromGitea.js', 'in SyncFromGiea : metaData SB validated');
- setSyncProgress((prev) => ({
- ...prev,
- syncStarted: true,
- totalFiles: Object.keys(metaDataSB?.ingredients).length + 2,
- completedFiles: 1,
- }));
- // setProjectData
- setSelectedGiteaProject({
- repo,
- branch: foundSyncBranch,
- metaDataSB,
- localUsername: currentUser.username,
- auth,
- mergeStatus: false,
- });
- // check for project exising - true/ undefined
- const duplicate = await checkDuplicate(metaDataSB, currentUser?.username, 'projects');
- if (duplicate) {
- logger.debug('SyncFromGitea.js', 'in SyncFromGiea : project exist and merge action');
- // save all data and trigger merge
- setSelectedGiteaProject((prev) => ({ ...prev, mergeStatus: true }));
- } else {
+ const sb = Buffer.from(metaFile.data);
+ const metaDataSB = JSON.parse(sb);
+ logger.debug('SyncFromGitea.js', 'in SyncFromGiea : fetch and parse metaData Success');
+ // Validate the burrito
+ const success = await validate('metadata', 'gitea/metadata.json', sb, metaDataSB.meta.version);
+ // if success proceed else raise error
+ if (success) {
+ logger.debug('SyncFromGitea.js', 'in SyncFromGiea : metaData SB validated');
+ setSyncProgress((prev) => ({
+ ...prev,
+ syncStarted: true,
+ totalFiles: Object.keys(metaDataSB?.ingredients).length + 2,
+ completedFiles: 1,
+ }));
+ // setProjectData
+ setSelectedGiteaProject({
+ repo,
+ branch: foundSyncBranch,
+ metaDataSB,
+ localUsername: currentUser.username,
+ auth,
+ mergeStatus: false,
+ });
+ // check for project exising - true/ undefined
+ const duplicate = await checkDuplicate(metaDataSB, currentUser?.username, 'projects');
+ if (duplicate) {
+ logger.debug('SyncFromGitea.js', 'in SyncFromGiea : project exist and merge action');
+ // save all data and trigger merge
+ setSelectedGiteaProject((prev) => ({ ...prev, mergeStatus: true }));
+ } else {
// import call
- logger.debug('SyncFromGitea.js', 'in SyncFromGiea : new project and import called');
- await importServerProject(false, repo, metaDataSB, auth, foundSyncBranch, { setSyncProgress, notifyStatus }, currentUser.username);
- await notifyStatus('success', 'Project Sync to scribe successfull');
- await addNotification('Sync', 'Project Sync Successfull', 'success');
+ logger.debug('SyncFromGitea.js', 'in SyncFromGiea : new project and import called');
+ await importServerProject(false, repo, metaDataSB, auth, foundSyncBranch, { setSyncProgress, notifyStatus }, currentUser.username);
+ await notifyStatus('success', 'Project Sync to scribe successfull');
+ await addNotification('Sync', 'Project Sync Successfull', 'success');
+ }
+ } else {
+ logger.debug('SyncFromGitea.js', 'Burrito Validation Failed');
+ throw new Error('Burrito Validation Failed');
}
- } else {
- logger.debug('SyncFromGitea.js', 'Burrito Validation Failed');
- throw new Error('Burrito Validation Failed');
- }
} else { throw new Error('Failed to read MetaData'); }
} else {
- logger.debug('SyncFromGitea.js', 'Invalid Project , No Valid Branch');
- throw new Error('Invalid Project, No Valid Branch');
+ logger.debug('SyncFromGitea.js', 'Invalid Project , No Valid Branch');
+ throw new Error('Invalid Project, No Valid Branch');
}
} else { throw new Error('branch not found'); }
} catch (err) {
@@ -86,9 +86,9 @@ export async function downloadFromGitea(repo, auth, setSyncProgress, notifyStatu
await addNotification('Sync', err?.message || err, 'failure');
} finally {
setSyncProgress({
- syncStarted: false,
- totalFiles: 0,
- completedFiles: 0,
+ syncStarted: false,
+ totalFiles: 0,
+ completedFiles: 0,
});
}
}
diff --git a/renderer/src/components/Sync/Gitea/SyncFromGitea.js b/renderer/src/components/Sync/Gitea/SyncFromGitea.js
index f2ccb2ad3..ccea72bb2 100644
--- a/renderer/src/components/Sync/Gitea/SyncFromGitea.js
+++ b/renderer/src/components/Sync/Gitea/SyncFromGitea.js
@@ -21,11 +21,11 @@ export async function downloadFromGitea(repo, auth, setSyncProgress, notifyStatu
}));
const readMetaData = await readContent(
{
- config: auth.config,
- owner: repo.owner.username,
- repo: repo.name,
- ref: branch,
- filepath: 'metadata.json',
+ config: auth.config,
+ owner: repo.owner.username,
+ repo: repo.name,
+ ref: branch,
+ filepath: 'metadata.json',
},
);
const fetchMetaData = await fetch(readMetaData.download_url);
@@ -79,10 +79,10 @@ export async function downloadFromGitea(repo, auth, setSyncProgress, notifyStatu
await addNotification('Sync', `${err?.message || err} unable to find Burrito File`, 'failure');
} finally {
setSyncProgress({
- syncStarted: false,
- syncType: null,
- totalFiles: 0,
- completedFiles: 0,
+ syncStarted: false,
+ syncType: null,
+ totalFiles: 0,
+ completedFiles: 0,
});
}
}
diff --git a/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js b/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js
index 8b6b1efce..20841bfe6 100644
--- a/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js
+++ b/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js
@@ -7,8 +7,8 @@ import { environment } from '../../../../environment';
import packageInfo from '../../../../../package.json';
import {
checkGitStatus,
- checkoutJsonFiles,
- checkoutToBranch, cloneTheProject, createBranch, createGitIgnore, getRepoOwner, pullProject, setUserConfig,
+ checkoutJsonFiles,
+ checkoutToBranch, cloneTheProject, createBranch, createGitIgnore, getRepoOwner, pullProject, setUserConfig,
} from '../Isomorphic/utils';
import { createRemoteBranch } from '../Isomorphic/api';
@@ -146,8 +146,8 @@ export const updateSettingsFiles = async (fs, sbDataObject1, projectDir, project
}
// burrito update
if (updateBurrito) {
- logger.debug('importBurrito.js', 'Updating the burrito version');
- sbDataObject = await updateVersion(sbDataObject);
+ logger.debug('importBurrito.js', 'Updating the burrito version');
+ sbDataObject = await updateVersion(sbDataObject);
}
await fs.writeFileSync(path.join(projectDir, `${projectName}_${id}`, 'metadata.json'), JSON.stringify(sbDataObject));
logger.debug('importBurrito.js', 'Creating the metadata.json Burrito file.');
@@ -204,32 +204,32 @@ export const importServerProject = async (updateBurrito, repo, sbData, auth, use
// getting unique project ID
if (sbDataObject?.identification?.primary?.scribe !== undefined) {
Object.entries(sbDataObject.identification?.primary?.scribe).forEach(([key]) => {
- logger.debug('SyncFromGiteaUtils.js', 'Fetching the key from burrito.');
- id = key;
+ logger.debug('SyncFromGiteaUtils.js', 'Fetching the key from burrito.');
+ id = key;
});
} else if (sbDataObject?.identification?.upstream?.scribe !== undefined) {
Object.entries(sbDataObject.identification.primary).forEach(([key]) => {
- logger.debug('SyncFromGiteaUtils.js', 'Swapping data between primary and upstream');
- const identity = sbDataObject.identification.primary[key];
- sbDataObject.identification.upstream[key] = [identity];
- delete sbDataObject.identification.primary[key];
- delete sbDataObject.idAuthorities;
+ logger.debug('SyncFromGiteaUtils.js', 'Swapping data between primary and upstream');
+ const identity = sbDataObject.identification.primary[key];
+ sbDataObject.identification.upstream[key] = [identity];
+ delete sbDataObject.identification.primary[key];
+ delete sbDataObject.idAuthorities;
});
sbDataObject.idAuthorities = {
- scribe: {
+ scribe: {
id: 'http://www.scribe.bible',
name: {
- en: 'Scribe application',
+ en: 'Scribe application',
},
- },
+ },
};
const list = sbDataObject.identification?.upstream?.scribe;
logger.debug('SyncFromGiteaUtils.js', 'Fetching the latest key from list.');
// eslint-disable-next-line max-len
const latest = list.reduce((a, b) => (new Date(a.timestamp) > new Date(b.timestamp) ? a : b));
Object.entries(latest).forEach(([key]) => {
- logger.debug('SyncFromGiteaUtils.js', 'Fetching the latest key from burrito.');
- id = key;
+ logger.debug('SyncFromGiteaUtils.js', 'Fetching the latest key from burrito.');
+ id = key;
});
if (list.length > 1) {
(sbDataObject.identification.upstream.scribe).forEach((e, i) => {
@@ -245,13 +245,13 @@ export const importServerProject = async (updateBurrito, repo, sbData, auth, use
// if Id is undefined - trying to get id, if project already exist
const folderList = await fs.readdirSync(projectDir);
await checkImportDuplicate(folderList, projectName, sbDataObject, projectDir, fs)
- .then((upstreamValue) => {
+ .then((upstreamValue) => {
// The ID of the existing project, using it for over wriitting it.
- if (upstreamValue.primaryId) {
- id = upstreamValue.primaryId;
- foundId = true;
- }
- });
+ if (upstreamValue.primaryId) {
+ id = upstreamValue.primaryId;
+ foundId = true;
+ }
+ });
}
// generating unique key if not exist or get
@@ -272,8 +272,8 @@ export const importServerProject = async (updateBurrito, repo, sbData, auth, use
}
sbDataObject.identification.primary.scribe = {
[id]: {
- revision: '0',
- timestamp: moment().format(),
+ revision: '0',
+ timestamp: moment().format(),
},
};
}
@@ -351,15 +351,15 @@ export const importServerProject = async (updateBurrito, repo, sbData, auth, use
}));
return false;
}
- action.setSyncProgress((prev) => ({
- ...prev,
- completedFiles: prev.completedFiles + 1,
- }));
- const checkoutFIles = await checkoutJsonFiles(fs, gitprojectDir, checkoutBranch);
- const pullStatus = checkoutFIles && await pullProject(fs, gitprojectDir, userBranch, auth.token.sha1, checkoutBranch);
- if (!pullStatus?.status) {
- // show warning again to overwrite
- const conflictHtmlText = `
+ action.setSyncProgress((prev) => ({
+ ...prev,
+ completedFiles: prev.completedFiles + 1,
+ }));
+ const checkoutFIles = await checkoutJsonFiles(fs, gitprojectDir, checkoutBranch);
+ const pullStatus = checkoutFIles && await pullProject(fs, gitprojectDir, userBranch, auth.token.sha1, checkoutBranch);
+ if (!pullStatus?.status) {
+ // show warning again to overwrite
+ const conflictHtmlText = `
You have conflict in ${pullStatus?.data?.data ? pullStatus?.data?.data : 'some files'}.
Connect your administrator to resolve this conflcit.
@@ -371,15 +371,15 @@ export const importServerProject = async (updateBurrito, repo, sbData, auth, use
which will overwrite all unsynced changes with the data of Door43.
`;
- setPullPopup({
- title: 'Conflict',
- status: true,
- confirmMessage: conflictHtmlText,
- buttonName: 'over-write',
- // type: 'overwrite',
- });
- }
- fetchedRepo = pullStatus?.status;
+ setPullPopup({
+ title: 'Conflict',
+ status: true,
+ confirmMessage: conflictHtmlText,
+ buttonName: 'over-write',
+ // type: 'overwrite',
+ });
+ }
+ fetchedRepo = pullStatus?.status;
} else {
const checkoutStatus = await cloneAndSetProject(fs, gitprojectDir, repo, userBranch, auth, checkoutBranch);
fetchedRepo = checkoutStatus;
diff --git a/renderer/src/components/Sync/GridRow.jsx b/renderer/src/components/Sync/GridRow.jsx
index 1d3c36bd4..c13cf3000 100644
--- a/renderer/src/components/Sync/GridRow.jsx
+++ b/renderer/src/components/Sync/GridRow.jsx
@@ -34,10 +34,10 @@ function GridRow({
>
{lastSync && lastSync !== null
? moment
- .utc(lastSync.lastSynced)
- .local()
- .startOf('seconds')
- .fromNow()
+ .utc(lastSync.lastSynced)
+ .local()
+ .startOf('seconds')
+ .fromNow()
: '-'}
diff --git a/renderer/src/components/Sync/Isomorphic/utils.js b/renderer/src/components/Sync/Isomorphic/utils.js
index 6c06c9f80..111518dcf 100644
--- a/renderer/src/components/Sync/Isomorphic/utils.js
+++ b/renderer/src/components/Sync/Isomorphic/utils.js
@@ -325,7 +325,7 @@ export async function pullProject(fs, dir, remoteBranch, token, localBranch) {
status.data = {
type: 'conflict',
data: e?.data?.filepaths,
- };
+ };
return status;
});
logger.debug('utils.js', 'Pulled the project');
diff --git a/renderer/src/components/Sync/PopUpModal.jsx b/renderer/src/components/Sync/PopUpModal.jsx
index a5347fa1c..a622fb64c 100644
--- a/renderer/src/components/Sync/PopUpModal.jsx
+++ b/renderer/src/components/Sync/PopUpModal.jsx
@@ -3,7 +3,7 @@ import { Dialog, Transition } from '@headlessui/react';
import PropTypes from 'prop-types';
export default function PopUpModal({
- isOpen, closeFunc, head, children,
+ isOpen, closeFunc, head, children,
}) {
return (
diff --git a/renderer/src/components/Sync/Scribe/ProjectFileBrowser.js b/renderer/src/components/Sync/Scribe/ProjectFileBrowser.js
index 6f87b3cbd..8134c4a24 100644
--- a/renderer/src/components/Sync/Scribe/ProjectFileBrowser.js
+++ b/renderer/src/components/Sync/Scribe/ProjectFileBrowser.js
@@ -1,5 +1,5 @@
import {
- useContext, useEffect,
+ useContext, useEffect,
} from 'react';
import GridRow from '../GridRow';
import { SyncContext } from '../../context/SyncContext';
@@ -7,8 +7,8 @@ import { SyncContext } from '../../context/SyncContext';
export default function ProjectFileBrowser() {
const {
states: {
- agProjects, agProjectsMeta, selectedAgProject, syncProgress,
- },
+ agProjects, agProjectsMeta, selectedAgProject, syncProgress,
+ },
action: {
fetchProjects, setSelectedAgProject,
},
@@ -58,5 +58,5 @@ export default function ProjectFileBrowser() {
)
))
-);
+ );
}
diff --git a/renderer/src/components/Sync/Scribe/SyncToGitea.js b/renderer/src/components/Sync/Scribe/SyncToGitea.js
index 6a89e1cc1..3acc70bdb 100644
--- a/renderer/src/components/Sync/Scribe/SyncToGitea.js
+++ b/renderer/src/components/Sync/Scribe/SyncToGitea.js
@@ -2,7 +2,7 @@ import * as localForage from 'localforage';
import * as logger from '../../../logger';
import packageInfo from '../../../../../package.json';
import {
- addGitRemote, checkInitialize, checkoutJsonFiles, checkoutToBranch, commitChanges, createBranch, getRepoOwner, initProject, pullProject, pushTheChanges, pushToMain,
+ addGitRemote, checkInitialize, checkoutJsonFiles, checkoutToBranch, commitChanges, createBranch, getRepoOwner, initProject, pullProject, pushTheChanges, pushToMain,
} from '../Isomorphic/utils';
import { createRepo, getRepoByOwner } from '../Isomorphic/api';
import { getOrPutLastSyncInAgSettings } from './SyncToGiteaUtils';
@@ -35,7 +35,7 @@ export async function uploadToGitea(projectDataAg, auth, setSyncProgress, notify
if (!checkInit || !checkForRepo?.id) {
setSyncProgress((prev) => ({
- ...prev, syncStarted: true, syncType: 'syncTo', completedFiles: 1, totalFiles: 6,
+ ...prev, syncStarted: true, syncType: 'syncTo', completedFiles: 1, totalFiles: 6,
}));
let projectInitialized;
if (!checkInit) {
@@ -62,7 +62,7 @@ export async function uploadToGitea(projectDataAg, auth, setSyncProgress, notify
}
} else {
setSyncProgress((prev) => ({
- ...prev, syncStarted: true, syncType: 'syncTo', completedFiles: 1, totalFiles: 3,
+ ...prev, syncStarted: true, syncType: 'syncTo', completedFiles: 1, totalFiles: 3,
}));
// const repoOwner = await getRepoOwner(fs, projectsMetaPath);
const commitStatus = await commitChanges(fs, projectsMetaPath, { email: auth.user.email, username: auth.user.username }, 'Added from scribe');
@@ -122,7 +122,7 @@ export async function uploadToGitea(projectDataAg, auth, setSyncProgress, notify
} finally {
setSyncProgress((prev) => ({
...prev, syncStarted: false, syncType: null, completedFiles: 0, totalFiles: 0,
- }));
+ }));
}
});
}
diff --git a/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js b/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js
index 98f635e38..b7f659138 100644
--- a/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js
+++ b/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js
@@ -1,6 +1,6 @@
import {
- readContent, createRepository, createContent, updateContent,
- } from 'gitea-react-toolkit';
+ readContent, createRepository, createContent, updateContent,
+} from 'gitea-react-toolkit';
import moment from 'moment';
import * as localForage from 'localforage';
import * as logger from '../../../logger';
@@ -9,50 +9,50 @@ import { environment } from '../../../../environment';
// create repo for new project sync
export const handleCreateRepo = async (repoName, auth, description) => {
- const settings = {
- name: repoName,
- description: description || `${repoName}`,
- private: false,
- };
+ const settings = {
+ name: repoName,
+ description: description || `${repoName}`,
+ private: false,
+ };
// eslint-disable-next-line no-async-promise-executor
- return new Promise(async (resolve) => {
- createRepository(
- {
- config: auth.config,
- repo: settings?.name,
- settings,
- },
- ).then((result) => {
- logger.debug('Dropzone.js', 'call to create repo from Gitea');
- resolve(result);
- }).catch((err) => {
- logger.debug('Dropzone.js', 'call to create repo from Gitea Error : ', err);
- resolve(err);
- });
+ return new Promise(async (resolve) => {
+ createRepository(
+ {
+ config: auth.config,
+ repo: settings?.name,
+ settings,
+ },
+ ).then((result) => {
+ logger.debug('Dropzone.js', 'call to create repo from Gitea');
+ resolve(result);
+ }).catch((err) => {
+ logger.debug('Dropzone.js', 'call to create repo from Gitea Error : ', err);
+ resolve(err);
});
- };
+ });
+};
// upload file to gitea
export const createFiletoServer = async (fileContent, filePath, branch, repoName, auth) => {
- try {
- await createContent({
- config: auth.config,
- owner: auth.user.login,
- // repo: repo.name,
- repo: repoName,
- branch: branch.replace(/ /g, '_'), // removing space to avoid error
- filepath: filePath,
- content: fileContent,
- message: `commit ${filePath}`,
- author: {
- email: auth.user.email,
- username: auth.user.username,
- },
- });
- } catch (err) {
- throw new Error(err?.message || err);
- }
- };
+ try {
+ await createContent({
+ config: auth.config,
+ owner: auth.user.login,
+ // repo: repo.name,
+ repo: repoName,
+ branch: branch.replace(/ /g, '_'), // removing space to avoid error
+ filepath: filePath,
+ content: fileContent,
+ message: `commit ${filePath}`,
+ author: {
+ email: auth.user.email,
+ username: auth.user.username,
+ },
+ });
+ } catch (err) {
+ throw new Error(err?.message || err);
+ }
+};
// update file in gitea
export const updateFiletoServer = async (fileContent, filePath, branch, repoName, auth) => {
@@ -65,26 +65,26 @@ export const updateFiletoServer = async (fileContent, filePath, branch, repoName
ref: branch.replace(/ /g, '_'),
filepath: filePath,
},
- );
- if (readResult === null) {
- throw new Error('can not read repo');
- } else {
- await updateContent({
- config: auth.config,
- owner: auth.user.login,
- repo: repoName.toLowerCase(),
- branch: branch.replace(/ /g, '_'),
- filepath: readResult.path,
- content: fileContent,
- message: `updated ${filePath}`,
- author: {
- email: auth.user.email,
- username: auth.user.username,
- },
- sha: readResult.sha,
- // eslint-disable-next-line no-unused-vars
- });
- }
+ );
+ if (readResult === null) {
+ throw new Error('can not read repo');
+ } else {
+ await updateContent({
+ config: auth.config,
+ owner: auth.user.login,
+ repo: repoName.toLowerCase(),
+ branch: branch.replace(/ /g, '_'),
+ filepath: readResult.path,
+ content: fileContent,
+ message: `updated ${filePath}`,
+ author: {
+ email: auth.user.email,
+ username: auth.user.username,
+ },
+ sha: readResult.sha,
+ // eslint-disable-next-line no-unused-vars
+ });
+ }
} catch (err) {
throw new Error(err?.message || err);
}
@@ -103,25 +103,25 @@ export const createSyncProfile = async (auth) => {
if (err) {
logger.error('SyncToGiteaUtils.js', 'Failed to read the data from file');
} else {
- logger.debug('SyncToGiteaUtils.js', 'Successfully read the data from file');
- const json = JSON.parse(data);
- if (!json.sync && !json.sync?.services) {
+ logger.debug('SyncToGiteaUtils.js', 'Successfully read the data from file');
+ const json = JSON.parse(data);
+ if (!json.sync && !json.sync?.services) {
// first time sync
- json.sync = {
- services: {
- door43: [
- {
- token: '',
- expired: false,
- default: false,
- username: auth?.user?.username,
- dateCreated: moment().format(),
- dateModified: null,
- },
- ],
- },
- };
- } else if (!json.sync?.services?.door43?.some((element) => element.username === auth?.user?.username)) {
+ json.sync = {
+ services: {
+ door43: [
+ {
+ token: '',
+ expired: false,
+ default: false,
+ username: auth?.user?.username,
+ dateCreated: moment().format(),
+ dateModified: null,
+ },
+ ],
+ },
+ };
+ } else if (!json.sync?.services?.door43?.some((element) => element.username === auth?.user?.username)) {
// user not in list create new entry
json.sync?.services?.door43?.push(
{
@@ -134,9 +134,9 @@ export const createSyncProfile = async (auth) => {
},
);
}
- // add token to file on login - used in editor sync
- // eslint-disable-next-line array-callback-return
- json.sync?.services?.door43?.filter((element) => {
+ // add token to file on login - used in editor sync
+ // eslint-disable-next-line array-callback-return
+ json.sync?.services?.door43?.filter((element) => {
if (element.username === auth?.user?.username) {
element.expired = false;
element.dateModified = moment().format();
@@ -152,9 +152,9 @@ export const createSyncProfile = async (auth) => {
};
}
});
- logger.debug('GiteaFileBrowser.js', 'Upadting the settings in existing file');
- await fs.writeFileSync(file, JSON.stringify(json));
- }
+ logger.debug('GiteaFileBrowser.js', 'Upadting the settings in existing file');
+ await fs.writeFileSync(file, JSON.stringify(json));
+ }
});
}
});
@@ -187,8 +187,8 @@ export const getOrPutLastSyncInAgSettings = async (method, projectMeta, syncUser
if (indx === 0) {
lastSyncedObj = element;
} else if (element.lastSynced > lastSyncedObj.lastSynced) {
- lastSyncedObj = element;
- }
+ lastSyncedObj = element;
+ }
});
return lastSyncedObj;
}
@@ -217,19 +217,19 @@ export const getOrPutLastSyncInAgSettings = async (method, projectMeta, syncUser
);
} else {
// eslint-disable-next-line array-callback-return
- settings.sync?.services?.door43?.forEach((element) => {
- if (element?.username === syncUsername) {
- element.lastSynced = moment().format();
- } else {
- settings.sync.services.door43.push(
- {
- username: syncUsername,
- dateCreated: moment().format(),
- lastSynced: moment().format(),
- },
- );
- }
- });
+ settings.sync?.services?.door43?.forEach((element) => {
+ if (element?.username === syncUsername) {
+ element.lastSynced = moment().format();
+ } else {
+ settings.sync.services.door43.push(
+ {
+ username: syncUsername,
+ dateCreated: moment().format(),
+ lastSynced: moment().format(),
+ },
+ );
+ }
+ });
}
logger.debug('SyncToGiteaUtils.js', 'Upadting the scribe settings with sync data');
diff --git a/renderer/src/components/Sync/Sync.js b/renderer/src/components/Sync/Sync.js
index 4b1385f6f..fda12da0e 100644
--- a/renderer/src/components/Sync/Sync.js
+++ b/renderer/src/components/Sync/Sync.js
@@ -81,7 +81,7 @@ export default function Sync() {
// for pull without conflict
const checkoutFIles = await checkoutJsonFiles(pullData.fs, pullData.gitprojectDir, pullData.checkoutBranch);
const pullStatus = checkoutFIles && await pullProject(pullData.fs, pullData.gitprojectDir, pullData.userBranch, auth.token.sha1, pullData.checkoutBranch);
- pullStatus?.status && await updateSettingsFiles(
+ pullStatus?.status && await updateSettingsFiles(
pullData.fs,
pullData.sbDataObject,
pullData.projectDir,
@@ -105,30 +105,30 @@ export default function Sync() {
// throw new Error(`Remove Resource failed : ${err}`);
// clone = false;
} else {
- // call clone
- const cloneStatus = await cloneAndSetProject(
- pullData.fs,
- pullData.gitprojectDir,
- pullData.repo,
- pullData.userBranch,
- pullData.auth,
- pullData.checkoutBranch,
- );
+ // call clone
+ const cloneStatus = await cloneAndSetProject(
+ pullData.fs,
+ pullData.gitprojectDir,
+ pullData.repo,
+ pullData.userBranch,
+ pullData.auth,
+ pullData.checkoutBranch,
+ );
// continue settings file writing
- cloneStatus && await updateSettingsFiles(
- pullData.fs,
- pullData.sbDataObject,
- pullData.projectDir,
- pullData.projectName,
- pullData.id,
- pullData.currentUser,
- pullData.updateBurrito,
- pullData.action,
- );
- logger.debug('Sync.js', 'Project Sync to scribe successfull, clone successfull');
- await notifyStatus('success', 'Project Sync to scribe successfull');
- await addNotification('Sync', 'Project Sync Successfull', 'success');
- }
+ cloneStatus && await updateSettingsFiles(
+ pullData.fs,
+ pullData.sbDataObject,
+ pullData.projectDir,
+ pullData.projectName,
+ pullData.id,
+ pullData.currentUser,
+ pullData.updateBurrito,
+ pullData.action,
+ );
+ logger.debug('Sync.js', 'Project Sync to scribe successfull, clone successfull');
+ await notifyStatus('success', 'Project Sync to scribe successfull');
+ await addNotification('Sync', 'Project Sync Successfull', 'success');
+ }
});
} else {
// call clone
@@ -157,7 +157,7 @@ export default function Sync() {
}
}
} else {
- logger.debug('Sync.js', 'error pullData not set from function');
+ logger.debug('Sync.js', 'error pullData not set from function');
}
};
diff --git a/renderer/src/components/Sync/VerticalStepperProgress.js b/renderer/src/components/Sync/VerticalStepperProgress.js
index b585c62ea..ab241bf03 100644
--- a/renderer/src/components/Sync/VerticalStepperProgress.js
+++ b/renderer/src/components/Sync/VerticalStepperProgress.js
@@ -2,27 +2,27 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import { CheckIcon } from '@heroicons/react/24/outline';
import {
- Box, Paper, Step, StepContent, StepLabel, Stepper, Typography,
+ Box, Paper, Step, StepContent, StepLabel, Stepper, Typography,
} from '@material-ui/core';
export function VerticalLinearStepper({ stepCount, steps, successMsg }) {
- const [activeStep, setActiveStep] = React.useState(0);
+ const [activeStep, setActiveStep] = React.useState(0);
- React.useEffect(() => {
- setActiveStep((prevActiveStep) => prevActiveStep + 1);
- }, [stepCount]);
+ React.useEffect(() => {
+ setActiveStep((prevActiveStep) => prevActiveStep + 1);
+ }, [stepCount]);
- const handleReset = () => {
- setActiveStep(0);
- };
+ const handleReset = () => {
+ setActiveStep(0);
+ };
- // const handleNext = () => {
- // setActiveStep((prevActiveStep) => prevActiveStep + 1);
- // };
+ // const handleNext = () => {
+ // setActiveStep((prevActiveStep) => prevActiveStep + 1);
+ // };
- React.useEffect(() => {
- handleReset();
- }, []);
+ React.useEffect(() => {
+ handleReset();
+ }, []);
return (