mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-04 16:38:12 +08:00
* Added TS. Updated build and linting config. Added types. * [ts-migrate][.] Rename files from JS/JSX to TS/TSX Co-authored-by: ts-migrate <> * [ts-migrate][.] Run TS Migrate Co-authored-by: ts-migrate <> * Corrected files mangled by ts-migrate. * Updated lint config, minor linting. * Re-enabled Husky. * Updated tests and config. * Reverted webpack devtool config. * Removed obsolete snapshots. * Added annotations snap. * Updated tsconfig includes wrt linting. * Removed ts-migrate. Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
This commit is contained in:
co-authored by
ts-migrate
Timmy Huang
parent
7328cbdbd5
commit
934cc5c69b
@@ -1,132 +0,0 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import AnnoDialog from "../../annoDialog";
|
||||
import LabelInput from "../../labelInput";
|
||||
|
||||
@connect((state) => ({
|
||||
annotations: state.annotations,
|
||||
schema: state.annoMatrix?.schema,
|
||||
obsCrossfilter: state.obsCrossfilter,
|
||||
genesetsUI: state.genesetsUI,
|
||||
genesets: state.genesets.genesets,
|
||||
}))
|
||||
class RenameGeneset extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
newGenesetName: props.parentGeneset,
|
||||
newGenesetDescription: props.parentGenesetDescription,
|
||||
};
|
||||
}
|
||||
|
||||
disableEditGenesetNameMode = (e) => {
|
||||
const { dispatch } = this.props;
|
||||
this.setState({
|
||||
newGenesetName: "",
|
||||
newGenesetDescription: "",
|
||||
});
|
||||
dispatch({
|
||||
type: "geneset: disable rename geneset mode",
|
||||
});
|
||||
if (e) e.preventDefault();
|
||||
};
|
||||
|
||||
renameGeneset = (e) => {
|
||||
const { dispatch, genesetsUI } = this.props;
|
||||
const { newGenesetName, newGenesetDescription } = this.state;
|
||||
|
||||
dispatch({
|
||||
type: "geneset: update",
|
||||
genesetName: genesetsUI.isEditingGenesetName,
|
||||
update: {
|
||||
genesetName: newGenesetName,
|
||||
genesetDescription: newGenesetDescription,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: "geneset: disable rename geneset mode",
|
||||
});
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
genesetNameError = () => {
|
||||
return false;
|
||||
};
|
||||
|
||||
handleChange = (e) => {
|
||||
this.setState({ newGenesetName: e });
|
||||
};
|
||||
|
||||
handleChangeDescription = (e) => {
|
||||
this.setState({ newGenesetDescription: e });
|
||||
};
|
||||
|
||||
validate = (genesetName, genesets) => {
|
||||
return (
|
||||
!genesets.has(genesetName) &&
|
||||
// eslint-disable-next-line no-control-regex -- unicode 0-31 127-65535
|
||||
genesetName.match(/^\s|[\u0000-\u001F\u007F-\uFFFF]|[ ]{2,}|^$|\s$/g)
|
||||
?.length
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { newGenesetName, newGenesetDescription } = this.state;
|
||||
const {
|
||||
genesetsUI,
|
||||
parentGeneset,
|
||||
parentGenesetDescription,
|
||||
genesets,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<AnnoDialog
|
||||
isActive={genesetsUI.isEditingGenesetName === parentGeneset}
|
||||
inputProps={{
|
||||
"data-testid": `${genesetsUI.isEditingGenesetName}:rename-geneset-dialog`,
|
||||
}}
|
||||
primaryButtonProps={{
|
||||
"data-testid": `${genesetsUI.isEditingGenesetName}:submit-geneset`,
|
||||
}}
|
||||
title="Edit gene set name and description"
|
||||
instruction={`Rename ${genesetsUI.isEditingGenesetName}`}
|
||||
cancelTooltipContent="Close this dialog without renaming the gene set."
|
||||
primaryButtonText="Edit gene set name and description"
|
||||
text={newGenesetName}
|
||||
secondaryText={newGenesetDescription}
|
||||
validationError={
|
||||
this.validate(newGenesetName, genesets) &&
|
||||
parentGenesetDescription === newGenesetDescription
|
||||
}
|
||||
annoInput={
|
||||
<LabelInput
|
||||
label={newGenesetName}
|
||||
onChange={this.handleChange}
|
||||
inputProps={{
|
||||
"data-testid": "rename-geneset-modal",
|
||||
leftIcon: "manually-entered-data",
|
||||
intent: "none",
|
||||
autoFocus: true,
|
||||
}}
|
||||
/>
|
||||
}
|
||||
secondaryInstructions="Edit description"
|
||||
secondaryInput={
|
||||
<LabelInput
|
||||
label={newGenesetDescription}
|
||||
onChange={this.handleChangeDescription}
|
||||
inputProps={{ "data-testid": "change geneset description" }}
|
||||
intent="none"
|
||||
autoFocus={false}
|
||||
/>
|
||||
}
|
||||
handleSubmit={this.renameGeneset}
|
||||
handleCancel={this.disableEditGenesetNameMode}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default RenameGeneset;
|
||||
Reference in New Issue
Block a user