Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Artifact Upload Issues #100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
background-color: var(--silver-base-97);
}

.qwm-btn-modal {
color: #fdfdfe;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
border: solid 1px var(--blue-darken-62);
background-color: var(--blue-base-65);
}

.qwm-btn-save {
color: #fdfdfe;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@
top: 10px;
}

input,
select {
.qwm input,
.qwm select {
width: 100%;
box-sizing: border-box;
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,49 @@ export async function serviceTemplateExists(serviceTemplateName) {
)}/${encodeURIComponent(encodeURIComponent(serviceTemplateName))}`,
{
method: "GET",
headers: {
Accept: "application/json",
},
}
);
return response.status === 200;
}

export async function deleteTagByID(serviceTemplateAddress, tagID) {
const response = await fetch(
`${getWineryEndpoint()}/servicetemplates/${serviceTemplateAddress}tags/${tagID}`,
{
method: "DELETE",
headers: {
Accept: "application/json",
},
}
);
return response.status === 204;
}

export async function getTags(serviceTemplateAddress) {
const response = await fetch(
`${getWineryEndpoint()}/servicetemplates/${serviceTemplateAddress}tags/`,
{
method: "GET",
headers: {
Accept: "application/json",
},
}
);
return response.json();
}

export async function deleteTopNodeTag(serviceTemplateAddress) {
const tags = await getTags(serviceTemplateAddress);
const topNodeTag = tags.find((tag) => tag.name === "top-node");
if (topNodeTag) {
return deleteTagByID(serviceTemplateAddress, topNodeTag.id);
}
return true;
}

export async function addNodeWithArtifactToServiceTemplateByName(
serviceTemplateName,
nodeTypeQName,
Expand Down Expand Up @@ -325,11 +363,11 @@ const nodeTypeQNameMapping = new Map([
"{http://opentosca.org/nodetypes}TomcatApplication_WAR-w1",
],
[
"{http://opentosca.org/artifacttypes}WAR17",
"{http://opentosca.org/artifacttypes}WAR-Java17",
"{http://opentosca.org/nodetypes}TomcatApplication_WAR-w1",
],
[
"{http://opentosca.org/artifacttypes}WAR8",
"{http://opentosca.org/artifacttypes}WAR-Java8",
"{http://opentosca.org/nodetypes}TomcatApplication_WAR-w1",
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
serviceTemplateExists,
addNodeWithArtifactToServiceTemplateByName,
deleteArtifactTemplate,
deleteTopNodeTag,
} from "../../deployment/WineryUtils";
import NotificationHandler from "../../../../editor/ui/notifications/NotificationHandler";
import { getWineryEndpoint } from "../../framework-config/config-manager";
Expand Down Expand Up @@ -105,6 +106,7 @@ export default function ArtifactUploadModal({
const nodeTypeQName = getNodeTypeQName(selectedOption);
const serviceTemplateName = `${namePrefix}ServiceTemplate-${element.id}`;
const doesExist = await serviceTemplateExists(serviceTemplateName);
console.log("doesExist", doesExist);
if (doesExist) {
serviceTemplateAddress =
await addNodeWithArtifactToServiceTemplateByName(
Expand All @@ -115,6 +117,7 @@ export default function ArtifactUploadModal({
`${namePrefix}Artifact-${element.id}`,
selectedOption
);
await deleteTopNodeTag(serviceTemplateAddress);
} else {
serviceTemplateAddress = await createServiceTemplateWithNodeAndArtifact(
serviceTemplateName,
Expand Down Expand Up @@ -291,7 +294,7 @@ export default function ArtifactUploadModal({
<div id="upload-form-buttons">
<button
type="button"
className="qwm-btn qwm-btn-primary"
className="qwm-btn qwm-btn-modal"
form="upload-form"
onClick={onSubmit}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function YamlModal(props) {
<div id="wizardFormButtons">
<button
type="button"
className="qwm-btn qwm-btn-primary"
className="qwm-btn qwm-btn-modal"
form="configForm"
onClick={onSubmit}
>
Expand Down