Skip to content

Commit

Permalink
Merge pull request #232 from CBIIT/CRDCDH-561
Browse files Browse the repository at this point in the history
CRDCDH-561 Added "Update" upload Metadata Intention
  • Loading branch information
amattu2 authored Dec 6, 2023
2 parents e0c9c79 + e64c92f commit b304aa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/components/DataSubmissions/DataSubmissionUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ const VisuallyHiddenInput = styled("input")(() => ({

const UploadRoles: User["role"][] = ["Organization Owner"]; // and submission owner

type UploadType = "New" | "Update";

type Props = {
submitterID: string;
readOnly?: boolean;
Expand All @@ -121,7 +119,7 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
const { submissionId } = useParams();
const { user } = useAuthContext();

const [uploadType, setUploadType] = useState<UploadType>("New");
const [metadataIntention, setMetadataIntention] = useState<MetadataIntention>("New");
const [selectedFiles, setSelectedFiles] = useState<FileList | null>(null);
const [isUploading, setIsUploading] = useState<boolean>(false);
const uploadMetatadataInputRef = useRef<HTMLInputElement>(null);
Expand Down Expand Up @@ -195,7 +193,7 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
variables: {
submissionID: submissionId,
type: "metadata",
metadataIntention: "New",
metadataIntention,
files: formattedFiles,
}
});
Expand Down Expand Up @@ -299,9 +297,9 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
<RadioInput
id="data-submission-dashboard-upload-type"
label="Upload Type"
value={uploadType}
onChange={(event, value: UploadType) => setUploadType(value)}
options={[{ label: "New", value: "New" }, { label: "Update", value: "Update", disabled: true }]}
value={metadataIntention}
onChange={(_event, value: MetadataIntention) => setMetadataIntention(value)}
options={[{ label: "New", value: "New", disabled: !canUpload }, { label: "Update", value: "Update", disabled: !canUpload }]}
gridWidth={4}
readOnly={readOnly}
inline
Expand Down
6 changes: 5 additions & 1 deletion src/components/DataSubmissions/RadioInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const StyledAsterisk = styled("span")(() => ({

const StyledRadio = styled(Radio)((props) => ({
"& input": {
cursor: props.readOnly ? "not-allowed" : "initial",
cursor: props.readOnly ? "not-allowed" : "pointer",
},
"& .radio-icon": {
backgroundColor: props.readOnly ? "#D2DFE9 !important" : "initial",
Expand Down Expand Up @@ -173,6 +173,10 @@ const RadioYesNoInput: FC<Props> = ({
};
}, [radioGroupInputRef]);

useEffect(() => {
setVal(value?.toString() ?? null);
}, [value]);

return (
<GridStyled md={gridWidth || 6} xs={12} item $containerWidth={containerWidth}>
<FormControl className="formControl" error={error}>
Expand Down

0 comments on commit b304aa8

Please # to comment.