Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit bbc87f1

Browse files
committed
chore: empty data after create prebuild project
1 parent 25374e9 commit bbc87f1

7 files changed

Lines changed: 39 additions & 22 deletions

File tree

src/components/CreateProjectModal/index.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const CreateProjectDatasetTypeControl = function (
6565
setPrebuildDataset,
6666
listPrebuildDataset,
6767
isLoadingPrebuildDataset,
68+
isCreatingProject,
6869
} = props;
6970

7071
const onChangeNumberOfDatasetImagesSlider = (
@@ -98,7 +99,7 @@ const CreateProjectDatasetTypeControl = function (
9899
<Box>
99100
<FormControlLabel
100101
value={value}
101-
control={<Radio />}
102+
control={<Radio disabled={isCreatingProject} />}
102103
label={label}
103104
onClick={() => setDatasetProjectType(value)}
104105
/>
@@ -114,6 +115,7 @@ const CreateProjectDatasetTypeControl = function (
114115
value={prebuildDataset}
115116
disablePortal
116117
loading={isLoadingPrebuildDataset}
118+
disabled={isCreatingProject}
117119
options={listPrebuildDataset}
118120
getOptionLabel={(option) => option.name}
119121
onChange={(_, selectedPrebuildDataset) => {
@@ -150,6 +152,7 @@ const CreateProjectDatasetTypeControl = function (
150152
prebuildDataset?.totalImage ||
151153
MIN_DATASET_IMAGES_CREATE_PROJECT
152154
}
155+
disabled={isCreatingProject}
153156
/>
154157
<Input
155158
value={numberOfDatasetImages}
@@ -164,6 +167,7 @@ const CreateProjectDatasetTypeControl = function (
164167
type: "number",
165168
"aria-labelledby": "input-number-of-dataset-images-slider",
166169
}}
170+
disabled={isCreatingProject}
167171
/>
168172
</Box>
169173
</Box>
@@ -179,6 +183,7 @@ const CreateProjectModal = function (props: CreateProjectModalProps) {
179183
register,
180184
handleSubmit,
181185
formState: { errors },
186+
reset,
182187
} = useForm<CreateProjectFields>({
183188
mode: "onChange",
184189
defaultValues: {
@@ -229,6 +234,13 @@ const CreateProjectModal = function (props: CreateProjectModalProps) {
229234
(state: RootState) => state.projectReducer.isCreatingProject
230235
);
231236

237+
const resetFormData = () => {
238+
reset();
239+
setPrebuildDataset(null);
240+
setDatasetProjectType(EMPTY_DATASET_CREATE_PROJECT_DATASET_TYPE_VALUE);
241+
setNumberOfDatasetImages(1);
242+
};
243+
232244
const onSubmitCreateProject = (fields: CreateProjectFields) => {
233245
if (
234246
datasetProjectType === EXISTING_DATASET_CREATE_PROJECT_DATASET_TYPE_VALUE
@@ -239,24 +251,34 @@ const CreateProjectModal = function (props: CreateProjectModalProps) {
239251
numberRadom: numberOfDatasetImages,
240252
};
241253
} else {
242-
toast.error("Please select one prebuild dataset");
254+
toast.error("Please select one prebuild dataset.");
243255
return;
244256
}
245257
}
246258

247259
dispatch({ type: CREATE_PROJECT.REQUESTED, payload: fields });
260+
resetFormData();
261+
};
262+
263+
const onCloseModal = () => {
264+
if (!isLoading) {
265+
if (handleClose) {
266+
handleClose();
267+
}
268+
resetFormData();
269+
}
248270
};
249271

250272
return (
251273
<Modal
252274
open={isOpen}
253-
onClose={!isLoading ? handleClose : undefined}
275+
onClose={!isLoading ? onCloseModal : undefined}
254276
disableEscapeKeyDown
255277
>
256278
<Box sx={{ ...modalStyle, width: 700 }}>
257279
<IconButton
258280
sx={modalCloseStyle}
259-
onClick={!isLoading ? handleClose : undefined}
281+
onClick={!isLoading ? onCloseModal : undefined}
260282
>
261283
<CancelIcon fontSize="large" />
262284
</IconButton>
@@ -343,6 +365,7 @@ const CreateProjectModal = function (props: CreateProjectModalProps) {
343365
setPrebuildDataset={setPrebuildDataset}
344366
listPrebuildDataset={listPrebuildDataset}
345367
isLoadingPrebuildDataset={isLoadingPrebuildDataset}
368+
isCreatingProject={isLoading}
346369
/>
347370
</Box>
348371
);

src/components/CreateProjectModal/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface CreateProjectDatasetTypeControlProps
3939
setPrebuildDataset: (value: PrebuildDataset) => void;
4040
listPrebuildDataset: PrebuildDataset[];
4141
isLoadingPrebuildDataset: boolean;
42+
isCreatingProject: boolean;
4243
}
4344

4445
export interface CreateProjectPreBuildFields {

src/reduxes/project/reducer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ const projectReducer = (
371371
...(payload as CreateSampleSucceedPayload),
372372
groups: null,
373373
ls_task: [],
374-
is_sample: true,
375374
description: "",
376375
},
377376
],

src/reduxes/project/type.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export interface ProjectInfo {
5858
times_generated: number;
5959
groups: GroupProjectInfo;
6060
ls_task: Array<TaskInfo>;
61-
is_sample: boolean;
6261
gen_status: GENERATE_PROJECT_STATUS_TYPE;
6362
aug_parameters: AugmentParameterApiField;
6463
}
@@ -69,7 +68,6 @@ export interface ApiListProjectsItem {
6968
s3_prefix: string;
7069
ls_task: Array<TaskInfo>;
7170
groups: GroupProjectInfo;
72-
is_sample: boolean;
7371
gen_status: GENERATE_PROJECT_STATUS_TYPE;
7472
thum_key: string;
7573
description: string;
@@ -169,7 +167,6 @@ export interface CreateSampleSucceedPayload {
169167
project_id: string;
170168
project_name: string;
171169
s3_prefix: string;
172-
is_sample: boolean;
173170
gen_status: GENERATE_PROJECT_STATUS_TYPE;
174171
thum_key: string;
175172
}
@@ -248,7 +245,6 @@ export interface SetIsOpenUpdateProjectInfoPayload {
248245
export interface ApiUpdateProjectsInfo {
249246
project_id: string;
250247
s3_prefix: string;
251-
is_sample: boolean;
252248
gen_status: GENERATE_PROJECT_STATUS_TYPE;
253249
project_name: string;
254250
description: string;

src/routes/DashboardPage/index.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ const EmptyDashboardMessage = function ({
4242
return (
4343
<Box mt={projectCount <= 0 ? 12 : 4} textAlign="center">
4444
{projectCount <= 0 && (
45-
<Typography variant="h4" component="h1">
46-
👋 Welcome to DAITA, let's get started.
47-
</Typography>
45+
<>
46+
<Typography variant="h4" component="h1">
47+
👋 Welcome to DAITA, let's get started.
48+
</Typography>
49+
50+
<Typography sx={{ mt: 2 }}>
51+
👉 If you just want to play, you can create project with existing
52+
dataset. You don't have to upload any data!
53+
</Typography>
54+
</>
4855
)}
49-
<Typography sx={{ mt: 2 }}>
50-
👉 If you just want to play, you can create project with existing
51-
dataset. You don't have to upload any data!
52-
</Typography>
5356
{/* <Typography sx={{ mt: 2 }}>
5457
👉 If you just want to play, you can create a sandbox project{" "}
5558
<Box

src/routes/ProjectDetail/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ const ProjectDetail = function () {
103103
useEffect(() => {
104104
if (
105105
currentProjectInfo &&
106-
// currentProjectInfo.is_sample &&
107106
currentProjectInfo.gen_status === GENERATING_SAMPLE_PROJECT_STATUS
108107
) {
109108
const timer = setTimeout(() => {
@@ -296,7 +295,6 @@ const ProjectDetail = function () {
296295
const renderProject = () => {
297296
if (
298297
currentProjectInfo &&
299-
// currentProjectInfo.is_sample &&
300298
currentProjectInfo.gen_status === GENERATING_SAMPLE_PROJECT_STATUS
301299
) {
302300
return (

src/sagas/projectSaga.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ function* handleCreateProject(action: any): any {
6363
s3_prefix: createProjectResponse.data.s3_prefix,
6464
ls_task: [],
6565
groups: null,
66-
is_sample: createProjectResponse.data.is_sample,
6766
gen_status: createProjectResponse.data.gen_status,
6867
thum_key: "",
6968
description: "",
@@ -76,9 +75,7 @@ function* handleCreateProject(action: any): any {
7675
type: SET_IS_OPEN_CREATE_PROJECT_MODAL,
7776
payload: { isOpen: false },
7877
});
79-
toast.success(
80-
createProjectResponse.message || "Project successfully created."
81-
);
78+
toast.success("Project successfully created.");
8279
history.push(`/project/${encodeURIComponent(projectName)}`);
8380
} else {
8481
yield put({

0 commit comments

Comments
 (0)