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

Revert "App upgrade notification shown for incorrect app (#9806)" #9958

Merged
merged 1 commit into from
Oct 20, 2023
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
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"storageclass",
"testid",
"tolerations",
"upgrader",
"userpreferences",
"virtualmachine",
"vuex",
Expand Down
2 changes: 0 additions & 2 deletions shell/config/os.ts

This file was deleted.

2 changes: 1 addition & 1 deletion shell/edit/provisioning.cattle.io.cluster/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { mapGetters } from 'vuex';
import { sortBy } from '@shell/utils/sort';
import { set } from '@shell/utils/object';
import { mapPref, PROVISIONER, _RKE1, _RKE2 } from '@shell/store/prefs';
import { filterAndArrangeCharts } from '@shell/utils/chart';
import { filterAndArrangeCharts } from '@shell/store/catalog';
import { CATALOG } from '@shell/config/labels-annotations';
import { CAPI, MANAGEMENT, DEFAULT_WORKSPACE } from '@shell/config/types';
import { mapFeature, RKE2 as RKE2_FEATURE } from '@shell/store/features';
Expand Down
2 changes: 1 addition & 1 deletion shell/mixins/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { formatSi, parseSi } from '@shell/utils/units';
import { CAPI, CATALOG } from '@shell/config/types';
import { isPrerelease } from '@shell/utils/version';
import difference from 'lodash/difference';
import { LINUX } from '@shell/config/os';
import { LINUX } from '@shell/store/catalog';
import { clone } from '@shell/utils/object';
import { merge } from 'lodash';

Expand Down
80 changes: 0 additions & 80 deletions shell/models/__tests__/catalog.cattle.io.app.test.ts

This file was deleted.

74 changes: 47 additions & 27 deletions shell/models/catalog.cattle.io.app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/* eslint-disable multiline-ternary */
import {
NAMESPACE, NAME, REPO, REPO_TYPE, CHART, VERSION, _VIEW, FROM_TOOLS, _FLAGGED
} from '@shell/config/query-params';
import { CATALOG as CATALOG_ANNOTATIONS, FLEET } from '@shell/config/labels-annotations';
import { compare, isPrerelease, sortable } from '@shell/utils/version';
import { compatibleVersionsFor } from '@shell/utils/chart';
import { filterBy } from '@shell/utils/array';
import { CATALOG, MANAGEMENT, NORMAN } from '@shell/config/types';
import { SHOW_PRE_RELEASE } from '@shell/store/prefs';
import { set } from '@shell/utils/object';

import SteveModel from '@shell/plugins/steve/steve-class';
import { compatibleVersionsFor } from '@shell/store/catalog';

