Skip to content

Commit

Permalink
refactor: Converted ExportDialog to ExportModal
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkoelle committed May 17, 2021
1 parent ab7a91f commit 6f47073
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 398 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
TextField,
Tooltip,
} from '@material-ui/core';
import ConditionalComment from '../model/ConditionalComment';

const PrimaryTooltip = withStyles((theme: Theme) => ({
tooltip: {
Expand All @@ -38,17 +37,28 @@ function ValueLabelComponent(props: any) {
);
}

export interface ConditionalCommentProps {}
export interface ConditionalCommentProps {
conditionalComment;
setConditionalComment;
showLabel;
setShowLabel;
value;
setValue;
comments;
setComments;
}

const ConditionalComment = (props: ConditionalCommentProps) => {
const [conditionalComment, setConditionalComment] = useState(true);
const [showLabel, setShowLabel] = useState(true);
const [value, setValue] = React.useState<number[]>([60, 80, 100]);
const [comments, setComments] = React.useState<string[]>([
'Gut!',
'Sehr gut!',
'Perfekt!',
]);
const ConditionalCommentPanel = (props: ConditionalCommentProps) => {
const {
conditionalComment,
setConditionalComment,
showLabel,
setShowLabel,
value,
setValue,
comments,
setComments,
} = props;

const marks = [
{
Expand Down Expand Up @@ -114,16 +124,16 @@ const ConditionalComment = (props: ConditionalCommentProps) => {
/>
</Grid>
</Grid>
<Collapse in={conditionalComment}>
<Collapse in={conditionalComment} style={{ width: '100%' }}>
<Grid container justify="center" alignItems="center">
<Grid item xs={12}>
<Paper
variant="outlined"
style={{
padding: '50px 60px 16px',
padding: '50px 50px 10px',
marginTop: '16px',
marginBottom: '16px',
width: 'calc(100% - 50px)',
width: 'calc(100%)',
}}
>
<Slider
Expand Down Expand Up @@ -151,7 +161,7 @@ const ConditionalComment = (props: ConditionalCommentProps) => {
<Grid key={`comment-${i}`} item>
<TextField
id={`comment-${i}`}
label={`Comment ${i}`}
label={`Score ≥ ${value[i]}%`}
name={i.toString()}
defaultValue={c}
variant="outlined"
Expand All @@ -171,4 +181,4 @@ const ConditionalComment = (props: ConditionalCommentProps) => {
);
};

export default ConditionalComment;
export default ConditionalCommentPanel;
54 changes: 0 additions & 54 deletions app/components/ReleaseNotes.tsx

This file was deleted.

18 changes: 1 addition & 17 deletions app/containers/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import { selectUnsavedChanges } from '../model/SaveSlice';
import { version } from '../package.json';
import { selectSettings, SettingsState } from '../model/SettingsSlice';
import { selectAllSheets } from '../model/SheetSlice';
import { selectCorrectionsBySheetId } from '../model/Selectors';
import ExportDialog from '../components/ExportDialog';
import { useAppDispatch } from '../store';
import { shouldUseDarkColors } from '../model/Theme';
import buildMenu from '../menu/Menu';
Expand All @@ -41,12 +39,10 @@ export default function TitleBar(props: TitleBarProps) {
const settings: SettingsState = useSelector(selectSettings);
const recentPaths: string[] = useSelector(selectRecentPaths);
const sheets = useSelector(selectAllSheets);
const [exportSheetId, setExportSheetId] = useState<string>();
const corrections = useSelector(selectCorrectionsBySheetId(exportSheetId));
const unsavedChanges: boolean = useSelector(selectUnsavedChanges);
const [maximized, setMaximized] = useState(currentWindow.isMaximized());
const [openFileError, setOpenFileError] = useState<boolean>(false);
const [openExportDialog, setOpenExportDialog] = useState<boolean>(false);

// Only for force reloading menu
const [, setBackupPaths] = useState<string[]>([]);

Expand Down Expand Up @@ -113,8 +109,6 @@ export default function TitleBar(props: TitleBarProps) {
unsavedChanges,
recentPaths,
setOpenFileError,
setOpenExportDialog,
setExportSheetId,
setReload,
setOpenUpdater
) as any
Expand Down Expand Up @@ -156,16 +150,6 @@ export default function TitleBar(props: TitleBarProps) {
disableMaximize={false}
// is the current window maximized?
maximized={maximized}
>
{/* custom titlebar items */}
</FramelessTitlebar>
<ExportDialog
open={openExportDialog}
handleClose={() => {
setOpenExportDialog(false);
setExportSheetId(undefined);
}}
correctionsToExport={corrections}
/>
<Snackbar
open={openFileError}
Expand Down
32 changes: 32 additions & 0 deletions app/dialogs/ConfirmDeleteSheetDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Correction from '../model/Correction';
import { overviewClearSelectedSheetWithId } from '../model/OverviewSlice';
import { schemaClearSelectedSheetWithId } from '../model/SchemaSlice';
import Sheet from '../model/Sheet';
import {
deleteCorrectionFromWorkspace,
reloadState,
save,
} from '../utils/FileAccess';

const ConfirmDeleteSheetDialog = (
autosave: boolean,
sheet: Sheet,
workspace: string,
corrections: Correction[]
) => {
return {
title: 'Confirm Delete Sheet',
text: `Are you sure you want to delete the sheet "${sheet.name}"?`,
onConfirm: (dispatch) => {
dispatch(schemaClearSelectedSheetWithId(sheet.id));
dispatch(overviewClearSelectedSheetWithId(sheet.id));
corrections.forEach((c) => deleteCorrectionFromWorkspace(c, workspace));
dispatch(reloadState());
if (autosave) {
dispatch(save());
}
},
};
};

export default ConfirmDeleteSheetDialog;
20 changes: 6 additions & 14 deletions app/features/correction/CorrectionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import {
Tooltip,
Typography,
} from '@material-ui/core';
import React, { useEffect, useState } from 'react';
import React, { useEffect } from 'react';
import FirstPageIcon from '@material-ui/icons/FirstPage';
import LastPageIcon from '@material-ui/icons/LastPage';
import FindInPageIcon from '@material-ui/icons/FindInPage';
import NavigateNextIcon from '@material-ui/icons/NavigateNext';
import NavigateBeforeIcon from '@material-ui/icons/NavigateBefore';
import { useDispatch, useSelector } from 'react-redux';
import ExportDialog from '../../components/ExportDialog';
import TimeAverage from '../../components/TimeAverage';
import TimeRemaining from '../../components/TimeRemaining';
import Status from '../../model/Status';
Expand All @@ -32,6 +31,7 @@ import ConfirmationDialog from '../../dialogs/ConfirmationDialog';
import SkipUnreadFilesDialog from '../../dialogs/SkipUnreadFilesDialog';
import OpenExportModalDialog from '../../dialogs/OpenExportModalDialog';
import AutosaveCorrectionEffect from '../../effects/AutosaveCorrectionEffect';
import ExportModal from '../../modals/ExportModal';

type CorrectionViewProps = {
corrections: Correction[];
Expand All @@ -47,8 +47,6 @@ export default function CorrectionView(props: CorrectionViewProps) {
const workspace = useSelector(selectWorkspacePath);
const autosave: boolean = useSelector(selectSettingsAutosave);
const corr = corrections[index];
// Dialogs
const [openExportDialog, setOpenExportDialog] = useState(false);

useEffect(AutosaveCorrectionEffect(autosave, corr, workspace), [
autosave,
Expand All @@ -57,11 +55,10 @@ export default function CorrectionView(props: CorrectionViewProps) {
]);

function onExport() {
setOpenExportDialog(true);
}

function onCloseExportDialog() {
setOpenExportDialog(false);
const sheetId = corrections[index]?.submission.sheet.id;
if (sheetId) {
showModal(ExportModal, { sheetId });
}
}

function setStatusDone() {
Expand Down Expand Up @@ -315,11 +312,6 @@ export default function CorrectionView(props: CorrectionViewProps) {
</Tooltip>
</Grid>
</Grid>
<ExportDialog
open={openExportDialog}
handleClose={onCloseExportDialog}
correctionsToExport={corrections}
/>
</div>
);
}
Loading

0 comments on commit 6f47073

Please sign in to comment.