-
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 modal to change pool name
ref: DTCORE-2652 Signed-off-by: Yoann Fievez <[email protected]>
- Loading branch information
Showing
19 changed files
with
175 additions
and
29 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Namen ändern", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Name", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Abbrechen", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_confirm": "Ändern" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Change the name", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Name", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Cancel", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_confirm": "Edit" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Cambiar el nombre", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Nombre", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Cancelar", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_confirm": "Editar" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Modifier le nom", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Nom", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Annuler", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_confirm": "Modifier" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Modifier le nom", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Nom", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Annuler", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_confirm": "Modifier" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Modifica il nome", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Nome", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Annullare", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_confirm": "Modificare" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Zmień nazwę", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Nazwa", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Anuluj", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_confirm": "Zmień" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r/apps/pci-load-balancer/public/translations/pools/overview/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_pools_detail_overview_edit_name_title": "Alterar o nome", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_label": "Nome", | ||
"octavia_load_balancer_pools_detail_overview_edit_name_cancel": "Anular", | ||
"octavia_load_balancer_pools_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,6 @@ export const updatePool = async ({ | |
: { type: 'disabled' }, | ||
}, | ||
); | ||
|
||
return data; | ||
}; | ||
|
||
|
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
107 changes: 107 additions & 0 deletions
107
...apps/pci-load-balancer/src/pages/detail/pools/detail/overview/edit-name/EditName.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,107 @@ | ||
import { PciModal } from '@ovh-ux/manager-pci-common'; | ||
import { useNotifications } from '@ovh-ux/manager-react-components'; | ||
import { OsdsFormField, OsdsInput } from '@ovhcloud/ods-components/react'; | ||
import { Translation, useTranslation } from 'react-i18next'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { useEffect, useState } from 'react'; | ||
import { ODS_INPUT_TYPE } from '@ovhcloud/ods-components'; | ||
import { ApiError } from '@ovh-ux/manager-core-api'; | ||
import LabelComponent from '@/components/form/Label.component'; | ||
import { useGetPool, useUpdatePool } from '@/api/hook/usePool'; | ||
|
||
export default function EditName() { | ||
const { addSuccess, addError } = useNotifications(); | ||
const { t: tEditName } = useTranslation('pools/overview/edit-name'); | ||
const navigate = useNavigate(); | ||
const { projectId, region, poolId } = useParams(); | ||
const { data: pool, isPending: isPendingPool } = useGetPool({ | ||
projectId, | ||
region, | ||
poolId, | ||
}); | ||
const { doUpdatePool, isPending: isPendingUpdatePool } = useUpdatePool({ | ||
projectId, | ||
region, | ||
poolId, | ||
onSuccess: () => { | ||
addSuccess( | ||
<Translation ns="pools/overview"> | ||
{(_t) => | ||
_t('octavia_load_balancer_pools_detail_overview_edit_name_success') | ||
} | ||
</Translation>, | ||
false, | ||
); | ||
navigate('..'); | ||
}, | ||
onError: (cause: ApiError) => { | ||
addError( | ||
<Translation ns="load-balancer"> | ||
{(_t) => ( | ||
<span | ||
dangerouslySetInnerHTML={{ | ||
__html: _t('octavia_load_balancer_global_error', { | ||
message: (cause?.response?.data as { message: string }) | ||
?.message, | ||
requestId: cause.response?.headers['x-ovh-queryid'], | ||
}), | ||
}} | ||
></span> | ||
)} | ||
</Translation>, | ||
true, | ||
); | ||
navigate('..'); | ||
}, | ||
}); | ||
const [poolName, setPoolName] = useState(pool?.name); | ||
useEffect(() => { | ||
if (pool) { | ||
setPoolName(pool?.name); | ||
} | ||
}, [pool]); | ||
const onConfirm = () => { | ||
doUpdatePool({ | ||
name: poolName, | ||
algorithm: pool?.algorithm, | ||
permanentSession: { | ||
isEnabled: pool.sessionPersistence.type !== 'disabled', | ||
cookieName: pool.sessionPersistence.cookieName, | ||
type: pool.sessionPersistence.type, | ||
}, | ||
}); | ||
}; | ||
const isPending = isPendingPool || isPendingUpdatePool; | ||
return ( | ||
<PciModal | ||
title={tEditName( | ||
'octavia_load_balancer_pools_detail_overview_edit_name_title', | ||
)} | ||
onCancel={() => navigate('..')} | ||
onClose={() => navigate('..')} | ||
submitText={tEditName( | ||
'octavia_load_balancer_pools_detail_overview_edit_name_confirm', | ||
)} | ||
cancelText={tEditName( | ||
'octavia_load_balancer_pools_detail_overview_edit_name_cancel', | ||
)} | ||
isPending={isPending} | ||
onConfirm={onConfirm} | ||
> | ||
<OsdsFormField> | ||
<LabelComponent | ||
text={tEditName( | ||
'octavia_load_balancer_pools_detail_overview_edit_name_label', | ||
)} | ||
/> | ||
<OsdsInput | ||
value={poolName} | ||
type={ODS_INPUT_TYPE.text} | ||
onOdsValueChange={(event) => { | ||
setPoolName(event.detail.value); | ||
}} | ||
/> | ||
</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
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