-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pci-common): add pci saving plan banner #14739
Closed
ppprevost
wants to merge
10
commits into
maintenance/manager-pci-common-v0.x
from
feat/add-pci-saving-plan
+151
−3
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dde40c8
ci: build and run tests only on pci-common
fredericvilcot 516a71e
feat(pci-common): add pci saving plan banner
cc1403e
feat(pci-common): fix translation
aa88f33
feat(pci-common): fix translation
d358b9a
feat(pci-common): fix tests
130a139
fix(i18n): add missing translations [CDS 171]
1c4fefd
feat(pci-common): add translation and context shell
d4e28fe
feat(pci-common): rename savings plan
27a5a5e
feat(pci-common): lint
24fa9dd
feat(pci-common): lint test and fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion
1
.../modules/manager-pci-common/src/components/banner/discovery-banner/PciDiscoveryBanner.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
58 changes: 58 additions & 0 deletions
58
...anager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.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,58 @@ | ||
import '@testing-library/jest-dom'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { | ||
ShellContext, | ||
ShellContextType, | ||
} from '@ovh-ux/manager-react-shell-client'; | ||
import { describe, it, vi } from 'vitest'; | ||
import PciSavingPlanBanner from './PciSavingsPlanBanner'; | ||
import { wrapper } from '@/wrapperRenders'; | ||
|
||
const mockNavigateTo = vi.fn(); | ||
|
||
const mockShellContext = { | ||
shell: { | ||
navigation: { | ||
navigateTo: mockNavigateTo, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('PciSavingPlanBanner tests', () => { | ||
it('should render the banner with the correct message and CTA', () => { | ||
const { container } = render( | ||
<PciSavingPlanBanner className="test-class" />, | ||
{ wrapper }, | ||
); | ||
|
||
expect( | ||
screen.getByText('pci_projects_savings_plan_banner'), | ||
).toBeInTheDocument(); | ||
|
||
expect( | ||
screen.getByText('pci_projects_savings_plan_cta'), | ||
).toBeInTheDocument(); | ||
|
||
expect(container.querySelector('.test-class')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call navigateToSavingsPlan on CTA click', async () => { | ||
render( | ||
<ShellContext.Provider | ||
value={(mockShellContext as unknown) as ShellContextType} | ||
> | ||
<PciSavingPlanBanner className="test-class" /> | ||
</ShellContext.Provider>, | ||
); | ||
|
||
const ctaButton = screen.getByText('pci_projects_savings_plan_cta'); | ||
|
||
fireEvent.click(ctaButton); | ||
|
||
expect(mockNavigateTo).toHaveBeenCalledWith( | ||
'public-cloud', | ||
`#/pci/projects/mockProjectUrl/savings-plan`, | ||
{}, | ||
); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
...les/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.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,32 @@ | ||
import { ActionBanner, useProjectUrl } from '@ovh-ux/manager-react-components'; | ||
import { ShellContext } from '@ovh-ux/manager-react-shell-client'; | ||
import { useContext } from 'react'; | ||
import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const PciSavingsPlanBanner = ({ className }: { className: string }) => { | ||
const { t } = useTranslation('savings-plan-banner'); | ||
const projectURL = useProjectUrl('public-cloud'); | ||
const { | ||
navigation: { navigateTo }, | ||
} = useContext(ShellContext).shell; | ||
const navigateToSavingsPlan = async () => { | ||
await navigateTo( | ||
'public-cloud', | ||
`#/pci/projects/${projectURL}/savings-plan`, | ||
{}, | ||
); | ||
}; | ||
|
||
return ( | ||
<ActionBanner | ||
message={t('pci_projects_savings_plan_banner')} | ||
cta={t('pci_projects_savings_plan_cta')} | ||
type={ODS_MESSAGE_TYPE.info} | ||
onClick={navigateToSavingsPlan} | ||
className={className} | ||
/> | ||
); | ||
}; | ||
|
||
export default PciSavingsPlanBanner; |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Profitieren Sie von günstigen monatlichen Preisen mit den Savings Plans und behalten Sie die Flexibilität der Instanzen auf Stundenbasis bei.", | ||
"pci_projects_savings_plan_cta": "Ihre Savings Plans konfigurieren" | ||
} |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Take advantage of low monthly rates with Savings Plans — save money without sacrificing the flexibility to use instances whenever you need them.", | ||
"pci_projects_savings_plan_cta": "Set up your Savings Plans" | ||
} |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Disfrute de tarifas mensuales más económicas gracias a los Savings Plans, manteniendo la flexibilidad de las instancias por horas.", | ||
"pci_projects_savings_plan_cta": "Configure sus Savings Plans" | ||
} |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Bénéficiez de tarifs mensuels avantageux grâce aux Savings Plans, tout en gardant la flexibilité des instances à l'heure.", | ||
"pci_projects_savings_plan_cta": "Configurez vos Savings Plans" | ||
} |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Bénéficiez de tarifs mensuels avantageux grâce aux Savings Plans, tout en gardant la flexibilité des instances à l'heure.", | ||
"pci_projects_savings_plan_cta": "Configurez vos Savings Plans" | ||
} |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Usufruisci di tariffe mensili vantaggiose grazie ai Savings Plan, conservando la flessibilità delle istanze all’ora.", | ||
"pci_projects_savings_plan_cta": "Configura i tuoi Savings Plan" | ||
} |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Dzięki Savings Plan zyskujesz korzystne opłaty miesięczne, a jednocześnie zachowujesz możliwość płatności za instancje w trybie za godzinę.", | ||
"pci_projects_savings_plan_cta": "Skonfiguruj swoje plany Savings" | ||
} |
4 changes: 4 additions & 0 deletions
4
...nager/modules/manager-pci-common/src/translations/savings-plan-banner/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,4 @@ | ||
{ | ||
"pci_projects_savings_plan_banner": "Graças aos Savings Plans, beneficie de preços mensais vantajosos, enquanto conserva a flexibilidade das instâncias à hora.", | ||
"pci_projects_savings_plan_cta": "Configure os seus Savings Plans" | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/index.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,27 @@ | ||
import i18next from 'i18next'; | ||
|
||
import de_DE from './Messages_de_DE.json'; | ||
import en_GB from './Messages_en_GB.json'; | ||
import es_ES from './Messages_es_ES.json'; | ||
import fr_CA from './Messages_fr_CA.json'; | ||
import fr_FR from './Messages_fr_FR.json'; | ||
import it_IT from './Messages_it_IT.json'; | ||
import pl_PL from './Messages_pl_PL.json'; | ||
import pt_PT from './Messages_pt_PT.json'; | ||
|
||
function addTranslations() { | ||
i18next.addResources('de_DE', 'savings-plan-banner', de_DE); | ||
i18next.addResources('en_GB', 'savings-plan-banner', en_GB); | ||
i18next.addResources('es_ES', 'savings-plan-banner', es_ES); | ||
i18next.addResources('fr_CA', 'savings-plan-banner', fr_CA); | ||
i18next.addResources('fr_FR', 'savings-plan-banner', fr_FR); | ||
i18next.addResources('it_IT', 'savings-plan-banner', it_IT); | ||
i18next.addResources('pl_PL', 'savings-plan-banner', pl_PL); | ||
i18next.addResources('pt_PT', 'savings-plan-banner', pt_PT); | ||
} | ||
|
||
if (i18next.isInitialized) { | ||
addTranslations(); | ||
} else { | ||
i18next.on('initialized', addTranslations); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this come from shell context ?