From c8757441057117c026ce10cdadc0735522234aee Mon Sep 17 00:00:00 2001 From: alisonlhart Date: Wed, 4 Dec 2024 18:11:26 -0500 Subject: [PATCH] Fix create button enablement with autofilling project name --- .../contentCreator/createDevfilePageApp.ts | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/webview/apps/contentCreator/createDevfilePageApp.ts b/src/webview/apps/contentCreator/createDevfilePageApp.ts index 5d960df70..a574262f8 100644 --- a/src/webview/apps/contentCreator/createDevfilePageApp.ts +++ b/src/webview/apps/contentCreator/createDevfilePageApp.ts @@ -71,7 +71,6 @@ function main() { folderExplorerButton.addEventListener("click", openFolderExplorer); devfileCreateButton.addEventListener("click", handleCreateClick); - devfileCreateButton.disabled = true; devfileClearButton.addEventListener("click", handleResetClick); @@ -97,6 +96,15 @@ function main() { devfileNameTextField.value = devfileNameTextField.placeholder; + if ( + devfileNameTextField.value.trim() && + destinationPathUrlTextField.value.trim() + ) { + devfileCreateButton.disabled = false; + } else { + devfileCreateButton.disabled = true; + } + devfilePathDiv?.appendChild(devfilePathElement); } @@ -146,8 +154,7 @@ function toggleCreateButton() { if ( devfileNameTextField.value.trim() && - (destinationPathUrlTextField.value.trim() || - destinationPathUrlTextField.placeholder !== "") + destinationPathUrlTextField.value.trim() ) { devfileCreateButton.disabled = false; } else { @@ -157,7 +164,7 @@ function toggleCreateButton() { function handleResetClick() { destinationPathUrlTextField.value = destinationPathUrlTextField.placeholder; - devfileNameTextField.value = ""; + devfileNameTextField.value = devfileNameTextField.placeholder; if (destinationPathUrlTextField.placeholder !== "") { devfilePathElement.innerHTML = `${destinationPathUrlTextField.placeholder}/devfile.yaml`; @@ -170,7 +177,14 @@ function handleResetClick() { imageDropdown.currentValue = "Upstream (ghcr.io/ansible/ansible-workspace-env-reference:latest)"; - devfileCreateButton.disabled = true; + if ( + devfileNameTextField.value.trim() && + destinationPathUrlTextField.value.trim() + ) { + devfileCreateButton.disabled = false; + } else { + devfileCreateButton.disabled = true; + } } function handleCreateClick() {