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

Fix/pci rancher fix value tapc 1615 #13026

Merged
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: 1 addition & 0 deletions packages/manager/apps/pci-rancher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@ovh-ux/manager-react-components": "^1.36.0",
"@ovh-ux/manager-react-core-application": "^0.10.2",
"@ovh-ux/manager-react-shell-client": "^0.7.2",
"@ovh-ux/manager-core-utils": "*",
"@ovh-ux/request-tagger": "^0.3.0",
"@ovh-ux/shell": "^3.8.0",
"@ovhcloud/ods-common-core": "17.2.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { OsdsText } from '@ovhcloud/ods-components/react';
import { Cell } from '@tanstack/react-table';
import { RancherService } from '@/types/api.type';
import '../Table.scss';

interface DisplayCellInterface {
cell: Cell<RancherService, number>;
}

function DisplayCellNumber({ cell }: Readonly<DisplayCellInterface>) {
const number = cell.renderValue();
return <OsdsText color={ODS_THEME_COLOR_INTENT.text}>{number}</OsdsText>;
}

export default DisplayCellNumber;
fredericvilcot marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import DisplayCellText from '../TextCell/TextCell.component';
import '../Table.scss';
import { deleteRancherServiceQueryKey } from '@/data/api/services';
import StatusChip from '../../StatusChip/StatusChip.component';
import DisplayCellNumber from '../NumberCell/NumberCell.component';

export default function TableContainer({
data,
Expand Down Expand Up @@ -71,7 +72,7 @@ export default function TableContainer({
id: 'numberOfCpu',
header: t('numberOfCpu'),
accessorFn: (row) => row.currentState.usage?.orchestratedVcpus,
cell: DisplayCellText,
cell: DisplayCellNumber,
},
{
id: 'status',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { format } from 'date-fns';
import * as locales from 'date-fns/locale';
import { getDateFnsLocale } from '@ovh-ux/manager-core-utils';

import {
CommonTitle,
Expand All @@ -22,7 +24,7 @@ import {
OsdsText,
OsdsTile,
} from '@ovhcloud/ods-components/react';
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { useHref } from 'react-router-dom';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -59,7 +61,11 @@ const RancherDetail = ({
updateOfferErrorMessage,
versions,
}: RancherDetailProps) => {
const { t } = useTranslation(['dashboard', 'updateSoftware', 'listing']);
const { t, i18n } = useTranslation([
'dashboard',
'updateSoftware',
'listing',
]);
const trackAction = useTrackingAction();
const hrefEdit = useHref('./edit');
const hrefUpdateSoftware = useHref('./update-software');
Expand Down Expand Up @@ -120,12 +126,24 @@ const RancherDetail = ({

const onAccessRancherUrl = () =>
trackAction(TrackingPageView.DetailRancher, TrackingEvent.accessUi);

const shouldDisplayUpdateSoftware =
getLatestVersionAvailable(rancher, versions) &&
isReadyStatus &&
!updateSoftwareResponseType;

const userLocale = getDateFnsLocale(i18n.language);
ppprevost marked this conversation as resolved.
Show resolved Hide resolved

const displayDate = useCallback(
(value: string) =>
format(new Date(dateUsage), value, {
locale:
userLocale in locales
? locales[userLocale as keyof typeof locales]
: locales.fr,
}),
[userLocale, locales, dateUsage],
);

const isEligibleForUpgrade = plan === RancherPlanName.OVHCLOUD_EDITION;

return (
Expand Down Expand Up @@ -243,14 +261,14 @@ const RancherDetail = ({
</TileBlock>
<TileBlock label={t('count_cpu_orchestrated')}>
<OsdsText color={ODS_THEME_COLOR_INTENT.text}>
{rancher.currentState.usage?.orchestratedVcpus || '-'}
{rancher.currentState.usage?.orchestratedVcpus}
</OsdsText>
{dateUsage && (
{displayDate && (
<div className="mt-3">
<OsdsText color={ODS_THEME_COLOR_INTENT.text}>
{t('last_update_date', {
date: format(dateUsage, 'yyyy_MM_dd'),
hour: format(dateUsage, 'HH:mm:ss'),
date: displayDate('PPPP'),
hour: displayDate('HH:mm:ss'),
})}
</OsdsText>
</div>
Expand Down
Loading