{"size": 2015, "ext": "js", "max_stars_repo_path": "lexis-client/src/modules/workflowTemplates/ui/workflowTemplate-upload.js", "max_stars_repo_name": "lexis-project/lexis-frontend-general", "max_stars_repo_stars_event_min_datetime": "2022-03-31T14:33:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:33:45.000Z", "max_issues_repo_path": "lexis-client/src/modules/workflowTemplates/ui/workflowTemplate-upload.js", "max_issues_repo_name": "lexis-project/lexis-frontend-general", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lexis-client/src/modules/workflowTemplates/ui/workflowTemplate-upload.js", "max_forks_repo_name": "lexis-project/lexis-frontend-general", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 37.3148148148, "max_line_length": 79, "alphanum_fraction": 0.4486352357}
import React from "react"
import cx from "classnames"
import { reduxForm } from "redux-form"
import { ReduxFormInputField } from "../../forms/input-field"
import { validateWFTUploadFragment } from "./validate"

const FragmentUploadImpl = ({
    handleSubmit,
    onFormSubmit,
    uploadInProgress,
}) => {
    return (
        <form
            onSubmit={handleSubmit(onFormSubmit)}
            className={cx({
                "workflow-template-upload": true,
            })}>
            <div className="card">
                <div className="card-header">
                    Upload a new Workflow Template{" "}
                </div>{" "}
                <div className="card-body">
                    <div className="row justify-content-between">
                        <div className="col">
                            <ReduxFormInputField
                                type="file"
                                label="Browse local files"
                                required={true}
                                name="workflowTemplate.file"
                                cy="workflowtemplates-fragment-upload-file"
                            />
                        </div>{" "}
                        <button
                            style={{ marginRight: "20px" }}
                            type="submit"
                            className="btn btn-simple text-nowrap"
                            disabled={uploadInProgress}>
                            {" "}
                            {uploadInProgress ? "Uploading..." : "Upload"}{" "}
                        </button>{" "}
                    </div>{" "}
                </div>{" "}
            </div>{" "}
        </form>
    )
}

export default reduxForm({
    form: "workflow-template-upload", // <------ same form name
    destroyOnUnmount: false, // <------ preserve form data
    forceUnregisterOnUnmount: false, // <------ unregister fields on unmount
    validate: validateWFTUploadFragment,
})(FragmentUploadImpl)
