Skip to content

Commit

Permalink
Refactoring Sync by structuring the files
Browse files Browse the repository at this point in the history
  • Loading branch information
vipinpaul committed Oct 12, 2023
1 parent cbc0650 commit f5a8441
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 61 deletions.
2 changes: 1 addition & 1 deletion renderer/pages/sync.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Sync from '@/components/Sync/Sync';
import AuthenticationContextProvider from '@/components/Login/AuthenticationContextProvider';
import AutographaContextProvider from '@/components/context/AutographaContext';
import SyncContextProvider from '@/components/Sync/SyncContextProvider';
import SyncContextProvider from '@/components/context/SyncContext';

const projects = () => (
<AuthenticationContextProvider>
Expand Down
1 change: 1 addition & 0 deletions renderer/src/components/LoadingSpinner/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as LoadingSpinner } from './LoadingSpinner';
1 change: 1 addition & 0 deletions renderer/src/components/ProgressCircle/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ProgressCircle } from './ProgressCircle';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import PopUpModal from '../../PopUpModal';
import * as logger from '../../../../logger';
import CloudUploadIcon from '@/icons/basil/Outline/Files/Cloud-upload.svg';
import CloudCheckIcon from '@/icons/basil/Solid/Files/Cloud-check.svg';
import ProgressCircle from '../../ProgressCircle';
import { ProgressCircle } from '../../../ProgressCircle';
import Door43Logo from '@/icons/door43.svg';
import { getGiteaUsersList, handleEditorSync } from './EditorSyncUtils';
import useGetCurrentProjectMeta from '../../hooks/useGetCurrentProjectMeta';
Expand Down
6 changes: 2 additions & 4 deletions renderer/src/components/Sync/Gitea/GiteaFileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import {
} from 'gitea-react-toolkit';
import { ChevronRightIcon } from '@heroicons/react/24/solid';
import CustomMultiComboBox from '@/components/Resources/ResourceUtils/CustomMultiComboBox';
import { SyncContext } from '../SyncContextProvider';
import { SyncContext } from '../../context/SyncContext';
import * as logger from '../../../logger';
import LoadingSpinner from '../LoadingSpinner';
import { LoadingSpinner } from '../../LoadingSpinner';
import GridRow from '../GridRow';
import ProjectMergePop from './ProjectMerge/ProjectMergePopUp';
import { environment } from '../../../../environment';

/* eslint-disable no-console */
// eslint-disable-next-line react/prop-types
const GiteaFileBrowser = ({ changeRepo }) => {
const {
states: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useAddNotification from '@/components/hooks/useAddNotification';
import PopUpModal from '../../PopUpModal';
import { VerticalLinearStepper } from '../../VerticalStepperProgress';
import { mergeProgressSteps } from './ProjectMergeConst';
import LoadingSpinner from '../../LoadingSpinner';
import { LoadingSpinner } from '../../../LoadingSpinner';
import { tryMergeProjects } from './MergeActions';
import burrito from '../../../../lib/BurritoTemplete.json';
import { backupLocalProject, deleteCreatedMergeBranch, undoMergeOrDeleteOldBackup } from './ProjectMergeUtils';
Expand Down
47 changes: 0 additions & 47 deletions renderer/src/components/Sync/GridRow.js

This file was deleted.

56 changes: 56 additions & 0 deletions renderer/src/components/Sync/GridRow.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';
import { classNames } from '@/util/classNames';
import moment from 'moment';
import FolderIcon from '@/icons/folder.svg';

function GridRow({
title,
lastSync,
selected,
isUpload,
uploadPercentage = 0,
}) {
return (
<>
<div className="flex gap-2 justify-between items-center px-5 py-4 border-b border-gray-100 cursor-pointer">
<span
className={classNames(
selected ? 'text-primary' : 'text-gray-800',
'capitalize w-full flex items-center gap-5',
)}
>
<FolderIcon className="w-4 h-4" />
{title}
</span>

<span
title={
lastSync && lastSync !== null ? lastSync.username : ''
}
className={classNames(
selected ? 'text-primary' : '',
'text-xs font-semibold text-right w-40',
)}
>
{lastSync && lastSync !== null
? moment
.utc(lastSync.lastSynced)
.local()
.startOf('seconds')
.fromNow()
: '-'}
</span>
</div>
{isUpload && (
<div className="w-full bg-gray-200 h-1">
<div
className="bg-primary h-1"
style={{ width: `${uploadPercentage}%` }}
/>
</div>
)}
</>
);
}

export default GridRow;
File renamed without changes.
2 changes: 1 addition & 1 deletion renderer/src/components/Sync/Scribe/ProjectFileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
useContext, useEffect,
} from 'react';
import GridRow from '../GridRow';
import { SyncContext } from '../SyncContextProvider';
import { SyncContext } from '../../context/SyncContext';

export default function ProjectFileBrowser() {
const {
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/Sync/Sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { SnackBar } from '@/components/SnackBar';
import useAddNotification from '@/components/hooks/useAddNotification';
import ConfirmationModal from '@/layouts/editor/ConfirmationModal';
import { SyncContext } from './SyncContextProvider';
import { SyncContext } from '../context/SyncContext';
import { uploadToGitea } from './Scribe/SyncToGitea';
import { downloadFromGitea } from './Gitea/SyncFromGitea';
import { cloneAndSetProject, updateSettingsFiles } from './Gitea/SyncFromGiteaUtils';
Expand Down
3 changes: 0 additions & 3 deletions renderer/src/components/Sync/supportForExistingSyncUsers.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/jsx-no-constructed-context-values */
import React, { createContext } from 'react';
import PropTypes from 'prop-types';
import useSync from './hooks/useSync';
import useSync from '../Sync/hooks/useSync';

export const SyncContext = createContext();

Expand Down
2 changes: 1 addition & 1 deletion renderer/src/layouts/projects/Export/ExportProjectPopUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { validate } from '../../../util/validate';
import * as logger from '../../../logger';
import burrito from '../../../lib/BurritoTemplete.json';
import ConfirmationModal from '../../editor/ConfirmationModal';
import ProgressCircle from '../../../components/Sync/ProgressCircle';
import { ProgressCircle } from '../../../components/ProgressCircle';
import { exportDefaultAudio, exportFullAudio } from './ExportUtils';
import packageInfo from '../../../../../package.json';

Expand Down

0 comments on commit f5a8441

Please sign in to comment.