-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: MANAGER-15191 Signed-off-by: Paul Dickerson <[email protected]>
- Loading branch information
Paul Dickerson
authored and
Nicolas Pierre-charles
committed
Nov 22, 2024
1 parent
7ccd653
commit c9086f4
Showing
23 changed files
with
443 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './iam/iam.handler'; | ||
export * from './vcd-organization/vcd-organization.handler'; | ||
export * from './vcd-organization/vcd-datacentre.handler'; | ||
export * from './vcd-organization/vcd-datacentre-order.handler'; | ||
export * from './veeam-backup/veeam-backup.handler'; |
71 changes: 71 additions & 0 deletions
71
...ages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { PathParams } from 'msw'; | ||
import { Handler } from '../../../../../../playwright-helpers'; | ||
import { datacentreList } from './vcd-datacentre.mock'; | ||
import { computeList } from './vdc-compute.mock'; | ||
import { storageList } from './vdc-storage.mock'; | ||
|
||
export type GetDatacentresMocksParams = { | ||
isDatacentresKo?: boolean; | ||
isDatacentreUpdateKo?: boolean; | ||
nbDatacentres?: number; | ||
isComputeKO?: boolean; | ||
nbCompute?: number; | ||
isStorageKO?: boolean; | ||
nbStorage?: number; | ||
}; | ||
|
||
const findDatacentreById = (params: PathParams) => | ||
datacentreList.find(({ id }) => id === params.id); | ||
|
||
export const getDatacentresMocks = ({ | ||
isDatacentresKo, | ||
isDatacentreUpdateKo, | ||
nbDatacentres = Number.POSITIVE_INFINITY, | ||
isComputeKO, | ||
nbCompute = Number.POSITIVE_INFINITY, | ||
isStorageKO, | ||
nbStorage = Number.POSITIVE_INFINITY, | ||
}: GetDatacentresMocksParams): Handler[] => [ | ||
{ | ||
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter/:id/storage', | ||
response: isStorageKO | ||
? { message: 'Storage error' } | ||
: storageList.slice(0, nbStorage), | ||
api: 'v2', | ||
status: isStorageKO ? 500 : 200, | ||
}, | ||
{ | ||
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter/:id/compute', | ||
response: isComputeKO | ||
? { message: 'Compute error' } | ||
: computeList.slice(0, nbCompute), | ||
api: 'v2', | ||
status: isComputeKO ? 500 : 200, | ||
}, | ||
{ | ||
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter', | ||
response: isDatacentresKo | ||
? { message: 'Datacentres error' } | ||
: datacentreList.slice(0, nbDatacentres), | ||
api: 'v2', | ||
status: isDatacentresKo ? 500 : 200, | ||
}, | ||
{ | ||
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter/:id', | ||
response: (_: unknown, params: PathParams) => | ||
isDatacentresKo | ||
? { message: 'Datacentre error' } | ||
: findDatacentreById(params), | ||
api: 'v2', | ||
status: isDatacentresKo ? 500 : 200, | ||
}, | ||
{ | ||
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter/:id', | ||
response: isDatacentreUpdateKo | ||
? { message: 'Datacentre update error' } | ||
: {}, | ||
method: 'put', | ||
api: 'v2', | ||
status: isDatacentreUpdateKo ? 500 : 200, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/manager/apps/hpc-vmware-managed-vcd/src/components/message/Message.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
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, | ||
} from '@ovhcloud/ods-components'; | ||
import { MessageType, useMessageContext } from '@/context/Message.context'; | ||
|
||
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, | ||
}; | ||
|
||
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, | ||
persistent, | ||
includedSubRoutes, | ||
excludedSubRoutes, | ||
duration, | ||
} = message; | ||
|
||
useEffect(() => { | ||
if ( | ||
!includedSubRoutes.every((route) => pathname.includes(route)) || | ||
excludedSubRoutes.some((route) => pathname.includes(route)) | ||
) { | ||
clearMessage(uid); | ||
} | ||
}, [uid, includedSubRoutes, excludedSubRoutes, pathname]); | ||
|
||
useEffect(() => { | ||
if (!duration) return; | ||
const durationTimeout = setTimeout(() => clearMessage(uid), duration); | ||
|
||
// eslint-disable-next-line consistent-return | ||
return () => clearTimeout(durationTimeout); | ||
}, [duration]); | ||
|
||
return ( | ||
<OsdsMessage | ||
className="mb-2" | ||
type={getMessageColor(type)} | ||
{...(persistent | ||
? {} | ||
: { | ||
removable: true, | ||
onOdsRemoveClick: () => clearMessage(uid), | ||
})} | ||
> | ||
<OsdsText | ||
color={getTextColor(type)} | ||
size={ODS_THEME_TYPOGRAPHY_SIZE._400} | ||
> | ||
{content} | ||
</OsdsText> | ||
</OsdsMessage> | ||
); | ||
}; |
15 changes: 15 additions & 0 deletions
15
...ages/manager/apps/hpc-vmware-managed-vcd/src/components/message/MessageList.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { useMessageContext } from '@/context/Message.context'; | ||
import { Message } from './Message.component'; | ||
|
||
export const MessageList: React.FC = () => { | ||
const { messages } = useMessageContext(); | ||
|
||
return ( | ||
<> | ||
{messages.map((message) => ( | ||
<Message key={message.uid} message={message} /> | ||
))} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.