Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ const calculatePercentage = (numerator: number, denominator: number): number =>
Math.round((numerator / denominator) * 100);

export const CurrentChannel: React.FC<CurrentChannelProps> = ({ cv, clusterVersionIsEditable }) => {
// TODO: use a more informative empty state label
const label = cv.spec.channel || '-';
// TODO: do not show #current-channel-update-link when no channels are present in CV (e.g., a nightly build)
return clusterVersionIsEditable ? (
<Button
type="button"
Expand Down Expand Up @@ -524,7 +526,7 @@ export const UpdatesGraph: React.FC<UpdatesGraphProps> = ({ cv }) => {
const secondNewestVersion = availableUpdates[1]?.version;
const currentChannel = cv.spec.channel;
const currentPrefix = splitClusterVersionChannel(currentChannel)?.prefix;
const similarChannels = getSimilarClusterVersionChannels(currentPrefix);
const similarChannels = getSimilarClusterVersionChannels(cv, currentPrefix);
const newerChannel = getNewerClusterVersionChannel(similarChannels, currentChannel);

return (
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/components/modals/cluster-channel-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ class ClusterChannelModal extends PromiseComponent<

render() {
const { cv } = this.props;
const availableChannels = getAvailableClusterChannels();
const availableChannels = getAvailableClusterChannels(cv).reduce((o, val) => {
o[val] = val;
return o;
}, {});
return (
<form
onSubmit={this._submit}
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/components/notification-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const getUpdateNotificationEntries = (
const updateData: ClusterUpdate[] = getSortedUpdates(cv);
const currentChannel = cv?.spec?.channel;
const currentPrefix = splitClusterVersionChannel(currentChannel)?.prefix;
const similarChannels = getSimilarClusterVersionChannels(currentPrefix);
const similarChannels = getSimilarClusterVersionChannels(cv, currentPrefix);
const newerChannel = getNewerClusterVersionChannel(similarChannels, currentChannel);
const newerChannelVersion = splitClusterVersionChannel(newerChannel)?.version;
const entries = [];
Expand Down
14 changes: 7 additions & 7 deletions frontend/public/module/k8s/cluster-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export const getSortedUpdates = (cv: ClusterVersionKind): ClusterUpdate[] => {
}
};

export const getAvailableClusterChannels = () => ({
'stable-4.6': 'stable-4.6',
'fast-4.6': 'fast-4.6',
'candidate-4.6': 'candidate-4.6',
});
export const getAvailableClusterChannels = (cv) => {
// temporarily fall back to hard-coded values when `cv.status.desired.channels` are not present
// TODO: remove fall back values once `cv.status.desired.channels` are widespread
return cv?.status?.desired?.channels || ['stable-4.6', 'fast-4.6', 'candidate-4.6'];
};

export const getDesiredClusterVersion = (cv: ClusterVersionKind): string => {
return _.get(cv, 'status.desired.version');
Expand All @@ -56,8 +56,8 @@ export const splitClusterVersionChannel = (channel: string) => {
return parsed ? { prefix: parsed[1], version: parsed[2] } : null;
};

export const getSimilarClusterVersionChannels = (currentPrefix) => {
return _.keys(getAvailableClusterChannels()).filter((channel: string) => {
export const getSimilarClusterVersionChannels = (cv, currentPrefix) => {
return getAvailableClusterChannels(cv).filter((channel: string) => {
return currentPrefix && splitClusterVersionChannel(channel)?.prefix === currentPrefix;
});
};
Expand Down