@rancher/shell 3.0.9 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/assets/styles/base/_color.scss +4 -0
  2. package/assets/styles/themes/_light.scss +6 -6
  3. package/assets/styles/themes/_modern.scss +14 -6
  4. package/assets/translations/en-us.yaml +2 -5
  5. package/components/CopyToClipboard.vue +28 -0
  6. package/components/CopyToClipboardText.vue +4 -0
  7. package/components/CruResource.vue +1 -0
  8. package/components/GlobalRoleBindings.vue +1 -5
  9. package/components/ResourceDetail/index.vue +0 -21
  10. package/components/__tests__/CruResource.test.ts +35 -1
  11. package/composables/useIsNewDetailPageEnabled.test.ts +98 -0
  12. package/composables/useIsNewDetailPageEnabled.ts +12 -0
  13. package/config/product/explorer.js +11 -1
  14. package/config/table-headers.js +0 -9
  15. package/config/types.js +0 -1
  16. package/edit/auth/github-app-steps.vue +2 -0
  17. package/edit/auth/github-steps.vue +2 -0
  18. package/edit/management.cattle.io.user.vue +60 -35
  19. package/edit/token.vue +29 -68
  20. package/models/token.js +0 -4
  21. package/package.json +8 -8
  22. package/pages/account/index.vue +67 -96
  23. package/pages/c/_cluster/apps/charts/AppChartCardFooter.vue +66 -9
  24. package/pages/c/_cluster/explorer/index.vue +2 -19
  25. package/pkg/auto-import.js +41 -0
  26. package/plugins/dashboard-store/resource-class.js +2 -2
  27. package/plugins/steve/__tests__/steve-class.test.ts +1 -1
  28. package/plugins/steve/steve-class.js +3 -3
  29. package/plugins/steve/steve-pagination-utils.ts +2 -4
  30. package/rancher-components/Pill/RcCounterBadge/RcCounterBadge.vue +7 -7
  31. package/rancher-components/Pill/RcStatusBadge/RcStatusBadge.vue +5 -2
  32. package/rancher-components/RcIcon/types.ts +2 -2
  33. package/rancher-components/RcSection/RcSection.test.ts +323 -0
  34. package/rancher-components/RcSection/RcSection.vue +252 -0
  35. package/rancher-components/RcSection/RcSectionActions.test.ts +212 -0
  36. package/rancher-components/RcSection/RcSectionActions.vue +85 -0
  37. package/rancher-components/RcSection/RcSectionBadges.test.ts +149 -0
  38. package/rancher-components/RcSection/RcSectionBadges.vue +29 -0
  39. package/rancher-components/RcSection/index.ts +12 -0
  40. package/rancher-components/RcSection/types.ts +86 -0
  41. package/scripts/test-plugins-build.sh +5 -4
  42. package/types/shell/index.d.ts +92 -108
  43. package/utils/style.ts +17 -0
  44. package/utils/units.js +14 -5
  45. package/models/ext.cattle.io.token.js +0 -48
