Skip to content

Commit

Permalink
Fix Artifact Upload Issues (#100)
Browse files Browse the repository at this point in the history
* Remove top node before adding new.

Also includes name updates to keep supporting WAR-17 and 8

* fix button layout

* Run linter

---------

Co-authored-by: LaviniaStiliadou <livia_16@live.de>
Co-authored-by: Benjamin Weder <benjamin.weder@iaas.uni-stuttgart.de>
  • Loading branch information
3 people authored Oct 25, 2023
1 parent ebea8b4 commit 7b57b9c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
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

0 comments on commit 7b57b9c

Please sign in to comment.