export default class CatalogApp extends SteveModel {
showMasthead(mode) {
Expand Down Expand Up @@ -41,48 +40,69 @@ export default class CatalogApp extends SteveModel {
}

matchingChart(includeHidden) {
return this.$rootGetters['catalog/chart']({
chart: this.spec?.chart,
const chart = this.spec?.chart;

if ( !chart ) {
return;
}

const chartName = chart.metadata?.name;
const preferRepoType = chart.metadata?.annotations?.[CATALOG_ANNOTATIONS.SOURCE_REPO_TYPE];
const preferRepoName = chart.metadata?.annotations?.[CATALOG_ANNOTATIONS.SOURCE_REPO_NAME];
const match = this.$rootGetters['catalog/chart']({
chartName,
preferRepoType,
preferRepoName,
includeHidden
});

return match;
}

get currentVersion() {
return this.spec?.chart?.metadata?.version;
}

/**
* Return possible upgrades
* false = does not apply (managed by fleet)
* null = no upgrade found
* string = version available to upgrade to
*/
get upgradeAvailable() {
// Things managed by fleet shouldn't show upgrade available even if there might be.
const isManaged = this.spec?.chart?.metadata?.annotations?.[CATALOG_ANNOTATIONS.MANAGED] ||
this.spec?.chart?.metadata?.annotations?.[FLEET.BUNDLE_ID];

if (isManaged) {
// false = does not apply (managed by fleet)
// null = no upgrade found
// object = version available to upgrade to

if (
this.spec?.chart?.metadata?.annotations?.[CATALOG_ANNOTATIONS.MANAGED] ||
this.spec?.chart?.metadata?.annotations?.[FLEET.BUNDLE_ID]
) {
// Things managed by fleet shouldn't show upgrade available even if there might be.
return false;
}
const chart = this.matchingChart(false);

const matchingChart = this.matchingChart(false);

if ( !matchingChart ) {
if ( !chart ) {
return null;
}

const workerOSs = this.$rootGetters['currentCluster'].workerOSs;

const showPreRelease = this.$rootGetters['prefs/get'](SHOW_PRE_RELEASE);
const currentChartVersion = this.spec?.chart?.metadata?.version;
const versions = !showPreRelease
? matchingChart.versions?.filter((v) => !isPrerelease(v.version))
: compatibleVersionsFor(matchingChart, workerOSs, showPreRelease);
const newChartVersion = versions?.[0]?.version;
const isOlder = compare(currentChartVersion, newChartVersion) < 0;

if ( isOlder ) {
return cleanupVersion(newChartVersion);

const thisVersion = this.spec?.chart?.metadata?.version;
let versions = chart.versions;

if (!showPreRelease) {
versions = chart.versions.filter((v) => !isPrerelease(v.version));
}

versions = compatibleVersionsFor(chart, workerOSs, showPreRelease);

const newestChart = versions?.[0];
const newestVersion = newestChart?.version;

if ( !thisVersion || !newestVersion ) {
return null;
}

if ( compare(thisVersion, newestVersion) < 0 ) {
return cleanupVersion(newestVersion);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion shell/models/chart.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compatibleVersionsFor } from '@shell/utils/chart';
import { compatibleVersionsFor } from '@shell/store/catalog';
import {
REPO_TYPE, REPO, CHART, VERSION, _FLAGGED, HIDE_SIDE_NAV
} from '@shell/config/query-params';
Expand Down
2 changes: 1 addition & 1 deletion shell/models/management.cattle.io.cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isEmpty } from '@shell/utils/object';
import { HARVESTER_NAME as HARVESTER } from '@shell/config/features';
import { isHarvesterCluster } from '@shell/utils/cluster';
import HybridModel from '@shell/plugins/steve/hybrid-class';
import { LINUX, WINDOWS } from '@shell/config/os';
import { LINUX, WINDOWS } from '@shell/store/catalog';
import { KONTAINER_TO_DRIVER } from './management.cattle.io.kontainerdriver';
import { PINNED_CLUSTERS } from '@shell/store/prefs';

Expand Down
2 changes: 1 addition & 1 deletion shell/pages/c/_cluster/apps/charts/chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DateFormatter from '@shell/components/formatter/Date';
import isEqual from 'lodash/isEqual';
import { CHART, REPO, REPO_TYPE, VERSION } from '@shell/config/query-params';
import { mapGetters } from 'vuex';
import { compatibleVersionsFor } from '@shell/utils/chart';
import { compatibleVersionsFor } from '@shell/store/catalog';
import TypeDescription from '@shell/components/TypeDescription';
export default {
components: {
Expand Down
2 changes: 1 addition & 1 deletion shell/pages/c/_cluster/apps/charts/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Checkbox } from '@components/Form/Checkbox';
import Select from '@shell/components/form/Select';
import { mapPref, HIDE_REPOS, SHOW_PRE_RELEASE, SHOW_CHART_MODE } from '@shell/store/prefs';
import { removeObject, addObject, findBy } from '@shell/utils/array';
import { compatibleVersionsFor, filterAndArrangeCharts } from '@shell/utils/chart';
import { compatibleVersionsFor, filterAndArrangeCharts } from '@shell/store/catalog';
import { CATALOG } from '@shell/config/labels-annotations';
import { isUIPlugin } from '@shell/config/uiplugins';

Expand Down
2 changes: 1 addition & 1 deletion shell/pages/c/_cluster/apps/charts/install.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { ignoreVariables } from './install.helpers';
import { findBy, insertAt } from '@shell/utils/array';
import Vue from 'vue';
import { saferDump } from '@shell/utils/create-yaml';
import { LINUX, WINDOWS } from '@shell/config/os';
import { LINUX, WINDOWS } from '@shell/store/catalog';

const VALUES_STATE = {
FORM: 'FORM',
Expand Down
2 changes: 1 addition & 1 deletion shell/pages/c/_cluster/explorer/tools/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { mapGetters } from 'vuex';
import Loading from '@shell/components/Loading';
import { _FLAGGED, DEPRECATED, HIDDEN, FROM_TOOLS } from '@shell/config/query-params';
import { filterAndArrangeCharts } from '@shell/utils/chart';
import { filterAndArrangeCharts } from '@shell/store/catalog';
import { CATALOG, MANAGEMENT, NORMAN } from '@shell/config/types';
import { CATALOG as CATALOG_ANNOTATIONS } from '@shell/config/labels-annotations';
import LazyImage from '@shell/components/LazyImage';
Expand Down
112 changes: 0 additions & 112 deletions shell/store/__tests__/catalog.test.ts

This file was deleted.

Loading
Loading