From bdfe8a21f355ec78067ba07830cc444be37f99d2 Mon Sep 17 00:00:00 2001 From: Imran Farhat Date: Wed, 17 Jun 2026 16:44:44 +0530 Subject: [PATCH] fix: add validation to LTI URL generation Clicking the LTI URL generation button with empty fields did nothing visible. handleLTIGenerate accessed ltiDetails.modelSchematic.id even when modelSchematic was unset, causing a silent failure (an unhandled error in the console, no feedback on screen). Fix: - Added a check for missing consumer key or secret key - Added a check for a missing/incomplete schematic selection - Both show a clear error message via the existing consumerError display Testing: - Clicking the generate button with all fields empty now shows 'Consumer Key and Secret Key are required.' - Filling in keys but leaving the schematic unselected shows 'Please select a schematic before generating LTI URL.' - Filling in all fields correctly still generates the LTI URL as expected --- eda-frontend/src/components/LTI/LTI.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eda-frontend/src/components/LTI/LTI.js b/eda-frontend/src/components/LTI/LTI.js index 5f8f585e..30d259c3 100644 --- a/eda-frontend/src/components/LTI/LTI.js +++ b/eda-frontend/src/components/LTI/LTI.js @@ -203,6 +203,14 @@ export default function LTIConfig () { // eslint-disable-next-line const handleLTIGenerate = () => { + if (!ltiDetails.consumerKey || !ltiDetails.secretKey) { + setLTIDetails({ ...ltiDetails, consumerError: 'Consumer Key and Secret Key are required.' }) + return + } + if (!ltiDetails.modelSchematic || !ltiDetails.modelSchematic.id) { + setLTIDetails({ ...ltiDetails, consumerError: 'Please select a schematic before generating LTI URL.' }) + return + } var score = '' if (!ltiDetails.scored) { score = null