Skip to content

Commit

Permalink
fix(upgrade): Fetch package from its installed cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
aanthonyrizzo authored and mecampbellsoup committed Oct 4, 2021
1 parent 322cc3d commit ef65b23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 8 additions & 2 deletions dashboard/src/components/UpgradeForm/UpgradeForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ it("fetches the available versions", () => {
Chart.getAvailablePackageVersions = getAvailablePackageVersions;
mountWrapper(defaultStore, <UpgradeForm {...defaultProps} />);
expect(getAvailablePackageVersions).toHaveBeenCalledWith({
context: { cluster: defaultProps.cluster, namespace: defaultProps.repoNamespace },
context: {
cluster: defaultProps.cluster,
namespace: defaultProps.repoNamespace,
},
identifier: defaultProps.packageId,
plugin: defaultProps.plugin,
} as AvailablePackageReference);
Expand Down Expand Up @@ -193,7 +196,10 @@ it("fetches the current chart version even if there is already one in the state"
);
expect(getAvailablePackageDetail).toHaveBeenCalledWith(
{
context: { cluster: defaultProps.cluster, namespace: defaultProps.repoNamespace },
context: {
cluster: availablePkgDetails[0].availablePackageRef?.context?.cluster,
namespace: defaultProps.repoNamespace,
},
identifier: defaultProps.packageId,
plugin: defaultProps.plugin,
} as AvailablePackageReference,
Expand Down
15 changes: 10 additions & 5 deletions dashboard/src/components/UpgradeForm/UpgradeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ function UpgradeForm({

const { availablePackageDetail, versions, schema, values, pkgVersion } = selected;

const packageCluster = availablePackageDetail?.availablePackageRef?.context?.cluster;

const {
apps: { isFetching: appsFetching },
charts: { isFetching: chartsFetching },
Expand All @@ -91,12 +93,15 @@ function UpgradeForm({
useEffect(() => {
dispatch(
actions.charts.fetchChartVersions({
context: { cluster: cluster, namespace: repoNamespace },
context: {
cluster: packageCluster ?? cluster,
namespace: repoNamespace,
},
plugin: pluginObj,
identifier: packageId,
} as AvailablePackageReference),
);
}, [dispatch, cluster, repoNamespace, packageId, pluginObj]);
}, [dispatch, packageCluster, repoNamespace, packageId, cluster, pluginObj]);

useEffect(() => {
if (deployed.values && !modifications) {
Expand All @@ -122,7 +127,7 @@ function UpgradeForm({
dispatch(
actions.charts.fetchChartVersion(
{
context: { cluster: cluster, namespace: repoNamespace },
context: { cluster: packageCluster, namespace: repoNamespace },
plugin: pluginObj,
identifier: packageId,
} as AvailablePackageReference,
Expand All @@ -131,7 +136,7 @@ function UpgradeForm({
);
}, [
dispatch,
cluster,
packageCluster,
repoNamespace,
packageId,
deployed.chartVersion?.version?.pkgVersion,
Expand Down Expand Up @@ -160,7 +165,7 @@ function UpgradeForm({
dispatch(
actions.charts.fetchChartVersion(
{
context: { cluster: cluster, namespace: repoNamespace },
context: { cluster: packageCluster, namespace: repoNamespace },
plugin: pluginObj,
identifier: packageId,
} as AvailablePackageReference,
Expand Down

0 comments on commit ef65b23

Please sign in to comment.