Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"postinstall-postinstall": "^2.1.0",
"prismjs": "^1.30.0",
"prismjs-bibtex": "^2.1.0",
"prop-types": "^15.8.1",
"react": "^19.3.1",
"react-dom": "^19.3.1",
"react-dropzone": "^20.2.0",
Expand Down
4 changes: 0 additions & 4 deletions scripts/typecheck-baseline.txt
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
src/app/App.js(466,12): error TS2739: Type '{ error: ErrorObject; onClose: () => void; }' is missing the following properties from type '{ error: any; onClose: any; needReload: any; title: any; }': needReload, title
src/app/App.js(512,10): error TS2741: Property 'needReload' is missing in type '{ error: unknown; title: string; onClose: () => void; }' but required in type '{ error: any; onClose: any; needReload: any; title: any; }'.
src/app/App.test.js(5,1): error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
src/app/App.test.js(13,3): error TS2304: Cannot find name 'expect'.
3 changes: 2 additions & 1 deletion src/app/AlignmentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ interface CardAlignment {
interface CardFinalAlignment {
dataType?: string;
numSequences: number;
numSequencesParsed: number;
// Absent on the store FinalAlignment; its parsingComplete is always true.
numSequencesParsed?: number;
length: number;
numAlignments: number;
filename: string;
Expand Down
1 change: 1 addition & 0 deletions src/app/App.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck — Jest globals. checkJs has no test runner types.
import React, { act } from 'react';
import { createRoot } from 'react-dom/client';
import Page from './index';
Expand Down
21 changes: 17 additions & 4 deletions src/app/App.js → src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import ErrorBoundary from './components/ErrorBoundary';
import ErrorDialog from './components/ErrorDialog';
import ModifiedDialog from './components/ModifiedDialog';

const VerticalHeading = styled( Typography )( ( { theme } ) => ( {
const VerticalHeading = styled( Typography )( () => ( {
writingMode: 'vertical-rl',
textOrientation: 'upright',
padding: '10px 5px',
Expand All @@ -43,7 +43,20 @@ const VerticalHeading = styled( Typography )( ( { theme } ) => ( {
borderRight: '1px solid #ccc',
} ) );

const App = () => {
interface SnackRun {
converted: boolean;
convertedAlignmentFrom: string | null;
modified: boolean;
showModifiedSnack: boolean;
clearShowModified: () => void;
}

interface SnackStore {
showAppSnack: boolean;
clearAppSnack: () => void;
}

const App = (): React.JSX.Element => {
const TabItems = store.runs.map( ( run ) => (
<Tab
key={run.id}
Expand Down Expand Up @@ -79,7 +92,7 @@ const App = () => {
/>
) );

function fileModifiedSnack( run ) {
function fileModifiedSnack( run: SnackRun ): React.JSX.Element {
let message = 'Something happened';
if ( run.converted ) {
message = `Converted your ${run.convertedAlignmentFrom} alignment into fasta!`;
Expand Down Expand Up @@ -107,7 +120,7 @@ const App = () => {
);
}

function appSnack( store ) {
function appSnack( store: SnackStore ): React.JSX.Element {
const message = 'Command copied';
return (
<Snackbar
Expand Down
19 changes: 12 additions & 7 deletions src/app/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import React from 'react';
import { observer } from 'mobx-react-lite';
import Button from '@mui/material/Button';
import AlignmentCard, { FinalAlignmentCard } from './AlignmentCard';
import type { AlignmentCardProps, FinalAlignmentCardProps } from './AlignmentCard';
import AstralTreeCard from './AstralTreeCard';
import type { AstralTreeCardProps } from './AstralTreeCard';
import PartitionFileCard from './PartitionFileCard';
import type { PartitionFileCardProps } from './PartitionFileCard';
import Box from '@mui/material/Box';
import TreeCard from './TreeCard';
import type { TreeCardProps } from './TreeCard';
import { Typography } from '@mui/material';
import Dropzone from 'react-dropzone';
import type { SxProps, Theme } from '@mui/material/styles';
Expand All @@ -14,21 +18,22 @@ interface DroppedFile {
path: string;
}

interface InputTree {
// Each child card's props name what it reads of the same store object.
type InputTree = TreeCardProps['tree'] & {
notAvailable: boolean;
haveFile: boolean;
}
};

interface InputRun {
type InputRun = PartitionFileCardProps['run'] & {
hasAstralTree: boolean;
addAlignments: ( files: DroppedFile[] ) => void;
addPartitionFiles: ( files: DroppedFile[] ) => void;
addTreeFiles: ( type: string, files: DroppedFile[] ) => void;
addAstralFiles: ( file: DroppedFile ) => void;
inputIsAlignment: boolean;
alignments: { path: string }[];
alignments: ( AlignmentCardProps['alignment'] & { path: string } )[];
inputIsTree: boolean;
astralTree: unknown;
astralTree: AstralTreeCardProps['astralTree'];
canLoadAlignment: boolean;
haveAlignments: boolean;
canLoadPartitionFile: boolean;
Expand All @@ -42,8 +47,8 @@ interface InputRun {
loadBackboneConstraintFile: () => void;
multifurcatingConstraint: InputTree;
loadMultifurcatingConstraintFile: () => void;
finalAlignment: unknown;
}
finalAlignment: FinalAlignmentCardProps['alignment'];
};

export interface InputProps {
run: InputRun;
Expand Down
3 changes: 2 additions & 1 deletion src/app/TreeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import type { SxProps, Theme } from '@mui/material/styles';

interface CardTree {
name: string;
loading: boolean;
// The store Tree has no loading flag, so this always reads undefined.
loading?: boolean;
openFile: () => void;
openFolder: () => void;
remove: () => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Box } from '@mui/material';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
Expand All @@ -17,11 +16,27 @@ import { getMailtoLinkToReportError } from '../report';
import { reportIssueToGitHub } from '../githubIssue';

const handleReload = () => {
const { rendererBridge } = /** @type {any} */ ( window );
return rendererBridge.reload();
return window.rendererBridge.reload();
};

export default function ErrorDialog( { error, onClose, needReload, title } ) {
type DialogError = Error & { isUserFix?: boolean };

export interface ErrorDialogProps {
// Store errors are caught values (unknown) or serialized bridge errors.
error?: unknown;
onClose: () => void;
needReload?: boolean;
title?: string | null;
}

export default function ErrorDialog( {
error: caught,
onClose,
needReload,
title,
}: ErrorDialogProps ): React.JSX.Element | null {
// The dialog reads name, message and isUserFix as the untyped component did.
const error = caught as DialogError | null | undefined;
const [reported, setReported] = React.useState( false );
const mailtoContent = React.useMemo(
() => ( error
Expand Down Expand Up @@ -171,10 +186,3 @@ export default function ErrorDialog( { error, onClose, needReload, title } ) {

return returnDialog;
}

ErrorDialog.propTypes = {
error: PropTypes.object,
onClose: PropTypes.func.isRequired,
needReload: PropTypes.bool,
title: PropTypes.string,
};
2 changes: 1 addition & 1 deletion src/app/index.js → src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if ( process.env.NODE_ENV !== 'development' ) {
} );
}

const Index = () => {
const Index = (): React.JSX.Element => {
const { light, dark } = theme;
const muiTheme = store.config.isDarkMode
? dark
Expand Down
2 changes: 1 addition & 1 deletion src/pageNodeImports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ it( 'the page can still import the user-fix error type and the alignment typeche
expect( alignment ).toMatch( /from ['"]\.\.\/\.\.\/common\/typecheckAlignment['"]/ );
expect( alignment ).toMatch( /from ['"]\.\.\/\.\.\/common\/errors['"]/ );
expect( run ).toMatch( /from ['"]\.\.\/\.\.\/common\/errors['"]/ );
expect( fs.readFileSync( path.join( __dirname, 'app', 'index.js' ), 'utf8' ) )
expect( fs.readFileSync( path.join( __dirname, 'app', 'index.tsx' ), 'utf8' ) )
.not.toMatch( /from ['"]\.\.\/common\/utils['"]/ );
} );
Loading