@@ -0,0 +1,29 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+ import RcStatusBadge from '@components/Pill/RcStatusBadge';
4
+ import type { RcSectionBadgesProps } from './types';
5
+
6
+ const MAX_BADGES = 3;
7
+
8
+ const props = defineProps<RcSectionBadgesProps>();
9
+
10
+ const visibleBadges = computed(() => {
11
+ if (props.badges.length > MAX_BADGES) {
12
+ // eslint-disable-next-line no-console
13
+ console.warn(`[RcSectionBadges]: Received ${ props.badges.length } badges but only ${ MAX_BADGES } are allowed. Extra badges will be hidden.`);
14
+ }
15
+
16
+ return props.badges.slice(0, MAX_BADGES);
17
+ });
18
+ </script>
19
+
20
+ <template>
21
+ <RcStatusBadge
22
+ v-for="(badge, i) in visibleBadges"
23
+ :key="i"
24
+ v-clean-tooltip="badge.tooltip"
25
+ :status="badge.status"
26
+ >
27
+ {{ badge.label }}
28
+ </RcStatusBadge>
29
+ </template>
@@ -0,0 +1,12 @@
1
+ export { default as RcSection } from './RcSection.vue';
2
+ export { default as RcSectionBadges } from './RcSectionBadges.vue';
3
+ export { default as RcSectionActions } from './RcSectionActions.vue';
4
+ export type {
5
+ RcSectionProps,
6
+ SectionType,
7
+ SectionMode,
8
+ BadgeConfig,
9
+ RcSectionBadgesProps,
10
+ ActionConfig,
11
+ RcSectionActionsProps,
12
+ } from './types';
@@ -0,0 +1,86 @@
1
+ import type { Status } from '@components/utils/status';
2
+ import type { RcIconType } from '@components/RcIcon/types';
3
+
4
+ export type SectionType = 'primary' | 'secondary';
5
+
6
+ export type SectionMode = 'with-header' | 'no-header';
7
+
8
+ export type SectionBackground = 'primary' | 'secondary';
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // Badge helpers
12
+ // ---------------------------------------------------------------------------
13
+
14
+ export interface BadgeConfig {
15
+ /** Display text inside the badge. */
16
+ label: string;
17
+ /** Status colour of the badge. */
18
+ status: Status;
19
+ /** Optional tooltip text shown on hover. */
20
+ tooltip?: string;
21
+ }
22
+
23
+ export interface RcSectionBadgesProps {
24
+ badges: BadgeConfig[];
25
+ }
26
+
27
+ // ---------------------------------------------------------------------------
28
+ // Action helpers
29
+ // ---------------------------------------------------------------------------
30
+
31
+ export interface ActionConfig {
32
+ /** Button label. When omitted the button renders as icon-only (ghost). */
33
+ label?: string;
34
+ /** Icon shown on the button (left position for labeled, sole content for icon-only). */
35
+ icon?: RcIconType;
36
+ /** Accessible label for the button. Required when `label` is omitted so screen readers can describe the action. */
37
+ ariaLabel?: string;
38
+ /** Callback invoked when the action is clicked. */
39
+ action: () => void;
40
+ }
41
+
42
+ export interface RcSectionActionsProps {
43
+ actions: ActionConfig[];
44
+ }
45
+
46
+ // ---------------------------------------------------------------------------
47
+ // Section
48
+ // ---------------------------------------------------------------------------
49
+
50
+ export interface RcSectionProps {
51
+ /**
52
+ * Visual type of the section.
53
+ * - Primary: no lateral padding, border-radius, or background (inherits from parent). Bolder title (700).
54
+ * - Secondary: has lateral padding (16px), border-radius (8px), and background color. Lighter title (600).
55
+ */
56
+ type: SectionType;
57
+
58
+ /**
59
+ * Controls whether the section renders with a header or without.
60
+ * - 'with-header': renders the full header (title, badges, actions, errors).
61
+ * - 'no-header': hides the header entirely; content padding adjusts to 16px vertical.
62
+ */
63
+ mode: SectionMode;
64
+
65
+ /**
66
+ * Background color of the section. When omitted, automatically alternates
67
+ * from the parent RcSection's background (primary -> secondary -> primary).
68
+ */
69
+ background?: SectionBackground;
70
+
71
+ /**
72
+ * Whether the section can be expanded/collapsed via the header.
73
+ */
74
+ expandable: boolean;
75
+
76
+ /**
77
+ * Whether the section content is expanded. Only applies when `expandable` is true.
78
+ * Supports `v-model:expanded`.
79
+ */
80
+ expanded?: boolean;
81
+
82
+ /**
83
+ * The section title text. Can also be provided via the `title` slot.
84
+ */
85
+ title?: string;
86
+ }
@@ -235,10 +235,11 @@ function clone_repo_test_extension_build() {
235
235
 
236
236
  # Here we just add the extension that we want to include as a check (all our official extensions should be included here)
237
237
  # Don't forget to add the unit tests exception to clone_repo_test_extension_build function if a new extension has those
238
- clone_repo_test_extension_build "rancher" "kubewarden-ui" "kubewarden"
239
- clone_repo_test_extension_build "rancher" "elemental-ui" "elemental"
238
+ # TODO: ISSUE #16858 - Reenable the tests as packages migrate to node version 24
239
+ # clone_repo_test_extension_build "rancher" "kubewarden-ui" "kubewarden"
240
+ # clone_repo_test_extension_build "rancher" "elemental-ui" "elemental"
240
241
  clone_repo_test_extension_build "neuvector" "manager-ext" "neuvector-ui-ext"
241
- clone_repo_test_extension_build "StackVista" "rancher-extension-stackstate" "observability"
242
- clone_repo_test_extension_build "harvester" "harvester-ui-extension" "harvester"
242
+ # clone_repo_test_extension_build "StackVista" "rancher-extension-stackstate" "observability"
243
+ # clone_repo_test_extension_build "harvester" "harvester-ui-extension" "harvester"
243
244
 
244
245
  echo "All done"
@@ -1789,21 +1789,23 @@ export namespace SCOPE_NORMAN {
1789
1789
  let sort_103: string[];
1790
1790
  export { sort_103 as sort };
1791
1791
  }
1792
- export namespace NORMAN_KEY_DEPRECATION {
1792
+ export namespace EXPIRES {
1793
1793
  let name_114: string;
1794
1794
  export { name_114 as name };
1795
+ let value_113: string;
1796
+ export { value_113 as value };
1795
1797
  let labelKey_111: string;
1796
1798
  export { labelKey_111 as labelKey };
1797
- export function value_113(row: any): string;
1798
- export { value_113 as value };
1799
- let sort_104: string;
1800
- export { sort_104 as sort };
1801
1799
  let align_18: string;
1802
1800
  export { align_18 as align };
1803
- let dashIfEmpty_7: boolean;
1804
- export { dashIfEmpty_7 as dashIfEmpty };
1801
+ let sort_104: string[];
1802
+ export { sort_104 as sort };
1803
+ let width_30: number;
1804
+ export { width_30 as width };
1805
+ let formatter_62: string;
1806
+ export { formatter_62 as formatter };
1805
1807
  }
1806
- export namespace EXPIRES {
1808
+ export namespace LAST_USED {
1807
1809
  let name_115: string;
1808
1810
  export { name_115 as name };
1809
1811
  let value_114: string;
@@ -1814,22 +1816,6 @@ export namespace EXPIRES {
1814
1816
  export { align_19 as align };
1815
1817
  let sort_105: string[];
1816
1818
  export { sort_105 as sort };
1817
- let width_30: number;
1818
- export { width_30 as width };
1819
- let formatter_62: string;
1820
- export { formatter_62 as formatter };
1821
- }
1822
- export namespace LAST_USED {
1823
- let name_116: string;
1824
- export { name_116 as name };
1825
- let value_115: string;
1826
- export { value_115 as value };
1827
- let labelKey_113: string;
1828
- export { labelKey_113 as labelKey };
1829
- let align_20: string;
1830
- export { align_20 as align };
1831
- let sort_106: string[];
1832
- export { sort_106 as sort };
1833
1819
  let width_31: number;
1834
1820
  export { width_31 as width };
1835
1821
  let formatter_63: string;
@@ -1840,40 +1826,40 @@ export namespace LAST_USED {
1840
1826
  export { formatterOpts_15 as formatterOpts };
1841
1827
  }
1842
1828
  export namespace RESTART {
1843
- let name_117: string;
1844
- export { name_117 as name };
1845
- let labelKey_114: string;
1846
- export { labelKey_114 as labelKey };
1847
- let value_116: string;
1848
- export { value_116 as value };
1849
- let sort_107: string[];
1850
- export { sort_107 as sort };
1829
+ let name_116: string;
1830
+ export { name_116 as name };
1831
+ let labelKey_113: string;
1832
+ export { labelKey_113 as labelKey };
1833
+ let value_115: string;
1834
+ export { value_115 as value };
1835
+ let sort_106: string[];
1836
+ export { sort_106 as sort };
1851
1837
  let formatter_64: string;
1852
1838
  export { formatter_64 as formatter };
1853
1839
  let width_32: number;
1854
1840
  export { width_32 as width };
1855
- let align_21: string;
1856
- export { align_21 as align };
1841
+ let align_20: string;
1842
+ export { align_20 as align };
1857
1843
  }
1858
1844
  export namespace ROLE {
1845
+ let name_117: string;
1846
+ export { name_117 as name };
1847
+ let value_116: string;
1848
+ export { value_116 as value };
1849
+ let labelKey_114: string;
1850
+ export { labelKey_114 as labelKey };
1851
+ }
1852
+ export namespace FEATURE_DESCRIPTION {
1859
1853
  let name_118: string;
1860
1854
  export { name_118 as name };
1861
- let value_117: string;
1862
- export { value_117 as value };
1863
1855
  let labelKey_115: string;
1864
1856
  export { labelKey_115 as labelKey };
1865
- }
1866
- export namespace FEATURE_DESCRIPTION {
1867
- let name_119: string;
1868
- export { name_119 as name };
1869
- let labelKey_116: string;
1870
- export { labelKey_116 as labelKey };
1871
- let value_118: string;
1872
- export { value_118 as value };
1873
- let align_22: string;
1874
- export { align_22 as align };
1875
- let sort_108: string[];
1876
- export { sort_108 as sort };
1857
+ let value_117: string;
1858
+ export { value_117 as value };
1859
+ let align_21: string;
1860
+ export { align_21 as align };
1861
+ let sort_107: string[];
1862
+ export { sort_107 as sort };
1877
1863
  let formatter_65: string;
1878
1864
  export { formatter_65 as formatter };
1879
1865
  export namespace formatterOpts_16 {
@@ -1882,14 +1868,14 @@ export namespace FEATURE_DESCRIPTION {
1882
1868
  export { formatterOpts_16 as formatterOpts };
1883
1869
  }
1884
1870
  export namespace STATE_NORMAN {
1885
- let name_120: string;
1886
- export { name_120 as name };
1887
- let labelKey_117: string;
1888
- export { labelKey_117 as labelKey };
1889
- let sort_109: string[];
1890
- export { sort_109 as sort };
1891
- let value_119: string;
1892
- export { value_119 as value };
1871
+ let name_119: string;
1872
+ export { name_119 as name };
1873
+ let labelKey_116: string;
1874
+ export { labelKey_116 as labelKey };
1875
+ let sort_108: string[];
1876
+ export { sort_108 as sort };
1877
+ let value_118: string;
1878
+ export { value_118 as value };
1893
1879
  let width_33: number;
1894
1880
  export { width_33 as width };
1895
1881
  let _default_3: string;
@@ -1898,6 +1884,18 @@ export namespace STATE_NORMAN {
1898
1884
  export { formatter_66 as formatter };
1899
1885
  }
1900
1886
  export namespace KUBE_NODE_OS {
1887
+ let name_120: string;
1888
+ export { name_120 as name };
1889
+ let labelKey_117: string;
1890
+ export { labelKey_117 as labelKey };
1891
+ let value_119: string;
1892
+ export { value_119 as value };
1893
+ let sort_109: string[];
1894
+ export { sort_109 as sort };
1895
+ let formatter_67: string;
1896
+ export { formatter_67 as formatter };
1897
+ }
1898
+ export namespace MACHINE_NODE_OS {
1901
1899
  let name_121: string;
1902
1900
  export { name_121 as name };
1903
1901
  let labelKey_118: string;
@@ -1906,10 +1904,12 @@ export namespace KUBE_NODE_OS {
1906
1904
  export { value_120 as value };
1907
1905
  let sort_110: string[];
1908
1906
  export { sort_110 as sort };
1909
- let formatter_67: string;
1910
- export { formatter_67 as formatter };
1907
+ let formatter_68: string;
1908
+ export { formatter_68 as formatter };
1909
+ let dashIfEmpty_7: boolean;
1910
+ export { dashIfEmpty_7 as dashIfEmpty };
1911
1911
  }
1912
- export namespace MACHINE_NODE_OS {
1912
+ export namespace MANAGEMENT_NODE_OS {
1913
1913
  let name_122: string;
1914
1914
  export { name_122 as name };
1915
1915
  let labelKey_119: string;
@@ -1918,63 +1918,49 @@ export namespace MACHINE_NODE_OS {
1918
1918
  export { value_121 as value };
1919
1919
  let sort_111: string[];
1920
1920
  export { sort_111 as sort };
1921
- let formatter_68: string;
1922
- export { formatter_68 as formatter };
1921
+ let formatter_69: string;
1922
+ export { formatter_69 as formatter };
1923
1923
  let dashIfEmpty_8: boolean;
1924
1924
  export { dashIfEmpty_8 as dashIfEmpty };
1925
1925
  }
1926
- export namespace MANAGEMENT_NODE_OS {
1926
+ export namespace FLEET_BUNDLE_LAST_UPDATED {
1927
1927
  let name_123: string;
1928
1928
  export { name_123 as name };
1929
1929
  let labelKey_120: string;
1930
1930
  export { labelKey_120 as labelKey };
1931
1931
  let value_122: string;
1932
1932
  export { value_122 as value };
1933
+ let formatter_70: string;
1934
+ export { formatter_70 as formatter };
1935
+ export namespace formatterOpts_17 {
1936
+ let addSuffix_3: boolean;
1937
+ export { addSuffix_3 as addSuffix };
1938
+ }
1939
+ export { formatterOpts_17 as formatterOpts };
1933
1940
  let sort_112: string[];
1934
1941
  export { sort_112 as sort };
1935
- let formatter_69: string;
1936
- export { formatter_69 as formatter };
1937
- let dashIfEmpty_9: boolean;
1938
- export { dashIfEmpty_9 as dashIfEmpty };
1939
1942
  }
1940
- export namespace FLEET_BUNDLE_LAST_UPDATED {
1943
+ export namespace FLEET_REPO_TARGET {
1941
1944
  let name_124: string;
1942
1945
  export { name_124 as name };
1943
1946
  let labelKey_121: string;
1944
1947
  export { labelKey_121 as labelKey };
1945
1948
  let value_123: string;
1946
1949
  export { value_123 as value };
1947
- let formatter_70: string;
1948
- export { formatter_70 as formatter };
1949
- export namespace formatterOpts_17 {
1950
- let addSuffix_3: boolean;
1951
- export { addSuffix_3 as addSuffix };
1952
- }
1953
- export { formatterOpts_17 as formatterOpts };
1954
1950
  let sort_113: string[];
1955
1951
  export { sort_113 as sort };
1956
1952
  }
1957
- export namespace FLEET_REPO_TARGET {
1953
+ export namespace FLEET_REPO {
1958
1954
  let name_125: string;
1959
1955
  export { name_125 as name };
1960
1956
  let labelKey_122: string;
1961
1957
  export { labelKey_122 as labelKey };
1962
1958
  let value_124: string;
1963
1959
  export { value_124 as value };
1964
- let sort_114: string[];
1965
- export { sort_114 as sort };
1966
- }
1967
- export namespace FLEET_REPO {
1968
- let name_126: string;
1969
- export { name_126 as name };
1970
- let labelKey_123: string;
1971
- export { labelKey_123 as labelKey };
1972
- let value_125: string;
1973
- export { value_125 as value };
1974
1960
  let formatter_71: string;
1975
1961
  export { formatter_71 as formatter };
1976
- let sort_115: string;
1977
- export { sort_115 as sort };
1962
+ let sort_114: string;
1963
+ export { sort_114 as sort };
1978
1964
  let search_19: string[];
1979
1965
  export { search_19 as search };
1980
1966
  }
@@ -2009,20 +1995,20 @@ export const UI_PLUGIN_CATALOG: ({
2009
1995
  formatterOpts?: undefined;
2010
1996
  })[];
2011
1997
  export namespace PROJECT {
1998
+ let name_126: string;
1999
+ export { name_126 as name };
2000
+ let labelKey_123: string;
2001
+ export { labelKey_123 as labelKey };
2002
+ }
2003
+ export namespace AUTOSCALER_ENABLED {
2012
2004
  let name_127: string;
2013
2005
  export { name_127 as name };
2014
2006
  let labelKey_124: string;
2015
2007
  export { labelKey_124 as labelKey };
2016
- }
2017
- export namespace AUTOSCALER_ENABLED {
2018
- let name_128: string;
2019
- export { name_128 as name };
2020
- let labelKey_125: string;
2021
- export { labelKey_125 as labelKey };
2022
- let value_126: string;
2023
- export { value_126 as value };
2024
- let sort_116: string[];
2025
- export { sort_116 as sort };
2008
+ let value_125: string;
2009
+ export { value_125 as value };
2010
+ let sort_115: string[];
2011
+ export { sort_115 as sort };
2026
2012
  let formatter_72: string;
2027
2013
  export { formatter_72 as formatter };
2028
2014
  }
@@ -2250,13 +2236,11 @@ export namespace BRAND {
2250
2236
  let RGS: string;
2251
2237
  }
2252
2238
  export namespace EXT {
2253
- export let USER_ACTIVITY: string;
2254
- export let SELFUSER: string;
2255
- export let GROUP_MEMBERSHIP_REFRESH_REQUESTS: string;
2256
- export let PASSWORD_CHANGE_REQUESTS: string;
2257
- export let KUBECONFIG: string;
2258
- let TOKEN_2: string;
2259
- export { TOKEN_2 as TOKEN };
2239
+ let USER_ACTIVITY: string;
2240
+ let SELFUSER: string;
2241
+ let GROUP_MEMBERSHIP_REFRESH_REQUESTS: string;
2242
+ let PASSWORD_CHANGE_REQUESTS: string;
2243
+ let KUBECONFIG: string;
2260
2244
  }
2261
2245
  export namespace CAPI {
2262
2246
  let CAPI_CLUSTER: string;
@@ -2277,8 +2261,8 @@ export namespace FLEET {
2277
2261
  export let GIT_REPO: string;
2278
2262
  export let HELM_OP: string;
2279
2263
  export let WORKSPACE: string;
2280
- let TOKEN_3: string;
2281
- export { TOKEN_3 as TOKEN };
2264
+ let TOKEN_2: string;
2265
+ export { TOKEN_2 as TOKEN };
2282
2266
  export let BUNDLE_NAMESPACE_MAPPING: string;
2283
2267
  export let GIT_REPO_RESTRICTION: string;
2284
2268
  }
@@ -3460,7 +3444,7 @@ export default class Resource {
3460
3444
  * Allow to handle the response of the save request
3461
3445
  * @param {*} res Full request response
3462
3446
  */
3463
- processSaveResponse(res: any): void;
3447
+ processSaveResponse(res: any, opt?: {}): void;
3464
3448
  _save(opt?: {}): Promise<this>;
3465
3449
  remove(...args: any[]): Promise<void>;
3466
3450
  _remove(opt?: {}): Promise<void>;
@@ -3826,7 +3810,7 @@ export default class SteveModel extends HybridModel {
3826
3810
  *
3827
3811
  * @param {*} res
3828
3812
  */
3829
- processSaveResponse(res: any): void;
3813
+ processSaveResponse(res: any, opt?: {}): void;
3830
3814
  }
3831
3815
  import HybridModel from './hybrid-class';
3832
3816
  }
package/utils/style.ts CHANGED
@@ -40,3 +40,20 @@ export function getHighestAlertColor(colors: StateColor[]) {
40
40
 
41
41
  // 1x1 transparent image as a placeholder image
42
42
  export const BLANK_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
43
+
44
+ /**
45
+ * Checks if the given element's text is truncated.
46
+ *
47
+ * @param element The DOM element to check for truncation
48
+ * @returns boolean indicating if the element's text is truncated
49
+ */
50
+ export function isTruncated(element: HTMLElement | null): boolean {
51
+ if (!element) {
52
+ return false;
53
+ }
54
+
55
+ const isHorizontallyTruncated = element.scrollWidth > element.clientWidth;
56
+ const isVerticallyTruncated = element.scrollHeight - element.clientHeight > 1;
57
+
58
+ return isHorizontallyTruncated || isVerticallyTruncated;
59
+ }
package/utils/units.js CHANGED
@@ -166,13 +166,22 @@ function createMemoryUnits(n) {
166
166
  export function createMemoryValues(total, useful) {
167
167
  const parsedTotal = parseSi((total || '0').toString());
168
168
  const parsedUseful = parseSi((useful || '0').toString());
169
- const format = createMemoryFormat(parsedTotal);
170
- const formattedTotal = formatSi(parsedTotal, format);
171
- const formattedUseful = formatSi(parsedUseful, format);
169
+
170
+ // Determine the appropriate unit based on total
171
+ const exponent = exponentNeeded(parsedTotal, 1024);
172
+ const divisor = 1024 ** exponent;
173
+
174
+ // Convert bytes to the appropriate unit, preserving precision
175
+ const totalInUnits = parsedTotal / divisor;
176
+ const usefulInUnits = parsedUseful / divisor;
177
+
178
+ // Apply maxPrecision rounding (2 decimal places) directly to numbers
179
+ const roundedTotal = Math.round(totalInUnits * 100) / 100;
180
+ const roundedUseful = Math.round(usefulInUnits * 100) / 100;
172
181
 
173
182
  return {
174
- total: Number.parseFloat(formattedTotal),
175
- useful: Number.parseFloat(formattedUseful),
183
+ total: roundedTotal,
184
+ useful: roundedUseful,
176
185
  units: createMemoryUnits(parsedTotal)
177
186
  };
178
187
  }
@@ -1,48 +0,0 @@
1
- import SteveModel from '@shell/plugins/steve/steve-class';
2
-
3
- export default class SteveToken extends SteveModel {
4
- // for now, we are only showing the new tokens in the UI. Later we will be able to edit a few of it's fields
5
- get _availableActions() {
6
- return super._availableActions.filter((a) => ['viewInApi', 'promptRemove'].includes(a.action));
7
- }
8
-
9
- cleanForSave(data) {
10
- const val = super.cleanForSave(data);
11
-
12
- delete val.type;
13
-
14
- return val;
15
- }
16
-
17
- get isDeprecated() {
18
- return undefined;
19
- }
20
-
21
- get state() {
22
- return this.isExpired ? 'expired' : !this.spec?.enabled ? 'inactive' : 'active';
23
- }
24
-
25
- get isExpired() {
26
- return this.status?.expired;
27
- }
28
-
29
- get expiresAt() {
30
- return this.status?.expiresAt || '';
31
- }
32
-
33
- get lastUsedAt() {
34
- return this.status?.lastUsedAt || '';
35
- }
36
-
37
- get description() {
38
- return this.spec?.description || '';
39
- }
40
-
41
- get clusterId() {
42
- return this.spec?.clusterName || '';
43
- }
44
-
45
- get created() {
46
- return this.metadata?.creationTimestamp;
47
- }
48
- }