Skip to content
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(generator): update e2e test script #11695

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fetchIcebergV2, fetchIcebergV6, apiClient } from '@ovh-ux/manager-core-api';
import { {{#if this.isApiV2}}fetchIcebergV2, {{/if}}{{#if this.isApiV6}}fetchIcebergV6, {{/if}}apiClient } from '@ovh-ux/manager-core-api';


{{!-- {{#if unknownTypeList}}
{{#each unknownTypeList}}
Expand Down Expand Up @@ -33,18 +34,15 @@ export const {{this.functionName}} = async ({{#if this.params}}params: {{pascalC
* Get listing with iceberg V6
*/
export const getListingIcebergV6 = async ({ {{#if this.isPCI }}projectId, {{/if}}pageSize, page }: { {{#if this.isPCI }}projectId: string, {{/if}}pageSize: number, page: number }) => {
try {
const List = await fetchIcebergV6({
route: `{{#if this.isPCI }}{{this.mainApiPathPci}}{{else}}{{this.mainApiPath}}{{/if}}`,
pageSize,
page
}).then(
({ data, status, totalCount }) => ({ data, status, totalCount }),
);
return List;
} catch (error) {
return null;
const { data, status, totalCount } = await fetchIcebergV6({
route: `{{#if this.isPCI }}{{this.mainApiPathPci}}{{else}}{{this.mainApiPath}}{{/if}}`,
pageSize,
page
});
if (status > 400) {
throw new Error();
}
return { data, status, totalCount };
};
{{/if}}

Expand All @@ -54,18 +52,15 @@ export const getListingIcebergV6 = async ({ {{#if this.isPCI }}projectId, {{/if}
*/

export const getListingIcebergV2 = async ({ {{#if this.isPCI }}projectId, {{/if}}pageSize, cursor }: { {{#if this.isPCI }}projectId: string, {{/if}}pageSize: number, cursor?: string }) => {
try {
const List = await fetchIcebergV2({
route: `{{#if this.isPCI }}{{this.mainApiPathPci}}{{else}}{{this.mainApiPath}}{{/if}}`,
pageSize,
cursor
}).then(
({ data, status, cursorNext }) => ({ data, status, cursorNext }),
);
return List;
} catch (error) {
return null;
const { data, status, cursorNext } = await fetchIcebergV2({
route: `{{#if this.isPCI }}{{this.mainApiPathPci}}{{else}}{{this.mainApiPath}}{{/if}}`,
pageSize,
cursor
});
if (status > 400) {
throw new Error();
}
return { data, status, cursorNext };
};
{{/if}}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, } from 'react';
import { useTranslation } from 'react-i18next';
import { Navigate, {{#if isPCI }}useParams, {{/if}} useNavigate, useLocation } from 'react-router-dom';
import { {{#if isPCI }}useParams, {{/if}} useNavigate, useLocation } from 'react-router-dom';
import { useInfiniteQuery } from '@tanstack/react-query';

import { OsdsButton, OsdsLink } from '@ovhcloud/ods-components/react';
Expand All @@ -20,6 +20,7 @@ import ErrorBanner from '@/components/Error/Error';
import Breadcrumb from '@/components/Breadcrumb/Breadcrumb';

import appConfig from '@/{{appName}}.config';
import { urls } from '@/routes/routes.constant';

export default function Listing() {
const { t } = useTranslation('listing');
Expand All @@ -44,6 +45,7 @@ export default function Listing() {
queryKey: [`servicesListingIceberg`],
queryFn: ({ pageParam }) => getListingIcebergV2({ {{#if isPCI }}projectId, {{/if}}pageSize, cursor: pageParam }),
staleTime: Infinity,
retry: false,
getNextPageParam: (lastPage) => lastPage.cursorNext as any,
});

Expand All @@ -54,7 +56,9 @@ export default function Listing() {
};

useEffect(() => {
if (status === 'success' && data?.pages.length > 0 && !flattenData) {
if (status === 'success' && data?.pages[0].data.length === 0) {
navigate(urls.onboarding);
} else if (status === 'success' && data?.pages.length > 0 && !flattenData) {
const tmp = Object.keys(data?.pages[0].data[0])
.filter((element) => element !== 'iam')
.map((element) => ({
Expand Down Expand Up @@ -98,8 +102,6 @@ export default function Listing() {
return (<div><Loading/></div>)
}

if (data?.length === 0) return <Navigate to="onboarding" />;

return (
<>
<div className="pt-5 pb-10">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Navigate,{{#if isPCI }} useParams, {{/if}} useNavigate, useLocation } from 'react-router-dom';
import { {{#if isPCI }} useParams, {{/if}} useNavigate, useLocation } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';

import { OsdsLink } from '@ovhcloud/ods-components/react';
Expand All @@ -19,6 +19,7 @@ import ErrorBanner from '@/components/Error/Error';
import Breadcrumb from '@/components/Breadcrumb/Breadcrumb';

import appConfig from '@/{{appName}}.config';
import { urls } from '@/routes/routes.constant';

export default function Listing() {
const myConfig = appConfig;
Expand All @@ -41,6 +42,7 @@ export default function Listing() {
const { data, isError, error, isLoading, status }: any = useQuery({
queryKey: [`servicesListingIceberg-${pageIndex + 1}-${pageSize}`],
queryFn: () => getListingIcebergV6({ {{#if isPCI }}projectId, {{/if}}pageSize, page: pageIndex + 1 }),
retry: false,
staleTime: Infinity,
enabled: true,
});
Expand All @@ -53,34 +55,38 @@ export default function Listing() {

useEffect(() => {
if (status === 'success' && data?.data) {
setRes(data?.data);
const newColumns = Object.keys(data?.data[0])
.filter((element) => element !== 'iam')
.map((element) => ({
id: element,
header: element,
label: element,
accessorKey: element,
cell: (props: any) => {
const label = props[element] as string;
if (typeof label === 'string' || typeof label === 'number') {
if (serviceKey === element)
return (
<DataGridTextCell>
<OsdsLink
color={ODS_THEME_COLOR_INTENT.primary}
onClick={() => navigateToDashabord(label)}
>
{label}
</OsdsLink>
</DataGridTextCell>
);
return <DataGridTextCell>{label}</DataGridTextCell>;
}
return <div>-</div>;
},
}));
setColumns(newColumns);
if (data?.data.length === 0) {
navigate(urls.onboarding);
} else {
setRes(data?.data);
const newColumns = Object.keys(data?.data[0])
.filter((element) => element !== 'iam')
.map((element) => ({
id: element,
header: element,
label: element,
accessorKey: element,
cell: (props: any) => {
const label = props[element] as string;
if (typeof label === 'string' || typeof label === 'number') {
if (serviceKey === element)
return (
<DataGridTextCell>
<OsdsLink
color={ODS_THEME_COLOR_INTENT.primary}
onClick={() => navigateToDashabord(label)}
>
{label}
</OsdsLink>
</DataGridTextCell>
);
return <DataGridTextCell>{label}</DataGridTextCell>;
}
return <div>-</div>;
},
}));
setColumns(newColumns);
}
}
}, [data?.data]);

Expand All @@ -92,8 +98,6 @@ export default function Listing() {
return (<div><Loading/></div>)
}

if (data?.length === 0) return <Navigate to="onboarding" />;

return (
<>
<div className="pt-5 pb-10">
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"guide2Title": "Monter votre NAS via un partage NFS",
"guide2Description": "Découvrez comment monter un NAS via un partage NFS",
"guide3Title": "Monter votre NAS sur Windows Server via CIFS",
"guide3Description": "Découvrez comment monter un NAS sur Windows Server via le protocole CIFS",
"guide3Description": "Découvrez comment monter un NAS sur Windows Server via le protocole CIFS"
}
Loading
Loading