Skip to content

Commit

Permalink
Update creator webviews to reflect ansible-creator CLI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonlhart committed Oct 13, 2024
1 parent 8d493f2 commit ecf5b41
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
4 changes: 2 additions & 2 deletions media/contentCreator/createAnsibleProjectPageStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ vscode-text-area {
margin-bottom: 6px;
}

.scm-org-project-div {
.playbook-project-div {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}

#scm-org-name, #scm-project-name {
#namespace-name, #collection-name {
width:49%;
display:inline-block;
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/contentCreator/createAnsibleCollectionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class CreateAnsibleCollection {
? initPath
: `${os.homedir()}/.ansible/collections/ansible_collections`;

let ansibleCreatorInitCommand = `ansible-creator init ${namespaceName}.${collectionName} --init-path=${initPathUrl} --no-ansi`;
let ansibleCreatorInitCommand = `ansible-creator init collection ${namespaceName}.${collectionName} ${initPathUrl} --no-ansi`;

// adjust collection url for using it in ade and opening it in workspace
// NOTE: this is done in order to synchronize the behavior of ade and extension
Expand Down
15 changes: 7 additions & 8 deletions src/features/contentCreator/createAnsibleProjectPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export class CreateAnsibleProject {
</section>
</vscode-text-field>
<div class="scm-org-project-div">
<vscode-text-field id="scm-org-name" form="init-form" placeholder="Enter scm organization name" size="512">SCM organization *</vscode-text-field>
<vscode-text-field id="scm-project-name" form="init-form" placeholder="Enter scm project name" size="512">SCM project *</vscode-text-field>
<div class="playbook-project-div">
<vscode-text-field id="namespace-name" form="init-form" placeholder="Enter namespace name" size="512">Namespace*</vscode-text-field>
<vscode-text-field id="collection-name" form="init-form" placeholder="Enter collection name" size="512">Collection*</vscode-text-field>
</div>
<div id="full-collection-path" class="full-collection-path">
Expand Down Expand Up @@ -304,8 +304,8 @@ export class CreateAnsibleProject {
) {
const {
destinationPath,
scmOrgName,
scmProjectName,
namespaceName,
collectionName,
logToFile,
logFilePath,
logFileAppend,
Expand All @@ -316,9 +316,8 @@ export class CreateAnsibleProject {

const destinationPathUrl = destinationPath
? destinationPath
: `${os.homedir()}/${scmOrgName}-${scmProjectName}`;

let ansibleCreatorInitCommand = `ansible-creator init --project=ansible-project --init-path=${destinationPathUrl} --scm-org=${scmOrgName} --scm-project=${scmProjectName} --no-ansi`;
: `${os.homedir()}/${namespaceName}-${collectionName}`;
let ansibleCreatorInitCommand = `ansible-creator init playbook ${namespaceName}.${collectionName} ${destinationPathUrl} --no-ansi`;

if (isForced) {
ansibleCreatorInitCommand += " --force";
Expand Down
4 changes: 2 additions & 2 deletions src/features/contentCreator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export type AnsibleCollectionFormInterface = {

export type AnsibleProjectFormInterface = {
destinationPath: string;
scmOrgName: string;
scmProjectName: string;
namespaceName: string;
collectionName: string;
verbosity: string;
logToFile: boolean;
logFilePath: string;
Expand Down
34 changes: 18 additions & 16 deletions src/webview/apps/contentCreator/createAnsibleProjectPageApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ window.addEventListener("load", main);
let destinationPathUrlTextField: TextField;
let folderExplorerButton: Button;

let scmOrgNameTextField: TextField;
let scmProjectNameTextField: TextField;
let namespaceNameTextField: TextField;
let collectionNameTextField: TextField;

let initCreateButton: Button;
let initClearButton: Button;
Expand Down Expand Up @@ -59,9 +59,11 @@ function main() {
) as TextField;
folderExplorerButton = document.getElementById("folder-explorer") as Button;

scmOrgNameTextField = document.getElementById("scm-org-name") as TextField;
scmProjectNameTextField = document.getElementById(
"scm-project-name",
namespaceNameTextField = document.getElementById(
"namespace-name",
) as TextField;
collectionNameTextField = document.getElementById(
"collection-name",
) as TextField;

forceCheckbox = document.getElementById("force-checkbox") as Checkbox;
Expand Down Expand Up @@ -96,8 +98,8 @@ function main() {

// projectNameTextField?.addEventListener("input", toggleCreateButton);
destinationPathUrlTextField.addEventListener("input", toggleCreateButton);
scmOrgNameTextField.addEventListener("input", toggleCreateButton);
scmProjectNameTextField.addEventListener("input", toggleCreateButton);
namespaceNameTextField.addEventListener("input", toggleCreateButton);
collectionNameTextField.addEventListener("input", toggleCreateButton);

folderExplorerButton.addEventListener("click", openExplorer);
fileExplorerButton.addEventListener("click", openExplorer);
Expand Down Expand Up @@ -166,11 +168,11 @@ function toggleCreateButton() {
if (!destinationPathUrlTextField.value.trim()) {
initCollectionPathElement.innerHTML = `${
destinationPathUrlTextField.placeholder
}/${scmOrgNameTextField.value.trim()}-${scmProjectNameTextField.value.trim()}`;
}/${namespaceNameTextField.value.trim()}-${collectionNameTextField.value.trim()}`;

if (
!scmOrgNameTextField.value.trim() ||
!scmProjectNameTextField.value.trim()
!namespaceNameTextField.value.trim() ||
!collectionNameTextField.value.trim()
) {
initCollectionPathElement.innerHTML =
destinationPathUrlTextField.placeholder;
Expand All @@ -181,8 +183,8 @@ function toggleCreateButton() {
}

if (
scmOrgNameTextField.value.trim() &&
scmProjectNameTextField.value.trim()
namespaceNameTextField.value.trim() &&
collectionNameTextField.value.trim()
) {
initCreateButton.disabled = false;
} else {
Expand All @@ -193,8 +195,8 @@ function toggleCreateButton() {
function handleInitClearClick() {
// projectNameTextField.value = "";
destinationPathUrlTextField.value = "";
scmOrgNameTextField.value = "";
scmProjectNameTextField.value = "";
namespaceNameTextField.value = "";
collectionNameTextField.value = "";

initCollectionPathElement.innerHTML = destinationPathUrlTextField.placeholder;

Expand Down Expand Up @@ -232,8 +234,8 @@ function handleInitCreateClick() {
payload: {
// projectName: projectNameTextField.value.trim(),
destinationPath: destinationPathUrlTextField.value.trim(),
scmOrgName: scmOrgNameTextField.value.trim(),
scmProjectName: scmProjectNameTextField.value.trim(),
namespaceName: namespaceNameTextField.value.trim(),
collectionName: collectionNameTextField.value.trim(),
verbosity: verboseDropdown.currentValue.trim(),
logToFile: logToFileCheckbox.checked,
logFilePath: logFilePath.value.trim(),
Expand Down

0 comments on commit ecf5b41

Please sign in to comment.