Skip to content

Commit

Permalink
Setup of Project management
Browse files Browse the repository at this point in the history
  • Loading branch information
vipinpaul committed Aug 9, 2024
1 parent 1c4bdce commit dea15a3
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 3 deletions.
145 changes: 145 additions & 0 deletions renderer/src/components/ProjectManagement/ProjectManagement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/* eslint-disable no-useless-escape */
import React, {
useRef, Fragment,
} from 'react';
import PropTypes from 'prop-types';
import { Dialog, Transition } from '@headlessui/react';
import { useTranslation } from 'react-i18next';
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 * as logger from '../../logger';
import burrito from '../../lib/BurritoTemplate.json';
import ConfirmationModal from '@/layouts/editor/ConfirmationModal';

Check failure on line 16 in renderer/src/components/ProjectManagement/ProjectManagement.js

View workflow job for this annotation

GitHub Actions / Lint Run

`@/layouts/editor/ConfirmationModal` import should occur before import of `@/illustrations/close-button-black.svg`

export default function ProjectMangement(props) {
const {
open,
closePopUp,
project,
} = props;
const { t } = useTranslation();
const cancelButtonRef = useRef(null);
const [valid, setValid] = React.useState(false);

Check failure on line 26 in renderer/src/components/ProjectManagement/ProjectManagement.js

View workflow job for this annotation

GitHub Actions / Lint Run

'valid' is assigned a value but never used
const [snackBar, setOpenSnackBar] = React.useState(false);
const [snackText, setSnackText] = React.useState('');
const [notify, setNotify] = React.useState();

Check failure on line 29 in renderer/src/components/ProjectManagement/ProjectManagement.js

View workflow job for this annotation

GitHub Actions / Lint Run

'setNotify' is assigned a value but never used
const [openModal, setOpenModal] = React.useState(false);
const [metadata, setMetadata] = React.useState({});
const [checkText, setCheckText] = React.useState(false);

Check failure on line 32 in renderer/src/components/ProjectManagement/ProjectManagement.js

View workflow job for this annotation

GitHub Actions / Lint Run

'checkText' is assigned a value but never used
const [totalExported, setTotalExported] = React.useState(0);

Check failure on line 33 in renderer/src/components/ProjectManagement/ProjectManagement.js

View workflow job for this annotation

GitHub Actions / Lint Run

'totalExported' is assigned a value but never used
const [totalExports, setTotalExports] = React.useState(0);

Check failure on line 34 in renderer/src/components/ProjectManagement/ProjectManagement.js

View workflow job for this annotation

GitHub Actions / Lint Run

'totalExports' is assigned a value but never used
const [exportStart, setExportstart] = React.useState(false);

// const { pushNotification } = useSystemNotification();

function resetExportProgress() {
logger.debug('ExportProjectPopUp.js', 'reset Export Progress');
if (!exportStart) {
setTotalExported(0);
setTotalExports(0);
setExportstart(false);
}
}

function close() {
if (!exportStart) {
logger.debug('ExportProjectPopUp.js', 'Closing the Dialog Box');
resetExportProgress(); // reset export
closePopUp(false);
setValid(false);
setMetadata({});
setCheckText(false);
}
}

const updateBurritoVersion = (username) => {
logger.debug('ExportProjectPopUp.js', 'Inside updateBurritoVersion');
setTotalExported(1); // 1 step of 2 finished
if (project?.type === 'Text Translation') {
updateTranslationSB(username, project, openModal);
} else if (project?.type === 'OBS') {
updateObsSB(username, project, openModal);
}
setOpenModal(false);
};

return (
<>
<Transition
show={open}
as={Fragment}
enter="transition duration-100 ease-out"
enterFrom="transform scale-95 opacity-0"
enterTo="transform scale-100 opacity-100"
leave="transition duration-75 ease-out"
leaveFrom="transform scale-100 opacity-100"
leaveTo="transform scale-95 opacity-0"
>
<Dialog
as="div"
className="fixed inset-0 z-10 overflow-y-auto"
initialFocus={cancelButtonRef}
static
open={open}
onClose={close}
>
<Dialog.Overlay className="fixed inset-0 bg-black opacity-30" />
<div className="flex items-center justify-center h-screen">
<div className="w-5/12 h-3/6 items-center justify-center m-auto z-50 shadow overflow-hidden rounded">
<div className="relative h-full rounded shadow overflow-hidden bg-white">
<div className="flex justify-between items-center bg-secondary">
<div className="uppercase bg-secondary text-white py-2 px-2 text-xs tracking-widest leading-snug rounded-tl text-center">
Project Mangement
:
{
`${project?.name}`
}
</div>
<button
onClick={close}
type="button"
className="focus:outline-none"
>
<CloseIcon
className="h-6 w-7"
aria-hidden="true"
/>
</button>
</div>
<div className="relative w-full h-5/6">
<p>Project Management</p>
</div>
</div>
</div>
</div>
</Dialog>
</Transition>
<SnackBar
openSnackBar={snackBar}
snackText={snackText}
setOpenSnackBar={setOpenSnackBar}
setSnackText={setSnackText}
error={notify}
/>
<ConfirmationModal
openModal={openModal}
title={t('modal-title-update-burrito')}
setOpenModal={setOpenModal}
confirmMessage={t('dynamic-msg-update-burrito-version', { version1: metadata?.metadata?.meta?.version, version2: burrito?.meta?.version })}
buttonName={t('btn-update')}
closeModal={
() => updateBurritoVersion(metadata.username, metadata.fs, metadata.path, metadata.folder)
}
/>
</>
);
}
ProjectMangement.propTypes = {
open: PropTypes.bool,
closePopUp: PropTypes.func,
project: PropTypes.object,
};
15 changes: 13 additions & 2 deletions renderer/src/components/Projects/ProjectList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import NewProject from './NewProject';
import * as logger from '../../logger';
import ProjectRow from './ProjectRow';
import { ProjectContext } from '../context/ProjectContext';
import ProjectMangement from '../ProjectManagement/ProjectManagement';

