Skip to content

Commit

Permalink
Added release version from window.SERVER_FLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
lokanandaprabhu authored and vikram-raj committed Mar 6, 2024
1 parent 8e09e82 commit 7521a45
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 68 deletions.
2 changes: 0 additions & 2 deletions locales/en/plugin__pipelines-console-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"Average duration": "Average duration",
"Average Duration": "Average Duration",
"Cancelled": "Cancelled",
"ClusterVersion": "ClusterVersion",
"ClusterVersions": "ClusterVersions",
"Duration": "Duration",
"Failed": "Failed",
"Last day": "Last day",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,17 @@ import {
listPageTableColumnClasses as tableColumnClasses,
} from '../utils';
import PipelineRunsForPipelinesRow from './PipelineRunsForPipelinesRow';
import { ClusterVersionModel } from '../../../models';
import { ClusterVersionKind } from '../../../types';
import { useK8sGet } from '../../hooks/use-k8sGet-hook';

type PipelineRunsForPipelinesListProps = {
summaryData: SummaryProps[];
summaryDataFiltered?: SummaryProps[];
loaded: boolean;
};

export const getClusterVersion = (cv: ClusterVersionKind): string => {
return cv?.status?.history?.[0]?.version || cv?.spec?.desiredUpdate?.version;
};

const PipelineRunsForPipelinesList: React.FC<
PipelineRunsForPipelinesListProps
> = ({ summaryData, summaryDataFiltered, loaded }) => {
const { t } = useTranslation('plugin__pipelines-console-plugin');
const [clusterVersionData, clusterVersionLoaded] =
useK8sGet<ClusterVersionKind>(ClusterVersionModel, 'version');
const clusterVersion =
clusterVersionLoaded && getClusterVersion(clusterVersionData);
const EmptyMsg = () => (
<EmptyState variant={EmptyStateVariant.large}>
{t('No PipelineRuns found')}
Expand Down Expand Up @@ -120,7 +109,6 @@ const PipelineRunsForPipelinesList: React.FC<
loadError={false}
unfilteredData={summaryData}
EmptyMsg={EmptyMsg}
rowData={{ clusterVersion }}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import { ALL_NAMESPACES_KEY } from '../../../consts';
import { PipelineModel, PipelineModelV1Beta1 } from '../../../models';
import { useActiveNamespace } from '../../hooks/useActiveNamespace';

const PipelineRunsForPipelinesRow: React.FC<
RowProps<SummaryProps, { clusterVersion: string }>
> = ({ obj, rowData }) => {
const PipelineRunsForPipelinesRow: React.FC<RowProps<SummaryProps>> = ({
obj,
}) => {
const [activeNamespace] = useActiveNamespace();
const [namespace, name] = obj.group_value.split('/');
const { clusterVersion } = rowData;
const clusterVersion = (window as any).SERVER_FLAGS?.releaseVersion;
const isV1SupportCluster =
clusterVersion.split('.')[0] === '4' && clusterVersion.split('.')[1] > '13';
clusterVersion?.split('.')[0] === '4' &&
clusterVersion?.split('.')[1] > '13';
const pipelineReference = getReferenceForModel(
isV1SupportCluster ? PipelineModel : PipelineModelV1Beta1,
);
Expand Down
17 changes: 0 additions & 17 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,3 @@ export const RouteModel: K8sKind = {
kind: 'Route',
id: 'route',
};

export const ClusterVersionModel: K8sKind = {
label: 'ClusterVersion',
// t('ClusterVersion')
labelKey: 'ClusterVersion',
labelPlural: 'ClusterVersions',
// t('ClusterVersions')
labelPluralKey: 'ClusterVersions',
apiVersion: 'v1',
apiGroup: 'config.openshift.io',
plural: 'clusterversions',
abbr: 'CV',
namespaced: false,
kind: 'ClusterVersion',
id: 'clusterversion',
crd: true,
};
32 changes: 0 additions & 32 deletions src/types/openshift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,3 @@ export type K8sResourceKind = K8sResourceCommon & {
status?: { [key: string]: any };
data?: { [key: string]: any };
};

export type UpdateHistory = {
state: 'Completed' | 'Partial';
startedTime: string;
completionTime: string;
version: string;
image: string;
verified: boolean;
};

export type Release = {
version: string;
image: string;
url?: string;
channels?: string[];
};
type ClusterVersionStatus = {
desired: Release;
history: UpdateHistory[];
};

type ClusterVersionSpec = {
channel: string;
clusterID: string;
desiredUpdate?: Release;
upstream?: string;
};

export type ClusterVersionKind = {
spec: ClusterVersionSpec;
status: ClusterVersionStatus;
} & K8sResourceCommon;

0 comments on commit 7521a45

Please sign in to comment.