Skip to content

Commit

Permalink
Fix create button enablement with autofilling project name
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonlhart committed Dec 4, 2024
1 parent 907e667 commit c875744
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/webview/apps/contentCreator/createDevfilePageApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function main() {
folderExplorerButton.addEventListener("click", openFolderExplorer);

devfileCreateButton.addEventListener("click", handleCreateClick);
devfileCreateButton.disabled = true;

devfileClearButton.addEventListener("click", handleResetClick);

Expand All @@ -97,6 +96,15 @@ function main() {

devfileNameTextField.value = devfileNameTextField.placeholder;

if (
devfileNameTextField.value.trim() &&
destinationPathUrlTextField.value.trim()
) {
devfileCreateButton.disabled = false;

Check warning on line 103 in src/webview/apps/contentCreator/createDevfilePageApp.ts

View check run for this annotation

Codecov / codecov/patch

src/webview/apps/contentCreator/createDevfilePageApp.ts#L103

Added line #L103 was not covered by tests
} else {
devfileCreateButton.disabled = true;

Check warning on line 105 in src/webview/apps/contentCreator/createDevfilePageApp.ts

View check run for this annotation

Codecov / codecov/patch

src/webview/apps/contentCreator/createDevfilePageApp.ts#L105

Added line #L105 was not covered by tests
}

devfilePathDiv?.appendChild(devfilePathElement);
}

Expand Down Expand Up @@ -146,8 +154,7 @@ function toggleCreateButton() {

if (
devfileNameTextField.value.trim() &&
(destinationPathUrlTextField.value.trim() ||
destinationPathUrlTextField.placeholder !== "")
destinationPathUrlTextField.value.trim()
) {
devfileCreateButton.disabled = false;
} else {
Expand All @@ -157,7 +164,7 @@ function toggleCreateButton() {

function handleResetClick() {
destinationPathUrlTextField.value = destinationPathUrlTextField.placeholder;
devfileNameTextField.value = "";
devfileNameTextField.value = devfileNameTextField.placeholder;

Check warning on line 167 in src/webview/apps/contentCreator/createDevfilePageApp.ts

View check run for this annotation

Codecov / codecov/patch

src/webview/apps/contentCreator/createDevfilePageApp.ts#L167

Added line #L167 was not covered by tests

if (destinationPathUrlTextField.placeholder !== "") {
devfilePathElement.innerHTML = `${destinationPathUrlTextField.placeholder}/devfile.yaml`;
Expand All @@ -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;

Check warning on line 184 in src/webview/apps/contentCreator/createDevfilePageApp.ts

View check run for this annotation

Codecov / codecov/patch

src/webview/apps/contentCreator/createDevfilePageApp.ts#L184

Added line #L184 was not covered by tests
} else {
devfileCreateButton.disabled = true;

Check warning on line 186 in src/webview/apps/contentCreator/createDevfilePageApp.ts

View check run for this annotation

Codecov / codecov/patch

src/webview/apps/contentCreator/createDevfilePageApp.ts#L186

Added line #L186 was not covered by tests
}
}

function handleCreateClick() {
Expand Down

0 comments on commit c875744

Please sign in to comment.