Skip to content

feat(pci-kubernetes): add cluster plan in list #17752

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

Draft
wants to merge 1 commit into
base: feat/add-plan-informations-to-cluster
Choose a base branch
from
Draft
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 @@ -11,6 +11,9 @@
"kube_service_file_help": "Le fichier kubeconfig contient les données permettant à l'outil en ligne de commande kubectl de communiquer avec l'API de votre cluster.",
"kube_service_file_more_information": "Plus d'informations disponibles ici",
"kube_service_cluster_information": "Informations sur le cluster",
"kube_service_cluster_offer": "Plan",
"kube_service_cluster_offer_free": "Gratuit",
"kube_service_cluster_offer_standard": "Standard",
"kube_service_cluster_status": "Statut",
"kube_service_cluster_status_READY": "Ok",
"kube_service_cluster_status_ERROR": "Erreur",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { renderHook } from '@testing-library/react';
import { render, renderHook } from '@testing-library/react';
import { Datagrid } from '@ovh-ux/manager-react-components';
import { useDatagridColumn } from './useDatagridColumn';
import { TClusterOffer, TKube } from '@/types';
import { wrapper } from '@/wrapperRenders';

const test = [
['name', 'kube_list_name'],
['id', 'kube_list_id'],
['offer', 'kube:kube_service_cluster_offer'],
['region', 'kube_list_region'],
['mode', 'kubernetes_containers_deployment_mode_label'],
['attachedTo', 'kube_list_network_attached'],
['version', 'kube_list_version'],
['status', 'kube:kube_service_cluster_status'],
['actions', ''],
];

const columnCount = test.length;

const clusterOffers: TClusterOffer[] = ['free', 'standard'];

describe('useDatagridColumn', () => {
it.each(test)('should return the correct column for %s', (id, label) => {
const { result } = renderHook(() => useDatagridColumn());
Expand All @@ -29,4 +36,22 @@ describe('useDatagridColumn', () => {

expect(columns).toHaveLength(columnCount);
});

it.each(clusterOffers)(`should display correct cluster offer`, (offer) => {
const { result } = renderHook(() => useDatagridColumn());

const fakeStandardOfferKubeData = [{ offer } as TKube];

const { getByText } = render(
<Datagrid
columns={result.current}
items={fakeStandardOfferKubeData}
totalItems={fakeStandardOfferKubeData.length}
/>,
{ wrapper },
);
expect(
getByText(`kube:kube_service_cluster_offer_${offer}`),
).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export const useDatagridColumn = () => {
),
label: t('kube_list_id'),
},
{
id: 'offer',
cell: (props: TKube) => (
<DataGridTextCell>
{t(`kube:kube_service_cluster_offer_${props.offer}`)}
</DataGridTextCell>
),
label: t('kube:kube_service_cluster_offer'),
},
{
id: 'region',
cell: (props: TKube) => (
Expand Down
4 changes: 4 additions & 0 deletions packages/manager/apps/pci-kubernetes/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export type TKube = {
privateNetworkConfiguration: TNetworkConfiguration;
isClusterReady: boolean;
plugins: typeof pluginData;
// TODO: enlever le ? pour mettre mandatory
offer?: TClusterOffer;
};

export type TAdmissionPlugin = {
Expand All @@ -64,6 +66,8 @@ export type TClusterCustomization = {
apiServer: TApiServerCustomization;
};

export type TClusterOffer = 'free' | 'standard';

export type TNetworkConfiguration = {
privateNetworkRoutingAsDefault: boolean;
defaultVrackGateway: string;
Expand Down
Loading