Skip to content

Commit adaecb5

Browse files
chestofwondersbrianchandotcom
authored andcommitted
LPD-68115 Fix behaviour issues detected on the dataset creation
1 parent 4f97204 commit adaecb5

File tree

1 file changed

+28
-12
lines changed
  • modules/apps/frontend-data-set/frontend-data-set-admin-web/src/main/resources/META-INF/resources/js

1 file changed

+28
-12
lines changed

modules/apps/frontend-data-set/frontend-data-set-admin-web/src/main/resources/META-INF/resources/js/CustomDataSets.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const NewDataSetModalContent = ({
9797
noEnpointsRESTApplicationValidationError,
9898
setNoEnpointsRESTApplicationValidationError,
9999
] = useState(false);
100+
const [restSchemaLoading, setRestSchemaLoading] = useState(false);
100101
const [restSchemaValidationError, setRESTSchemaValidationError] =
101102
useState(false);
102103
const [restEndpointValidationError, setRESTEndpointValidationError] =
@@ -186,10 +187,14 @@ const NewDataSetModalContent = ({
186187
return;
187188
}
188189

190+
setRestSchemaLoading(true);
191+
189192
const response = await fetch(`/o${restApplication}/openapi.json`, {
190193
headers: DEFAULT_FETCH_HEADERS,
191194
});
192195

196+
setRestSchemaLoading(false);
197+
193198
if (!response.ok) {
194199
openDefaultFailureToast();
195200

@@ -245,15 +250,11 @@ const NewDataSetModalContent = ({
245250
if (paths?.length === 1) {
246251
setSelectedRESTEndpoint(paths[0]);
247252
}
248-
249-
setNoEnpointsRESTApplicationValidationError(false);
250253
}
251254
else {
252255
setSelectedRESTSchema(null);
253256

254257
setSelectedRESTEndpoint(null);
255-
256-
setNoEnpointsRESTApplicationValidationError(false);
257258
}
258259

259260
setRESTSchemaEndpoints(schemaEndpoints);
@@ -300,6 +301,7 @@ const NewDataSetModalContent = ({
300301
<ClayButton
301302
aria-labelledby={`${namespace}restApplicationsLabel`}
302303
className="form-control form-control-select form-control-select-secondary"
304+
disabled={restSchemaLoading}
303305
displayType="secondary"
304306
id={`${namespace}restApplicationsSelect`}
305307
>
@@ -318,6 +320,8 @@ const NewDataSetModalContent = ({
318320
onItemClick={(item: string) => {
319321
setSelectedRESTApplication(item);
320322

323+
setNoEnpointsRESTApplicationValidationError(false);
324+
321325
setRequiredRESTApplicationValidationError(false);
322326

323327
getRESTSchemas(item, resolvedRESTSchemas);
@@ -336,14 +340,21 @@ const NewDataSetModalContent = ({
336340
<ClayButton
337341
aria-labelledby={`${namespace}restSchema`}
338342
className="form-control form-control-select form-control-select-secondary"
339-
disabled={!selectedRESTApplication}
343+
disabled={
344+
!selectedRESTApplication ||
345+
!restSchemaEndpoints.size ||
346+
restSchemaLoading
347+
}
340348
displayType="secondary"
341349
id={`${namespace}restSchemaSelect`}
342350
>
343-
{selectedRESTSchema ||
344-
Liferay.Language.get(
345-
'choose-a-rest-application-to-enable-this'
346-
)}
351+
{selectedRESTSchema
352+
? selectedRESTSchema
353+
: selectedRESTApplication
354+
? Liferay.Language.get('choose-an-option')
355+
: Liferay.Language.get(
356+
'choose-a-rest-application-to-enable-this'
357+
)}
347358
</ClayButton>
348359
}
349360
>
@@ -376,12 +387,17 @@ const NewDataSetModalContent = ({
376387
<ClayButton
377388
aria-labelledby={`${namespace}restEndpoint`}
378389
className="form-control form-control-select form-control-select-secondary"
379-
disabled={!selectedRESTSchema}
390+
disabled={!selectedRESTSchema || restSchemaLoading}
380391
displayType="secondary"
381392
id={`${namespace}restEndpointSelect`}
382393
>
383-
{selectedRESTEndpoint ||
384-
Liferay.Language.get('choose-a-schema-to-enable-this')}
394+
{selectedRESTEndpoint
395+
? selectedRESTEndpoint
396+
: selectedRESTSchema
397+
? Liferay.Language.get('choose-an-option')
398+
: Liferay.Language.get(
399+
'choose-a-schema-to-enable-this'
400+
)}
385401
</ClayButton>
386402
}
387403
>

0 commit comments

Comments
 (0)