Skip to content

Commit

Permalink
fix(manager-components): remove change on update name modal
Browse files Browse the repository at this point in the history
ref: MANAGER-16063

Signed-off-by: Nicolas Pierre-charles <[email protected]>
Signed-off-by: Paul Dickerson <[email protected]>
  • Loading branch information
Nicolas Pierre-charles committed Nov 19, 2024
1 parent 85f7621 commit ea9fe6e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type UpdateNameModalProps = {
inputLabel: string;
defaultValue?: string;
closeModal: () => void;
updateDisplayName: (newDisplayName?: string) => void;
updateDisplayName: (newDisplayName: string) => void;
isLoading?: boolean;
error?: string;
cancelButtonLabel?: string;
Expand Down Expand Up @@ -108,18 +108,14 @@ export const UpdateNameModal: React.FC<UpdateNameModalProps> = ({
)}
</OdsFormField>
<OdsButton
isDisabled={isLoading}
slot="actions"
variant={ODS_BUTTON_VARIANT.ghost}
{...handleClick(closeModal)}
label={cancelButtonLabel || t('updateModalCancelButton')}
/>
<OdsButton
disabled={
isLoading ||
isPatternError ||
defaultValue === displayName ||
undefined
}
isDisabled={isPatternError}
slot="actions"
isLoading={isLoading}
{...handleClick(() => updateDisplayName(displayName))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { OsdsMessage, OsdsText } from '@ovhcloud/ods-components/react';
import { ODS_THEME_TYPOGRAPHY_SIZE } from '@ovhcloud/ods-common-theming';
import { NotificationType } from '@ovh-ux/manager-react-components';
import {
ODS_MESSAGE_TYPE,
ODS_TEXT_COLOR_INTENT,
Expand All @@ -13,32 +12,20 @@ type MessageProps = {
message: MessageType;
};

const messageColors = {
[NotificationType.Success]: ODS_MESSAGE_TYPE.success,
[NotificationType.Error]: ODS_MESSAGE_TYPE.error,
[NotificationType.Warning]: ODS_MESSAGE_TYPE.warning,
[NotificationType.Info]: ODS_MESSAGE_TYPE.info,
};
const textColors = {
[NotificationType.Success]: ODS_TEXT_COLOR_INTENT.success,
[NotificationType.Error]: ODS_TEXT_COLOR_INTENT.error,
[NotificationType.Warning]: ODS_TEXT_COLOR_INTENT.warning,
[NotificationType.Info]: ODS_TEXT_COLOR_INTENT.info,
[ODS_MESSAGE_TYPE.success]: ODS_TEXT_COLOR_INTENT.success,
[ODS_MESSAGE_TYPE.error]: ODS_TEXT_COLOR_INTENT.error,
[ODS_MESSAGE_TYPE.warning]: ODS_TEXT_COLOR_INTENT.warning,
[ODS_MESSAGE_TYPE.info]: ODS_TEXT_COLOR_INTENT.info,
};

const getMessageColor = (type: NotificationType) =>
messageColors[type] || ODS_MESSAGE_TYPE.info;

const getTextColor = (type: NotificationType) =>
textColors[type] || ODS_TEXT_COLOR_INTENT.info;

export const Message: React.FC<MessageProps> = ({ message }) => {
const { pathname } = useLocation();
const { clearMessage } = useMessageContext();
const {
content,
uid,
type,
type = ODS_MESSAGE_TYPE.info,
persistent,
includedSubRoutes,
excludedSubRoutes,
Expand All @@ -65,7 +52,7 @@ export const Message: React.FC<MessageProps> = ({ message }) => {
return (
<OsdsMessage
className="mb-2"
type={getMessageColor(type)}
type={type}
{...(persistent
? {}
: {
Expand All @@ -74,7 +61,7 @@ export const Message: React.FC<MessageProps> = ({ message }) => {
})}
>
<OsdsText
color={getTextColor(type)}
color={textColors[type] || ODS_TEXT_COLOR_INTENT.info}
size={ODS_THEME_TYPOGRAPHY_SIZE._400}
>
{content}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@ export default function BackupTileItem({
.then((url: string) => setVeeamHref(url));
}, []);

if (isLoading) return <OsdsSkeleton data-testid="backupLoading" />;

return (
<div className="flex flex-col items-start">
<OsdsChip
inline
data-testid={badgeParams.testIdLabel}
color={badgeParams.color}
size={ODS_CHIP_SIZE.sm}
>
{t(badgeParams.translationKey)}
</OsdsChip>
<div className="my-3">
{isLoading ? (
<OsdsSkeleton data-testid="backupLoading" />
) : (
<OsdsChip
inline
data-testid={badgeParams.testIdLabel}
color={badgeParams.color}
size={ODS_CHIP_SIZE.sm}
>
{t(badgeParams.translationKey)}
</OsdsChip>
)}
</div>
<Links
type={LinkType.external}
label={t('managed_vcd_dashboard_backup_link')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function OrganizationServiceManagementTile() {
<OsdsChip
inline
color={ODS_THEME_COLOR_INTENT.primary}
className="ml-3"
className="ml-3 mt-3"
size={ODS_CHIP_SIZE.sm}
>
{t('managed_vcd_dashboard_coming_soon')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NotificationType } from '@ovh-ux/manager-react-components/src/components/notifications/useNotifications';
import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components';
import React, {
createContext,
FC,
Expand All @@ -12,7 +12,7 @@ import React, {
export type MessageType = {
uid: number;
content: ReactNode;
type: NotificationType;
type: ODS_MESSAGE_TYPE;
persistent?: boolean;
includedSubRoutes?: string[];
excludedSubRoutes?: string[];
Expand Down Expand Up @@ -64,13 +64,13 @@ export const MessageContextProvider: FC<PropsWithChildren> = ({ children }) => {
() => ({
messages,
addSuccess: (props: AddSpecificMessageProps) =>
addMessage({ type: NotificationType.Success, ...props }),
addMessage({ type: ODS_MESSAGE_TYPE.success, ...props }),
addError: (props: AddSpecificMessageProps) =>
addMessage({ type: NotificationType.Error, ...props }),
addMessage({ type: ODS_MESSAGE_TYPE.error, ...props }),
addInfo: (props: AddSpecificMessageProps) =>
addMessage({ type: NotificationType.Info, ...props }),
addMessage({ type: ODS_MESSAGE_TYPE.info, ...props }),
addWarning: (props: AddSpecificMessageProps) =>
addMessage({ type: NotificationType.Warning, ...props }),
addMessage({ type: ODS_MESSAGE_TYPE.warning, ...props }),
clearMessage: (id) => deleteMessage(id),
clearMessages: () => setMessages([]),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Delete veeam-backup', () => {
const confirmButton = await getButtonByLabel({
container,
label: 'deleteModalDeleteButton',
altLabel: labels.deleteModal.deleteModalDeleteButton,
altLabel: 'Supprimer',
});

await waitFor(() => userEvents.click(confirmButton));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import i18next, { i18n } from 'i18next';
import deleteModal from '@ovh-ux/manager-react-components/src/components/templates/delete-modal/translations/Messages_fr_FR.json';
import common from '../../public/translations/veeam-backup/Messages_fr_FR.json';
import orderVeeam from '../../public/translations/order-veeam/Messages_fr_FR.json';
import listing from '../../public/translations/listing/Messages_fr_FR.json';
Expand Down Expand Up @@ -29,7 +28,6 @@ function addTranslations() {
.addResources(defaultLocale, 'onboarding', onboarding)
.addResources(defaultLocale, 'delete-veeam', deleteVeeam)
.addResources(defaultLocale, 'error', error)
.addResources(defaultLocale, 'delete-modal', deleteModal)
.use({
type: 'postProcessor',
name: 'normalize',
Expand Down Expand Up @@ -69,5 +67,4 @@ export const labels = {
deleteVeeam,
listing,
error,
deleteModal,
};

0 comments on commit ea9fe6e

Please sign in to comment.