export default function ProjectList() {
const { t } = useTranslation();
Expand All @@ -36,7 +37,7 @@ export default function ProjectList() {
FetchProjects,
},
} = useContext(AutographaContext);
const { states: { openExportPopUp }, actions: { setOpenExportPopUp } } = useContext(ProjectContext);
const { states: { openExportPopUp, openManageProject }, actions: { setOpenExportPopUp, setOpenManageProject } } = useContext(ProjectContext);
const [currentProject, setCurrentProject] = useState();
const [filteredProjects, setFilteredProjects] = useState(projects);
const handleExportPopUp = (project) => {
Expand All @@ -57,6 +58,14 @@ export default function ProjectList() {
setCallEditProject(false);
await FetchProjects();
};
const manageProject = (project) => {
console.log(project);

Check warning on line 62 in renderer/src/components/Projects/ProjectList.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
setCurrentProject(project);
setOpenManageProject(true);
};
const closeManageProject = () => {
setOpenManageProject(false);
};
return (
<>
{!callEditProject ? (
Expand Down Expand Up @@ -89,7 +98,7 @@ export default function ProjectList() {
orderBy={orderBy}
onRequestSort={handleRequestSort}
/>
<ProjectRow projects={projects} filteredProjects={filteredProjects} order={order} orderBy={orderBy} showArchived={showArchived} openExportPopUp={handleExportPopUp} setCurrentProject={setCurrentProject} handleClickStarred={handleClickStarred} />
<ProjectRow projects={projects} filteredProjects={filteredProjects} order={order} orderBy={orderBy} showArchived={showArchived} openExportPopUp={handleExportPopUp} setCurrentProject={setCurrentProject} handleClickStarred={handleClickStarred} manageProject={manageProject} />
</table>
{(!projects) && <div><LoadingScreen /></div>}
</div>
Expand All @@ -102,6 +111,8 @@ export default function ProjectList() {
</ProjectsLayout>
) : <NewProject call="edit" project={currentProject} closeEdit={() => closeEditProject()} />}
<ExportProjectPopUp open={openExportPopUp} closePopUp={closeExportPopUp} project={currentProject} />
{openManageProject
&& <ProjectMangement open={openManageProject} closePopUp={closeManageProject} project={currentProject} />}
</>
);
}
20 changes: 19 additions & 1 deletion renderer/src/components/Projects/ProjectRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import NewProjectIcon from '@/icons/new.svg';
import { ProjectContext } from '../context/ProjectContext';

const ProjectRow = ({
projects, order, orderBy, showArchived, openExportPopUp, handleClickStarred, setCurrentProject, filteredProjects,
projects, order, orderBy, showArchived, openExportPopUp, handleClickStarred, setCurrentProject, filteredProjects, manageProject,
}) => {
const router = useRouter();
const { t } = useTranslation();
Expand Down Expand Up @@ -233,6 +233,24 @@ const ProjectRow = ({
</button>
)}
</Menu.Item>
{
project.type === 'Audio'
&& (
<Menu.Item>
{({ active }) => (
<button
type="button"
aria-label="export-project"
className={`${active ? 'bg-primary text-white' : 'text-gray-900'
} group rounded-md items-center w-full px-2 py-2 text-sm ${project.isArchived ? 'hidden' : 'flex'}`}
onClick={() => manageProject(project)}
>
Manage Project
</button>
)}
</Menu.Item>
)
}
</div>
</Menu.Items>
</Transition>
Expand Down
3 changes: 3 additions & 0 deletions renderer/src/components/context/ProjectContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const ProjectContextProvider = ({ children }) => {
const [sideBarTab, setSideBarTab] = useState('');
const [openImportPopUp, setOpenImportPopUp] = useState(false);
const [openExportPopUp, setOpenExportPopUp] = useState(false);
const [openManageProject, setOpenManageProject] = useState(false);

const handleProjectFields = (prop) => (event) => {
setNewProjectFields({ ...newProjectFields, [prop]: event.target.value });
Expand Down Expand Up @@ -541,6 +542,7 @@ const ProjectContextProvider = ({ children }) => {
sideBarTab,
openImportPopUp,
openExportPopUp,
openManageProject,
selectedProjectMeta,
importedBookCodes,
},
Expand All @@ -566,6 +568,7 @@ const ProjectContextProvider = ({ children }) => {
setSideBarTab,
setOpenImportPopUp,
setOpenExportPopUp,
setOpenManageProject,
setSelectedProjectMeta,
setImportedBookCodes,
},
Expand Down

0 comments on commit dea15a3

Please sign in to comment.