Skip to content

Commit 078ecdd

Browse files
committed
clean up
1 parent 8c962f2 commit 078ecdd

File tree

2 files changed

+33
-48
lines changed

2 files changed

+33
-48
lines changed

web/src/components/apps/AvailableUpdatesComponent.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import ReactTooltip from "react-tooltip";
2-
31
import Icon from "@components/Icon";
42
import MountAware from "@components/shared/MountAware";
53
import { AirgapUploader } from "@src/utilities/airgapUploader";
64
import { Utilities } from "@src/utilities/utilities";
75
import { AvailableUpdate } from "@types";
6+
import ReactTooltip from "react-tooltip";
87

98
const AvailableUpdatesComponent = ({
109
updates,
@@ -115,7 +114,6 @@ const AvailableUpdatesComponent = ({
115114
/>
116115
</>
117116
)}
118-
119117
<button
120118
className={"btn tw-ml-2 primary blue"}
121119
onClick={() => startUpgradeService(update)}
@@ -130,7 +128,6 @@ const AvailableUpdatesComponent = ({
130128
{isCurrentVersionLoading ? "Preparing..." : "Deploy"}
131129
</span>
132130
</button>
133-
134131
<ReactTooltip
135132
effect="solid"
136133
id="disable-deployment-tooltip"

web/src/features/Dashboard/components/DashboardVersionCard.tsx

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ type Props = {
4343
adminConsoleMetadata: Metadata | null;
4444
airgapUploader: AirgapUploader | null;
4545
airgapUploadError: string | null;
46-
4746
checkingForUpdates: boolean;
4847
checkingForUpdateError: boolean;
4948
checkingUpdateText: string;
@@ -181,6 +180,32 @@ const DashboardVersionCard = (props: Props) => {
181180
} = useNextAppVersionWithIntercept();
182181
const { latestDeployableVersion } = newAppVersionWithInterceptData || {};
183182

183+
const fetchAvailableUpdates = async () => {
184+
const appSlug = params.slug;
185+
setState({ isFetchingAvailableUpdates: true });
186+
const res = await fetch(
187+
`${process.env.API_ENDPOINT}/app/${appSlug}/updates`,
188+
{
189+
headers: {
190+
"Content-Type": "application/json",
191+
},
192+
credentials: "include",
193+
method: "GET",
194+
}
195+
);
196+
if (!res.ok) {
197+
setState({ isFetchingAvailableUpdates: false });
198+
return;
199+
}
200+
const response = await res.json();
201+
202+
setState({
203+
isFetchingAvailableUpdates: false,
204+
availableUpdates: response.updates,
205+
});
206+
return response;
207+
};
208+
184209
// moving this out of the state because new repeater instances were getting created
185210
// and it doesn't really affect the UI
186211
const versionDownloadStatusJobs: {
@@ -1413,33 +1438,6 @@ const DashboardVersionCard = (props: Props) => {
14131438
);
14141439
};
14151440

1416-
const fetchAvailableUpdates = async () => {
1417-
const appSlug = params.slug;
1418-
setState({ isFetchingAvailableUpdates: true });
1419-
const res = await fetch(
1420-
`${process.env.API_ENDPOINT}/app/${appSlug}/updates`,
1421-
{
1422-
headers: {
1423-
"Content-Type": "application/json",
1424-
},
1425-
credentials: "include",
1426-
method: "GET",
1427-
}
1428-
);
1429-
if (!res.ok) {
1430-
setState({ isFetchingAvailableUpdates: false });
1431-
return;
1432-
}
1433-
const response = await res.json();
1434-
1435-
setState({
1436-
isFetchingAvailableUpdates: false,
1437-
// only show the most recent available update
1438-
availableUpdates: response.updates,
1439-
});
1440-
return response;
1441-
};
1442-
14431441
const {
14441442
currentVersion,
14451443
checkingForUpdates,
@@ -1594,24 +1592,14 @@ const DashboardVersionCard = (props: Props) => {
15941592
)}
15951593
{props.adminConsoleMetadata?.isEmbeddedCluster &&
15961594
state.availableUpdates?.length > 0 && (
1597-
<>
1598-
{state.isFetchingAvailableUpdates ? (
1599-
<div className="flex-column flex1 alignItems--center justifyContent--center">
1600-
<Loader size="30" />
1601-
</div>
1602-
) : (
1603-
<AvailableUpdateCard
1604-
updates={state.availableUpdates}
1605-
showReleaseNotes={showReleaseNotes}
1606-
upgradeService={state.upgradeService}
1607-
appSlug={params.slug}
1608-
/>
1609-
)}
1610-
</>
1595+
<AvailableUpdateCard
1596+
updates={state.availableUpdates}
1597+
showReleaseNotes={showReleaseNotes}
1598+
upgradeService={state.upgradeService}
1599+
appSlug={params.slug}
1600+
/>
16111601
)}
1612-
16131602
{renderBottomSection()}
1614-
16151603
<div className="u-marginTop--10">
16161604
<Link
16171605
to={`/app/${selectedApp?.slug}/version-history`}

0 commit comments

Comments
 (0)