-
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 edit pool member name modal
ref: DTCORE-2661 Signed-off-by: Yoann Fievez <[email protected]>
- Loading branch information
Showing
13 changed files
with
237 additions
and
1 deletion.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Den Namen Ihres Mitglieds ändern", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Name", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Abbrechen", | ||
"octavia_load_balancer_pools_members_edit_name_confirm": "Ändern" | ||
} |
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Change your member’s name", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Name", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Cancel", | ||
"octavia_load_balancer_pools_members_edit_name_confirm": "Edit" | ||
} |
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Cambiar el nombre de su miembro", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Nombre", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Cancelar", | ||
"octavia_load_balancer_pools_members_edit_name_confirm": "Editar" | ||
} |
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Modifier le nom de votre membre", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Nom", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Annuler", | ||
"octavia_load_balancer_pools_members_edit_name_confirm": "Modifier" | ||
} |
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Modifier le nom de votre membre", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Nom", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Annuler", | ||
"octavia_load_balancer_pools_members_edit_name_confirm": "Modifier" | ||
} |
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Modifica il nome del membro", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Nome", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Annullare", | ||
"octavia_load_balancer_pools_members_edit_name_confirm": "Modificare" | ||
} |
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Zmień nazwę użytkownika", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Nazwa", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Anuluj", | ||
"octavia_load_balancer_pools_members_edit_name_confirm": "Zmień" | ||
} |
6 changes: 6 additions & 0 deletions
6
...manager/apps/pci-load-balancer/public/translations/pools/members/edit/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_pools_members_edit_name_title": "Alterar o nome do seu membro", | ||
"octavia_load_balancer_pools_members_edit_name_label": "Nome", | ||
"octavia_load_balancer_pools_members_edit_name_cancel": "Anular", | ||
"octavia_load_balancer_pools_members_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
126 changes: 126 additions & 0 deletions
126
...s/manager/apps/pci-load-balancer/src/pages/detail/pools/detail/members/edit/Edit.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,126 @@ | ||
import { PciModal } from '@ovh-ux/manager-pci-common'; | ||
import { useNotifications } from '@ovh-ux/manager-react-components'; | ||
import { Translation, useTranslation } from 'react-i18next'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { ApiError } from '@ovh-ux/manager-core-api'; | ||
import { useEffect, useState } from 'react'; | ||
import { OsdsFormField, OsdsInput } from '@ovhcloud/ods-components/react'; | ||
import { ODS_INPUT_TYPE } from '@ovhcloud/ods-components'; | ||
import { | ||
useGetPoolMember, | ||
useUpdatePoolMember, | ||
} from '@/api/hook/usePoolMember'; | ||
import LabelComponent from '@/components/form/Label.component'; | ||
|
||
export default function EditPage() { | ||
const { addSuccess, addError } = useNotifications(); | ||
const navigate = useNavigate(); | ||
const { t: tEdit } = useTranslation('pools/members/edit'); | ||
const { t: tPciCommon } = useTranslation('pci-common'); | ||
const { projectId, poolId, region, memberId } = useParams(); | ||
const onClose = () => { | ||
navigate('..'); | ||
}; | ||
|
||
const { data: poolMember, isPending: isPendingPoolMember } = useGetPoolMember( | ||
projectId, | ||
poolId, | ||
region, | ||
memberId, | ||
); | ||
const [memberName, setMemberName] = useState(''); | ||
const [isTouched, setIsTouched] = useState(false); | ||
const { | ||
updatePoolMemberName, | ||
isPending: isPendingUpdate, | ||
} = useUpdatePoolMember({ | ||
projectId, | ||
region, | ||
poolId, | ||
memberId, | ||
name: memberName, | ||
onError(error: ApiError) { | ||
addError( | ||
<Translation ns="octavia-load-balancer"> | ||
{(_t) => | ||
_t('octavia_load_balancer_global_error', { | ||
message: error?.response?.data?.message || error?.message || null, | ||
requestId: error?.config?.headers['X-OVH-MANAGER-REQUEST-ID'], | ||
}) | ||
} | ||
</Translation>, | ||
true, | ||
); | ||
onClose(); | ||
}, | ||
onSuccess() { | ||
addSuccess( | ||
<Translation ns="pools/members"> | ||
{(_t) => | ||
_t('octavia_load_balancer_pools_detail_members_edit_name_success') | ||
} | ||
</Translation>, | ||
true, | ||
); | ||
navigate('..'); | ||
}, | ||
}); | ||
|
||
const onConfirm = () => { | ||
updatePoolMemberName(); | ||
}; | ||
|
||
const onCancel = () => { | ||
navigate('..'); | ||
}; | ||
useEffect(() => { | ||
if (poolMember) { | ||
setMemberName(poolMember.name); | ||
} | ||
}, [poolMember]); | ||
return ( | ||
<PciModal | ||
title={tEdit('octavia_load_balancer_pools_members_edit_name_title')} | ||
onClose={onClose} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
type="default" | ||
isPending={isPendingPoolMember || isPendingUpdate} | ||
isDisabled={!memberName.trim()} | ||
submitText={tEdit( | ||
'octavia_load_balancer_pools_members_edit_name_confirm', | ||
)} | ||
cancelText={tEdit('octavia_load_balancer_pools_members_edit_name_cancel')} | ||
> | ||
<OsdsFormField | ||
className="mt-8" | ||
error={ | ||
isTouched && !memberName.trim() | ||
? tPciCommon('common_field_error_required') | ||
: '' | ||
} | ||
> | ||
<LabelComponent | ||
text={tEdit('octavia_load_balancer_pools_members_edit_name_label')} | ||
slot="label" | ||
hasError={isTouched && !memberName.trim()} | ||
/> | ||
<OsdsInput | ||
value={memberName} | ||
type={ODS_INPUT_TYPE.text} | ||
className={ | ||
isTouched && !memberName.trim() | ||
? 'bg-red-100 border-red-500 text-red-500 focus:text-red-500' | ||
: 'border-color-[var(--ods-color-default-200)] bg-white' | ||
} | ||
onOdsValueChange={(event) => { | ||
setMemberName(event.detail.value.trim()); | ||
}} | ||
onOdsInputBlur={() => { | ||
setIsTouched(true); | ||
}} | ||
/> | ||
</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