Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Dec 19, 2024
1 parent d87ac0a commit 5c0276d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 57 deletions.
30 changes: 18 additions & 12 deletions web/src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,13 @@ const Root = () => {
if (state.adminConsoleMetadata?.isEC2Install) {
url = `${process.env.API_ENDPOINT}/app/${appSlug}/ec2-deploy/status`;
}
const res = await fetch(url,
{
headers: {
"Content-Type": "application/json",
},
credentials: "include",
method: "GET",
}
);
const res = await fetch(url, {
headers: {
"Content-Type": "application/json",
},
credentials: "include",
method: "GET",
});
if (!res.ok) {
if (res.status === 401) {
Utilities.logoutUser();
Expand All @@ -307,9 +305,15 @@ const Root = () => {

let showModal = false;
if (state.adminConsoleMetadata?.isEC2Install) {
showModal = status !== "" && status !== "complete" && response.step !== "app-upgrade-service";
showModal =
status !== "" &&
status !== "complete" &&
response.step !== "app-upgrade-service";
} else {
showModal = status === "upgrading-cluster" || status === "upgrading-app" || status === "upgrade-failed";
showModal =
status === "upgrading-cluster" ||
status === "upgrading-app" ||
status === "upgrade-failed";
}
if (showModal) {
setState({
Expand Down Expand Up @@ -1210,7 +1214,9 @@ const Root = () => {
isOpen={state.showUpgradeStatusModal}
onRequestClose={() => {
// cannot close the modal while upgrading
const failedStatus = state.adminConsoleMetadata?.isEC2Install ? "failed" : "upgrade-failed";
const failedStatus = state.adminConsoleMetadata?.isEC2Install
? "failed"
: "upgrade-failed";
if (state.upgradeStatus === failedStatus) {
setState({ showUpgradeStatusModal: false });
}
Expand Down
72 changes: 38 additions & 34 deletions web/src/components/apps/AppVersionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1033,22 +1033,21 @@ class AppVersionHistory extends Component<Props, State> {
if (adminConsoleMetadata?.isEC2Install) {
url = `${process.env.API_ENDPOINT}/app/${app?.slug}/ec2-deploy/status`;
}
fetch(
url,
{
headers: {
"Content-Type": "application/json",
},
credentials: "include",
method: "GET",
}
)
fetch(url, {
headers: {
"Content-Type": "application/json",
},
credentials: "include",
method: "GET",
})
.then(async (res) => {
const response = await res.json();

let stopPolling = response.status !== "starting";
if (adminConsoleMetadata?.isEC2Install) {
stopPolling = response.step !== "app-upgrade-service" || (response.status !== "pending" && response.status !== "starting");
stopPolling =
response.step !== "app-upgrade-service" ||
(response.status !== "pending" && response.status !== "starting");
}

if (stopPolling) {
Expand Down Expand Up @@ -1896,7 +1895,7 @@ class AppVersionHistory extends Component<Props, State> {
this.handleViewLogs(
currentDownstreamVersion,
currentDownstreamVersion?.status ===
"failed"
"failed"
)
}
data-tip="View deploy logs"
Expand Down Expand Up @@ -1957,17 +1956,19 @@ class AppVersionHistory extends Component<Props, State> {
)}

<div
className={`flex-column flex1 alignSelf--start ${gitopsIsConnected ? "gitops-enabled" : ""
}`}
className={`flex-column flex1 alignSelf--start ${
gitopsIsConnected ? "gitops-enabled" : ""
}`}
>
<div
className={`flex-column flex1 version ${showDiffOverlay ? "u-visibility--hidden" : ""
}`}
className={`flex-column flex1 version ${
showDiffOverlay ? "u-visibility--hidden" : ""
}`}
>
{(versionHistory.length === 0 && gitopsIsConnected) ||
versionHistory?.length > 0 ||
(this.state.availableUpdates &&
this.state.availableUpdates?.length > 0) ? (
versionHistory?.length > 0 ||
(this.state.availableUpdates &&
this.state.availableUpdates?.length > 0) ? (
<div>
{gitopsIsConnected && (
<div
Expand Down Expand Up @@ -2022,8 +2023,8 @@ class AppVersionHistory extends Component<Props, State> {
) : (
<div className="flex alignItems--center">
{checkingForUpdates &&
!this.props.outletContext
.isBundleUploading ? (
!this.props.outletContext
.isBundleUploading ? (
<div className="flex alignItems--center u-marginRight--20">
<Loader
className="u-marginRight--5"
Expand Down Expand Up @@ -2090,20 +2091,23 @@ class AppVersionHistory extends Component<Props, State> {
)}
{(this.state.numOfSkippedVersions > 0 ||
this.state.numOfRemainingVersions > 0) && (
<p className="u-fontSize--small u-fontWeight--medium u-lineHeight--more u-textColor--info u-marginTop--10">
{this.state.numOfSkippedVersions > 0
? `${this.state.numOfSkippedVersions
} version${this.state.numOfSkippedVersions > 1
? "s"
: ""
} will be skipped in upgrading to ${versionHistory[0].versionLabel
<p className="u-fontSize--small u-fontWeight--medium u-lineHeight--more u-textColor--info u-marginTop--10">
{this.state.numOfSkippedVersions > 0
? `${
this.state.numOfSkippedVersions
} version${
this.state.numOfSkippedVersions > 1
? "s"
: ""
} will be skipped in upgrading to ${
versionHistory[0].versionLabel
}. `
: ""}
{this.state.numOfRemainingVersions > 0
? "Additional versions are available after you deploy this required version."
: ""}
</p>
)}
: ""}
{this.state.numOfRemainingVersions > 0
? "Additional versions are available after you deploy this required version."
: ""}
</p>
)}
</div>
)}

Expand Down
20 changes: 9 additions & 11 deletions web/src/components/upgrade_service/hooks/postDeployAppVersion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ async function postDeployAppVersion({
if (isEC2Install) {
url = `${process.env.API_ENDPOINT}/upgrade-service/app/${slug}/ec2-deploy`;
}
const response = await fetch(url,
{
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
credentials: "include",
method: "POST",
body,
}
);
const response = await fetch(url, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
credentials: "include",
method: "POST",
body,
});

if (!response.ok) {
throw new Error(
Expand Down

0 comments on commit 5c0276d

Please sign in to comment.