-
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.
Add users & roles pci µapp Updates gitignore Make img in onboarding component optional Add guides-header, action-banner unit test Bump manager-core-api ref: DTCORE-1844 Signed-off-by: Florian Renaut <[email protected]> Co-authored-by: Mohammed Hamdoune <[email protected]> Co-authored-by: Yoann Fievez <[email protected]> Co-authored-by: LIDRISSI Hamid <[email protected]>
- Loading branch information
1 parent
7e93099
commit 07959d4
Showing
153 changed files
with
7,345 additions
and
54 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,3 +1,4 @@ | ||
.idea | ||
node_modules | ||
cache | ||
dist | ||
|
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
32 changes: 32 additions & 0 deletions
32
packages/manager-components/src/components/action-banner/action-banner.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,32 @@ | ||
import { fireEvent, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { ActionBanner, ActionBannerProps } from './action-banner.component'; | ||
import { render } from '../../utils/test.provider'; | ||
|
||
const renderComponent = (props: ActionBannerProps) => { | ||
return render(<ActionBanner {...props} />); | ||
}; | ||
|
||
describe('ActionBanner tests', () => { | ||
it('should display message', () => { | ||
renderComponent({ | ||
message: 'hello world', | ||
cta: 'custom action', | ||
onClick: () => {}, | ||
}); | ||
expect(screen.getAllByText('hello world')).not.toBeNull(); | ||
}); | ||
it('should have a working call to action button', () => { | ||
const onClick = jest.fn(); | ||
renderComponent({ | ||
message: 'hello world', | ||
cta: 'custom action', | ||
onClick, | ||
}); | ||
expect(screen.getAllByText('custom action')).not.toBeNull(); | ||
const cta = screen.queryByTestId('cta'); | ||
expect(onClick).not.toHaveBeenCalled(); | ||
fireEvent.click(cta); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
...nager-components/src/components/action-banner/pci/pci-discovery-banner.component.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,46 @@ | ||
import { useNavigation } from '@ovh-ux/manager-react-shell-client'; | ||
import { fireEvent, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { | ||
isDiscoveryProject, | ||
PciDiscoveryBanner, | ||
PciDiscoveryBannerProps, | ||
} from './pci-discovery-banner.component'; | ||
import { render } from '../../../utils/test.provider'; | ||
|
||
jest.mock('@ovh-ux/manager-react-shell-client', () => { | ||
const navigateTo = jest.fn(); | ||
return { | ||
useNavigation: () => { | ||
return { | ||
navigateTo, | ||
}; | ||
}, | ||
}; | ||
}); | ||
|
||
const renderComponent = (props: PciDiscoveryBannerProps) => { | ||
return render(<PciDiscoveryBanner {...props} />); | ||
}; | ||
|
||
describe('PciDiscoveryBanner tests', () => { | ||
it('should navigate to project activation when clicking on cta', () => { | ||
const { navigateTo } = useNavigation(); | ||
renderComponent({ | ||
projectId: '123', | ||
}); | ||
const cta = screen.queryByTestId('cta'); | ||
expect(navigateTo).not.toHaveBeenCalled(); | ||
fireEvent.click(cta); | ||
expect(navigateTo).toHaveBeenCalledWith( | ||
'public-cloud', | ||
'#/pci/projects/123/activate', | ||
{}, | ||
); | ||
}); | ||
it('should identify discovery projects', () => { | ||
expect(isDiscoveryProject({ planCode: 'foo' })).toBeFalsy(); | ||
expect(isDiscoveryProject({ planCode: undefined })).toBeFalsy(); | ||
expect(isDiscoveryProject({ planCode: 'project.discovery' })).toBeTruthy(); | ||
}); | ||
}); |
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
9 changes: 9 additions & 0 deletions
9
packages/manager-components/src/components/datagrid/datagrid.contants.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,9 @@ | ||
import { PaginationState } from '@tanstack/react-table'; | ||
|
||
/* List of allowed page sizes */ | ||
export const PAGE_SIZES = [10, 25, 50, 100, 300]; | ||
|
||
export const DEFAULT_PAGINATION: PaginationState = { | ||
pageIndex: 0, | ||
pageSize: PAGE_SIZES[0], | ||
}; |
11 changes: 11 additions & 0 deletions
11
packages/manager-components/src/components/datagrid/useDatagrid.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,11 @@ | ||
import { useState } from 'react'; | ||
import { ColumnSort, PaginationState } from '@tanstack/react-table'; | ||
import { DEFAULT_PAGINATION } from './datagrid.contants'; | ||
|
||
export const useDataGrid = (defaultSorting: ColumnSort = undefined) => { | ||
const [pagination, setPagination] = useState<PaginationState>( | ||
DEFAULT_PAGINATION, | ||
); | ||
const [sorting, setSorting] = useState<ColumnSort>(defaultSorting); | ||
return { pagination, setPagination, sorting, setSorting }; | ||
}; |
9 changes: 2 additions & 7 deletions
9
packages/manager-components/src/components/datagrid/useDatagridSearchParams.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
140 changes: 140 additions & 0 deletions
140
packages/manager-components/src/components/filters/filter-add.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,140 @@ | ||
import React, { useMemo, useState } from 'react'; | ||
import { Filter, FilterComparator } from '@ovh-ux/manager-core-api'; | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
import { | ||
ODS_BUTTON_SIZE, | ||
ODS_INPUT_TYPE, | ||
ODS_TEXT_LEVEL, | ||
} from '@ovhcloud/ods-components'; | ||
import { | ||
OsdsButton, | ||
OsdsFormField, | ||
OsdsInput, | ||
OsdsSelect, | ||
OsdsSelectOption, | ||
OsdsText, | ||
} from '@ovhcloud/ods-components/react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import './translations'; | ||
|
||
type ColumnFilter = { | ||
id: string; | ||
label: string; | ||
comparators: FilterComparator[]; | ||
}; | ||
|
||
export type FilterAddProps = { | ||
columns: ColumnFilter[]; | ||
onAddFilter: (filter: Filter, column: ColumnFilter) => void; | ||
}; | ||
|
||
export function FilterAdd({ columns, onAddFilter }: Readonly<FilterAddProps>) { | ||
const { t } = useTranslation('filters'); | ||
|
||
const [selectedId, setSelectedId] = useState(columns?.[0]?.id || ''); | ||
const [selectedComparator, setSelectedComparator] = useState( | ||
columns?.[0]?.comparators?.[0] || FilterComparator.IsEqual, | ||
); | ||
const [value, setValue] = useState(''); | ||
|
||
const selectedColumn = useMemo( | ||
() => columns.find(({ id }) => selectedId === id), | ||
[columns, selectedId], | ||
); | ||
|
||
const submitAddFilter = () => { | ||
onAddFilter( | ||
{ | ||
key: selectedId, | ||
comparator: selectedComparator, | ||
value, | ||
}, | ||
selectedColumn, | ||
); | ||
setValue(''); | ||
}; | ||
|
||
return ( | ||
<> | ||
<OsdsFormField> | ||
<div slot="label"> | ||
<OsdsText | ||
level={ODS_TEXT_LEVEL.heading} | ||
color={ODS_THEME_COLOR_INTENT.text} | ||
> | ||
{t('common_criteria_adder_column_label')} | ||
</OsdsText> | ||
</div> | ||
<OsdsSelect | ||
value={selectedId} | ||
data-testid="add-filter_select_idColumn" | ||
onOdsValueChange={(event) => | ||
setSelectedId(event.detail.value as string) | ||
} | ||
> | ||
{columns.map(({ id, label }) => ( | ||
<OsdsSelectOption key={id} value={id}> | ||
{label} | ||
</OsdsSelectOption> | ||
))} | ||
</OsdsSelect> | ||
</OsdsFormField> | ||
<OsdsFormField className="mt-2"> | ||
<div slot="label"> | ||
<OsdsText | ||
level={ODS_TEXT_LEVEL.heading} | ||
color={ODS_THEME_COLOR_INTENT.text} | ||
> | ||
{t('common_criteria_adder_operator_label')} | ||
</OsdsText> | ||
</div> | ||
<OsdsSelect | ||
value={selectedComparator} | ||
onOdsValueChange={(event) => { | ||
setSelectedComparator(event.detail.value as FilterComparator); | ||
}} | ||
> | ||
{selectedColumn?.comparators?.map((comp) => ( | ||
<OsdsSelectOption key={comp} value={comp}> | ||
{t(`${'common_criteria_adder_operator_'}${comp}`)} | ||
</OsdsSelectOption> | ||
))} | ||
</OsdsSelect> | ||
</OsdsFormField> | ||
<OsdsFormField className="mt-2"> | ||
<div slot="label"> | ||
<OsdsText | ||
level={ODS_TEXT_LEVEL.heading} | ||
color={ODS_THEME_COLOR_INTENT.text} | ||
> | ||
{t('common_criteria_adder_value_label')} | ||
</OsdsText> | ||
</div> | ||
|
||
<OsdsInput | ||
className="border" | ||
type={ODS_INPUT_TYPE.text} | ||
color={ODS_THEME_COLOR_INTENT.primary} | ||
value={value} | ||
data-testid="filter-add_value-input" | ||
onOdsValueChange={(e) => setValue(`${e.detail.value}`)} | ||
onKeyDown={(e) => { | ||
if (e.key === 'Enter') { | ||
submitAddFilter(); | ||
} | ||
}} | ||
/> | ||
</OsdsFormField> | ||
<OsdsButton | ||
className="mt-4" | ||
color={ODS_THEME_COLOR_INTENT.primary} | ||
size={ODS_BUTTON_SIZE.sm} | ||
disabled={value ? undefined : true} | ||
onClick={submitAddFilter} | ||
data-testid="filter-add_submit" | ||
> | ||
{t('common_criteria_adder_submit_label')} | ||
</OsdsButton> | ||
</> | ||
); | ||
} |
Oops, something went wrong.