Skip to content

Commit

Permalink
Merge pull request #57 from koellemichael/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
michaelkoelle authored Oct 27, 2021
2 parents 2e95137 + 4f6102a commit 09ce9d4
Show file tree
Hide file tree
Showing 48 changed files with 338 additions and 116 deletions.
2 changes: 1 addition & 1 deletion app/autocorrection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class AutoCorrection {
);
});

ipcMain.on(AUTOCORRECTION_CANCEL, (event: IpcMainEvent, arg) => {
ipcMain.on(AUTOCORRECTION_CANCEL, (event: IpcMainEvent) => {
const { sender } = event;
this.cancelRequest = true;
sender.send(AUTOCORRECTION_CANCEL_PENDING);
Expand Down
11 changes: 7 additions & 4 deletions app/components/ConditionalCommentSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
/* eslint-disable react/jsx-props-no-spreading */
import React from 'react';
import { Theme, withStyles } from '@material-ui/core/styles';
import AddCircleIcon from '@material-ui/icons/AddCircle';
import Typography from '@material-ui/core/Typography';
import {
Fade,
Grid,
IconButton,
Paper,
Slider,
Tooltip,
Theme,
useTheme,
} from '@material-ui/core';
import { useDispatch, useSelector } from 'react-redux';
Expand All @@ -22,7 +20,12 @@ import {
settingsUpdateConditionalCommentValue,
} from '../model/SettingsSlice';

function ValueLabelComponent(props: any) {
function ValueLabelComponent(props: {
children;
value: number;
comments: string[];
theme: Theme;
}) {
const { children, value, comments, theme } = props;
return (
<>
Expand Down
1 change: 0 additions & 1 deletion app/components/ConditionalCommentTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* eslint-disable react/prop-types */
import { IconButton, TextField } from '@material-ui/core';
import CancelIcon from '@material-ui/icons/Cancel';
import { relative } from 'path';
import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
import ConditionalComment from '../model/ConditionalComment';
Expand Down
7 changes: 6 additions & 1 deletion app/components/LoadingItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { Grid, CircularProgress, Typography } from '@material-ui/core';
import React from 'react';
import DoneIcon from '@material-ui/icons/Done';

export default function LoadingItem(props: any): JSX.Element {
export type LoadingItemProps = {
complete: boolean;
message: string;
};

export default function LoadingItem(props: LoadingItemProps): JSX.Element {
const { complete, message } = props;
const loadingIcon = complete ? (
<DoneIcon style={{ fill: 'black' }} />
Expand Down
16 changes: 10 additions & 6 deletions app/components/LoadingItemList.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { List, ListItem } from '@material-ui/core';
import React from 'react';
import LoadingItem from './LoadingItem';
import LoadingItem, { LoadingItemProps } from './LoadingItem';

export default function LoadingItemList(props: any): JSX.Element {
type LoadingItemListProps = {
progress: (LoadingItemProps & { active: boolean })[];
};

export default function LoadingItemList(
props: LoadingItemListProps
): JSX.Element {
const { progress } = props;
const activeItems = progress.filter(
(item: { active: boolean }) => item.active
);
const activeItems = progress.filter((item) => item.active);

return (
<List>
{activeItems.map((item: { message: string; complete: boolean }) => {
{activeItems.map((item) => {
return (
<ListItem key={item.message}>
<LoadingItem message={item.message} complete={item.complete} />
Expand Down
2 changes: 1 addition & 1 deletion app/components/OutputFormatSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
selectSettingsExport,
settingsSetExport,
} from '../model/SettingsSlice';
import { ParserType } from '../parser/Parser';
import ParserType from '../parser/ParserType';

const OutputFormatSelect = () => {
const dispatch = useDispatch();
Expand Down
2 changes: 1 addition & 1 deletion app/containers/CorrectionViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
} from '../model/Selectors';

import Sheet from '../model/Sheet';
import { sheetsUpsertOne } from '../model/SheetSlice';
import { serializeTerm } from '../utils/Formatter';
import './SplitPane.css';

Expand Down Expand Up @@ -64,6 +63,7 @@ export default function CorrectionViewPage() {
);
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [index]);

function handleCloseDialog() {
Expand Down
2 changes: 1 addition & 1 deletion app/containers/OverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import React from 'react';
import Overview from '../features/overview/Overview';

export default function OverviewPage(props: any) {
export default function OverviewPage(props) {
return <Overview {...props} />;
}
1 change: 1 addition & 0 deletions app/containers/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AnyAction, EnhancedStore } from '@reduxjs/toolkit';
import Providers from './Providers';

type Props = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
store: EnhancedStore<any, AnyAction, any[]>;
history: History;
};
Expand Down
3 changes: 2 additions & 1 deletion app/containers/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useSelector } from 'react-redux';
import { useTheme, Snackbar } from '@material-ui/core';
import { remote } from 'electron';
import { Alert } from '@material-ui/lab';
import { MenuItem } from 'frameless-titlebar/dist/title-bar/typings';
import {
selectRecentPaths,
selectWorkspacePath,
Expand Down Expand Up @@ -109,7 +110,7 @@ export default function TitleBar(props: TitleBarProps) {
recentPaths,
setOpenFileError,
setReload
) as any
) as MenuItem[] | undefined
}
theme={{
bar: {
Expand Down
3 changes: 2 additions & 1 deletion app/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import {
} from './constants/ExportIPC';
import ConditionalComment from './model/ConditionalComment';
import Correction from './model/Correction';
import Parser, { ParserType } from './parser/Parser';
import Parser from './parser/Parser';
import instanciateParser from './parser/ParserUtil';
import { serializeCorrection } from './utils/Formatter';
import { loadFilesFromWorkspaceMainProcess } from './utils/FileAccess';
import ParserType from './parser/ParserType';

export interface ExportProgress {
steps: {
Expand Down
1 change: 1 addition & 0 deletions app/features/correction/CorrectionOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function CorrectionOverview(props: CorrectionOverviewProps) {
correction.status === Status.Marked
)
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [index]);

const handleClick = () => {
Expand Down
6 changes: 4 additions & 2 deletions app/features/media-viewer/PDFViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export default function PDFViewer(props: ViewerProps) {
const textLayers = document.querySelectorAll(
'.react-pdf__Page__textContent'
);
textLayers.forEach((layer: any) => {
const { style } = layer;
textLayers.forEach((layer) => {
const { style } = (layer as unknown) as {
style: { top: string; left: string; transform: string };
};
style.top = '0';
style.left = '0';
style.transform = '';
Expand Down
1 change: 1 addition & 0 deletions app/features/media-viewer/ViewerToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default function ViewerToolbar(props: ViewerToolbarProps) {
return () => {
window.removeEventListener('wheel', handleScrollEvent);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
Expand Down
16 changes: 11 additions & 5 deletions app/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from 'electron';
import { normalize } from 'normalizr';
import Correction from './model/Correction';
import Parser, { ParserType } from './parser/Parser';
import Parser from './parser/Parser';
import instanciateParser from './parser/ParserUtil';
import {
IMPORT_CONFLICTS,
Expand All @@ -27,6 +27,7 @@ import {
getAllFilesInDirectory,
} from './utils/FileAccess';
import { CorrectionSchema } from './model/NormalizationSchema';
import ParserType from './parser/ParserType';

export interface ImportProgress {
name: string;
Expand Down Expand Up @@ -82,6 +83,7 @@ export default class Importer {
// Create new workspace file if no workspace is allocated yet
if (workspacePath.length === 0) {
const p: string | undefined = dialog.showSaveDialogSync(this.mainWindow, {
defaultPath: `${Path.parse(path).name}.cor`,
filters: [{ name: 'Correctinator', extensions: ['cor'] }],
});
if (!p) {
Expand Down Expand Up @@ -162,7 +164,8 @@ export default class Importer {
const content = fs.readFileSync(importPath, Importer.ENCODING);
const correction: Correction = parser.deserialize(
content,
Path.basename(Path.dirname(importPath))
Path.basename(Path.dirname(importPath)),
Path.basename(importPath)
);

// Were the submissions already imported?
Expand Down Expand Up @@ -224,7 +227,8 @@ export default class Importer {
const content = zipEntry.getData().toString(Importer.ENCODING);
const correction: Correction = parser.deserialize(
content,
Path.basename(Path.dirname(zipEntry.entryName))
Path.basename(Path.dirname(zipEntry.entryName)),
Path.basename(zipEntry.entryName)
);

// Were the submissions already imported?
Expand Down Expand Up @@ -381,7 +385,8 @@ export default class Importer {
const parser: Parser = instanciateParser(c.parser);
const correction: Correction = parser.deserialize(
content,
Path.basename(Path.dirname(c.path))
Path.basename(Path.dirname(c.path)),
Path.basename(c.path)
);
corrections.push(
this.ingestCorrectionFromZip(
Expand All @@ -407,7 +412,8 @@ export default class Importer {
const parser: Parser = instanciateParser(c.parser);
const correction: Correction = parser.deserialize(
content,
Path.basename(Path.dirname(c.path))
Path.basename(Path.dirname(c.path)),
Path.basename(c.path)
);
corrections.push(
this.ingestCorrectionFromFolder(
Expand Down
5 changes: 0 additions & 5 deletions app/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export default class MenuBuilder {
this.setupDevelopmentEnvironment();
}

const template =
process.platform === 'darwin'
? this.buildDarwinTemplate()
: this.buildDefaultTemplate();

const menu = Menu.buildFromTemplate([]);
Menu.setApplicationMenu(menu);

Expand Down
1 change: 1 addition & 0 deletions app/menu/FileMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const buildFileMenu = (
},
{
label: 'Close file',
disabled: !workspace,
click: async () => {
unsavedChangesDialog('');
},
Expand Down
5 changes: 3 additions & 2 deletions app/modals/AutoCorrectionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const AutoCorrectionModal: FC<AutoCorrectionModalProps> = ({ ...props }) => {
) => {
setAutoCorrectionProgress(progress);
};
const handleAutoCorrectionCancelPending = (_event: IpcRendererEvent) => {
const handleAutoCorrectionCancelPending = () => {
setAutoCorrectionState(AutoCorrectionState.AUTOCORRECTION_CANCEL_PENDING);
};

Expand Down Expand Up @@ -236,9 +236,10 @@ const AutoCorrectionModal: FC<AutoCorrectionModalProps> = ({ ...props }) => {
handleProgress
);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

let content;
let content: JSX.Element | null;

switch (autoCorrectionState) {
case AutoCorrectionState.AUTOCORRECTION_STARTED:
Expand Down
4 changes: 1 addition & 3 deletions app/modals/ExportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import DialogTitleWithCloseIcon from './DialogTitleWithCloseIcon';
import { ModalProps } from './ModalProvider';
import { selectCorrectionsBySheetId } from '../model/Selectors';
import * as ExportIPC from '../constants/ExportIPC';
import { ParserType } from '../parser/Parser';
import { ExportProgress } from '../exporter';
import CircularProgressWithLabel from '../components/CircularProgressWithLabel';
import Status from '../model/Status';
Expand All @@ -41,8 +40,7 @@ import {
} from '../model/SettingsSlice';
import OutputFormatSelect from '../components/OutputFormatSelect';
import ConditionalCommentSettings from '../components/ConditionalCommentSettings';
import Correction from '../model/Correction';
import { selectSheetById } from '../model/SheetSlice';
import ParserType from '../parser/ParserType';

type ExportModalProps = ModalProps & {
sheetId: string;
Expand Down
3 changes: 2 additions & 1 deletion app/modals/ImportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import {
import { CorrectionsSchema } from '../model/NormalizationSchema';
import { loadCorrections } from '../model/CorrectionsSlice';
import CircularProgressWithLabel from '../components/CircularProgressWithLabel';
import { ParserType } from '../parser/Parser';
// eslint-disable-next-line import/no-cycle
import OverwriteDuplicateSubmissionsDialog from '../dialogs/OverwriteDuplicateSubmissionsDialog';
import ConfirmationDialog from '../dialogs/ConfirmationDialog';
import { save } from '../utils/FileAccess';
import { selectSettingsGeneral } from '../model/SettingsSlice';
import ParserType from '../parser/ParserType';

type ImportModalProps = ModalProps & {
path?: string;
Expand Down Expand Up @@ -127,6 +127,7 @@ const ImportModal: FC<ImportModalProps> = ({ ...props }) => {
ipcRenderer.removeListener(ImportIPC.IMPORT_FAILED, handleImportFailed);
ipcRenderer.removeListener(ImportIPC.IMPORT_PROGRESS, handleProgress);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

let content;
Expand Down
3 changes: 2 additions & 1 deletion app/modals/ModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ const ModalContext = createContext<

export default function ModalProvider(props: ModalProviderProps) {
const { children } = props;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [Modal, setModal] = useState<any>(null);
const [modalOptions, setModalOptions] = useState<any>(null);
const [modalOptions, setModalOptions] = useState<unknown>(null);

const openModal = <T extends unknown>(
component: FC<T & ModalProps>,
Expand Down
1 change: 1 addition & 0 deletions app/modals/ReleaseNotesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const ReleaseNotesModal: FC<ReleaseNotesModalProps> = ({ ...props }) => {
.catch(() => {
setLoading(false);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

let content: JSX.Element;
Expand Down
6 changes: 4 additions & 2 deletions app/model/AnnotationSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const slice = createSlice({
adapter.upsertMany(state, action.payload.annotations);
}
},
[deleteEntities.type]: (state, action) => {
[deleteEntities.type]: (state) => {
adapter.removeAll(state);
},
},
Expand All @@ -53,6 +53,8 @@ export const {
selectEntities: selectAnnotationEntities,
selectAll: selectAllAnnotations,
selectTotal: selectTotalAnnotations,
} = adapter.getSelectors((state: any) => state.annotations);
} = adapter.getSelectors(
(state: { annotations: EntityState<Annotation> }) => state.annotations
);

export default slice.reducer;
10 changes: 8 additions & 2 deletions app/model/CommentSlice.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint-disable import/no-cycle */
import { createEntityAdapter, createSlice } from '@reduxjs/toolkit';
import {
createEntityAdapter,
createSlice,
EntityState,
} from '@reduxjs/toolkit';
import CommentEntity from './CommentEntity';
import { loadCorrections, deleteEntities } from './CorrectionsSlice';

Expand Down Expand Up @@ -49,6 +53,8 @@ export const {
selectEntities: selectCommentsEntities,
selectAll: selectAllComments,
selectTotal: selectTotalComments,
} = adapter.getSelectors((state: any) => state.comments);
} = adapter.getSelectors(
(state: { comments: EntityState<CommentEntity> }) => state.comments
);

export default slice.reducer;
Loading

0 comments on commit 09ce9d4

Please sign in to comment.