-
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.
feat(pci-load-balancer): add rename health monitor modal
DTCORE-2771 Signed-off-by: LIDRISSI Hamid <[email protected]>
- Loading branch information
1 parent
85c2f17
commit 19e5b1e
Showing
14 changed files
with
231 additions
and
2 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_de_DE.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Namen ändern", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Name", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Abbrechen", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Ändern" | ||
} |
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_en_GB.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Change name", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Name", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Cancel", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Edit" | ||
} |
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_es_ES.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Cambiar el nombre", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Nombre", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Cancelar", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Editar" | ||
} |
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_fr_CA.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Modifier le nom", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Nom", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Annuler", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Modifier" | ||
} |
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_fr_FR.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Modifier le nom", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Nom", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Annuler", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Modifier" | ||
} |
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_it_IT.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Modifica il nome", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Nome", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Annullare", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Modificare" | ||
} |
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_pl_PL.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Zmień nazwę", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Nazwa", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Anuluj", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Zmień" | ||
} |
6 changes: 6 additions & 0 deletions
6
...er/public/translations/octavia-load-balancer-health-monitor-edit-name/Messages_pt_PT.json
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,6 @@ | ||
{ | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_title": "Alterar o nome", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_label": "Nome", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel": "Anular", | ||
"octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm": "Alterar" | ||
} |
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
132 changes: 132 additions & 0 deletions
132
...balancer/src/pages/detail/pools/detail/health-monitor/rename/RenameHealthMonitor.page.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,132 @@ | ||
import { ApiError } from '@ovh-ux/manager-core-api'; | ||
import { PciModal } from '@ovh-ux/manager-pci-common'; | ||
import { useNotifications } from '@ovh-ux/manager-react-components'; | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
import { ODS_INPUT_TYPE } from '@ovhcloud/ods-components'; | ||
import { | ||
OsdsFormField, | ||
OsdsInput, | ||
OsdsText, | ||
} from '@ovhcloud/ods-components/react'; | ||
import { useMemo, useState } from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { HEALTH_MONITOR_NAME_REGEX } from '@/constants'; | ||
import LabelComponent from '@/components/form/Label.component'; | ||
import { | ||
useGetHealthMonitor, | ||
useRenameHealthMonitor, | ||
} from '@/api/hook/useHealthMonitor'; | ||
|
||
export default function RenameHealthMonitorPage() { | ||
const { t } = useTranslation( | ||
'octavia-load-balancer-health-monitor-edit-name', | ||
); | ||
const { t: tForm } = useTranslation( | ||
'octavia-load-balancer-health-monitor-form', | ||
); | ||
const { t: tCommon } = useTranslation('pci-common'); | ||
|
||
const navigate = useNavigate(); | ||
const { addSuccess, addError } = useNotifications(); | ||
|
||
const { projectId, region, poolId } = useParams(); | ||
|
||
const { | ||
data: healthMonitor, | ||
isPending: isHealthMonitorPending, | ||
} = useGetHealthMonitor({ | ||
projectId, | ||
region, | ||
poolId, | ||
}); | ||
|
||
const [isNameTouched, setIsNameTouched] = useState(false); | ||
const [editedName, setEditedName] = useState(healthMonitor?.name); | ||
|
||
const { | ||
renameHealthMonitor, | ||
isPending: isEditionPending, | ||
} = useRenameHealthMonitor({ | ||
projectId, | ||
region, | ||
healthMonitorId: healthMonitor?.id, | ||
onError(error: ApiError) { | ||
addError( | ||
<Trans | ||
i18nKey="octavia_load_balancer_global_error" | ||
ns="octavia-load-balancer" | ||
values={{ | ||
message: error?.response?.data?.message || error?.message || null, | ||
requestId: error?.config?.headers['X-OVH-MANAGER-REQUEST-ID'], | ||
}} | ||
/>, | ||
true, | ||
); | ||
navigate('..'); | ||
}, | ||
onSuccess() { | ||
addSuccess( | ||
<Trans | ||
i18nKey="octavia_load_balancer_health_monitor_detail_overview_edit_name_success" | ||
ns="octavia-load-balancer-health-monitor" | ||
/>, | ||
true, | ||
); | ||
navigate('..'); | ||
}, | ||
}); | ||
|
||
const nameError = useMemo(() => { | ||
if (isNameTouched) { | ||
if (!editedName) { | ||
return tCommon('common_field_error_required'); | ||
} | ||
if (!HEALTH_MONITOR_NAME_REGEX.test(editedName)) { | ||
return tCommon('common_field_error_pattern'); | ||
} | ||
} | ||
return ''; | ||
}, [editedName, isNameTouched]); | ||
|
||
return ( | ||
<PciModal | ||
title={t( | ||
'octavia_load_balancer_health_monitor_detail_overview_edit_name_title', | ||
)} | ||
onConfirm={() => renameHealthMonitor(editedName)} | ||
onClose={() => navigate('..')} | ||
onCancel={() => navigate('..')} | ||
isPending={isEditionPending || isHealthMonitorPending} | ||
submitText={t( | ||
'octavia_load_balancer_health_monitor_detail_overview_edit_name_confirm', | ||
)} | ||
cancelText={t( | ||
'octavia_load_balancer_health_monitor_detail_overview_edit_name_cancel', | ||
)} | ||
isDisabled={!!nameError} | ||
> | ||
<OsdsFormField className="my-8" error={nameError}> | ||
<LabelComponent | ||
text={t( | ||
'octavia_load_balancer_health_monitor_detail_overview_edit_name_label', | ||
)} | ||
hasError={!!nameError} | ||
/> | ||
|
||
<OsdsInput | ||
name="name" | ||
type={ODS_INPUT_TYPE.text} | ||
value={editedName} | ||
error={!!nameError} | ||
onOdsValueChange={(event) => setEditedName(event.detail.value)} | ||
onKeyDown={() => setIsNameTouched(true)} | ||
/> | ||
|
||
<OsdsText slot="helper" color={ODS_THEME_COLOR_INTENT.text}> | ||
{tForm('octavia_load_balancer_health_monitor_form_name_help')} | ||
</OsdsText> | ||
</OsdsFormField> | ||
</PciModal> | ||
); | ||
} |
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