Skip to content

Commit

Permalink
feat(ips): init ips react app
Browse files Browse the repository at this point in the history
ref: MANAGER-15657

Signed-off-by: Quentin Pavy <[email protected]>
  • Loading branch information
Quentin Pavy committed Nov 15, 2024
1 parent e94354c commit 287eb9a
Show file tree
Hide file tree
Showing 40 changed files with 991 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/manager/apps/ips/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @ovh-ux/manager-ips-app

> ips manager app
20 changes: 20 additions & 0 deletions packages/manager/apps/ips/cucumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const isCI = process.env.CI;

module.exports = {
default: {
paths: ['e2e/features/**/*.feature'],
require: [
'../../../../playwright-helpers/bdd-setup.ts',
'e2e/**/*.step.ts',
],
requireModule: ['ts-node/register'],
format: [
'summary',
isCI ? 'progress' : 'progress-bar',
!isCI && ['html', 'e2e/reports/cucumber-results-report.html'],
!isCI && ['usage-json', 'e2e/reports/cucumber-usage-report.json'],
].filter(Boolean),
formatOptions: { snippetInterface: 'async-await' },
retry: 1,
},
};
22 changes: 22 additions & 0 deletions packages/manager/apps/ips/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="mobile-web-app-capable" content="yes" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>OVHcloud</title>
<link rel="shortcut icon" href="images/favicon.png" />
<link rel="apple-touch-icon" href="images/touchicon-180.png" />
</head>
<body>
<noscript>
<strong>
We're sorry but this application doesn't work properly without
JavaScript enabled. Please enable it to continue.
</strong>
</noscript>
<div id="root"></div>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions packages/manager/apps/ips/mocks/example/example-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"id": 20374
},
{
"id": 20375
},
{
"id": 20379
}
]
30 changes: 30 additions & 0 deletions packages/manager/apps/ips/mocks/example/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Handler } from '../../../../../../playwright-helpers';
import exampleList from './example-data.json';

export type GetExampleMocksParams = { isKo?: boolean; nb?: number };

export const getExampleMocks = ({
isKo,
nb = Number.POSITIVE_INFINITY,
}: GetExampleMocksParams): Handler[] => [
{
url: '*',
response: isKo
? {
message: 'Example error',
}
: exampleList.slice(0, nb),
status: isKo ? 500 : 200,
api: 'v6',
},
{
url: '*',
response: isKo
? {
message: 'Example error',
}
: exampleList.slice(0, nb),
status: isKo ? 500 : 200,
api: 'v2',
},
];
1 change: 1 addition & 0 deletions packages/manager/apps/ips/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './example/example';
55 changes: 55 additions & 0 deletions packages/manager/apps/ips/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@ovh-ux/manager-ips-app",
"version": "0.0.0",
"private": true,
"description": "Ips manager app",
"repository": {
"type": "git",
"url": "git+https://github.com/ovh/manager.git",
"directory": "packages/manager/apps/ips"
},
"license": "BSD-3-Clause",
"author": "OVH SAS",
"scripts": {
"build": "tsc && vite build",
"dev": "tsc && vite",
"start": "lerna exec --stream --scope='@ovh-ux/manager-ips-app' --include-dependencies -- npm run build --if-present",
"start:dev": "lerna exec --stream --scope='@ovh-ux/manager-ips-app' --include-dependencies -- npm run dev --if-present",
"start:watch": "lerna exec --stream --parallel --scope='@ovh-ux/manager-ips-app' --include-dependencies -- npm run dev:watch --if-present"
},
"dependencies": {
"@ovh-ux/manager-config": "*",
"@ovh-ux/manager-core-api": "*",
"@ovh-ux/manager-core-utils": "*",
"@ovh-ux/manager-react-components": "2.1.0",
"@ovh-ux/manager-react-core-application": "*",
"@ovh-ux/manager-react-shell-client": "^0.8.1",
"@ovh-ux/manager-tailwind-config": "*",
"@ovh-ux/request-tagger": "^0.4.0",
"@ovhcloud/ods-common-core": "^18.3.0",
"@ovhcloud/ods-components": "18.3.0",
"@ovhcloud/ods-themes": "^18.3.0",
"axios": "^1.1.2",
"clsx": "^1.2.1",
"i18next": "^23.8.2",
"i18next-http-backend": "^2.4.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.0.5",
"react-router-dom": "^6.3.0"
},
"devDependencies": {
"@cucumber/cucumber": "^10.3.1",
"@ovh-ux/manager-vite-config": "*",
"@tanstack/react-query": "^5.51.21",
"@tanstack/react-query-devtools": "^5.51.21",
"tailwindcss": "^3.4.4",
"typescript": "^5.1.6",
"vite": "^5.2.13"
},
"regions": [
"CA",
"EU",
"US"
]
}
6 changes: 6 additions & 0 deletions packages/manager/apps/ips/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "Dashboard page",
"error_service": "No services info",
"general_informations": "Informations générales",
"tab2": "Tab 2",
"back_link": "Retour à la liste"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "Bienvenue uapp",
"crumb": "ips",
"tabs_2": "Tabs 2",
"onboarding": "Onboarding"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"manager_error_page_title": "Oops …!",
"manager_error_page_button_cancel": "Annuler",
"manager_error_page_detail_code": "Code d'erreur : ",
"manager_error_page_action_reload_label": "Réessayer",
"manager_error_page_action_home_label": "Retour à la page d'accueil",
"manager_error_page_default": "Une erreur est survenue lors du chargement de la page."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Listing page",
"listing_resultats": "résultats"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": "ips",
"description": "Découvrez des services de stockage managés qui s’appuient sur le système de fichiers OpenZFS. Bénéficiez en quelques clics d’espaces de stockage centralisés pour entreposer ou sauvegarder vos données et fichiers.",
"orderButtonLabel": "Commander un ips",
"moreInfoButtonLabel": "En savoir plus sur ips",
"guideCategory": "Tutoriel",
"guide1Title": "Premiers pas avec un ips",
"guide1Description": "Découvrez comment gérer un NAS-HA depuis l'espace-client OVHcloud",
"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"
}
35 changes: 35 additions & 0 deletions packages/manager/apps/ips/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { useEffect, useContext } from 'react';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { odsSetup } from '@ovhcloud/ods-common-core';
import { ShellContext } from '@ovh-ux/manager-react-shell-client';
import { RouterProvider, createHashRouter } from 'react-router-dom';
import { Routes } from './routes/routes';

odsSetup();

const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 300_000,
},
},
});

function App() {
const { shell } = useContext(ShellContext);
const router = createHashRouter(Routes);

useEffect(() => {
shell.ux.hidePreloader();
}, []);

return (
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
<ReactQueryDevtools />
</QueryClientProvider>
);
}

export default App;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions packages/manager/apps/ips/src/components/Breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import {
OdsBreadcrumb,
OdsBreadcrumbItem,
} from '@ovhcloud/ods-components/react';
import {
useBreadcrumb,
BreadcrumbItem,
} from '@/hooks/breadcrumb/useBreadcrumb';
import appConfig from '@/ips.config';

export interface BreadcrumbProps {
customRootLabel?: string;
appName?: string;
items?: BreadcrumbItem[];
}

function Breadcrumb({ customRootLabel }: BreadcrumbProps): JSX.Element {
const label = customRootLabel || appConfig.rootLabel;

const breadcrumbItems = useBreadcrumb({
rootLabel: label,
appName: 'ips',
});
return (
<OdsBreadcrumb>
{breadcrumbItems?.map((item) => (
<OdsBreadcrumbItem
key={item.label}
href={item.href}
label={item.label}
/>
))}
</OdsBreadcrumb>
);
}

export default Breadcrumb;
18 changes: 18 additions & 0 deletions packages/manager/apps/ips/src/components/Error/Error.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.manager-error-page {
margin-left: auto;
margin-right: auto;
max-width: 600px;
width: 100%;
display: grid;
height: 100%;
overflow: hidden;
.manager-error-page-image {
img {
width: 100%;
}
}
.manager-error-page-footer {
text-align: right;
overflow: hidden;
}
}
52 changes: 52 additions & 0 deletions packages/manager/apps/ips/src/components/Error/Error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { ShellContext } from '@ovh-ux/manager-react-shell-client';
import {
ErrorMessage,
TRACKING_LABELS,
ErrorBanner,
} from '@ovh-ux/manager-react-components';

interface ErrorObject {
[key: string]: any;
}

function getTrackingTypology(error: ErrorMessage) {
if (error?.detail?.status && Math.floor(error.detail.status / 100) === 4) {
return [401, 403].includes(error.detail.status)
? TRACKING_LABELS.UNAUTHORIZED
: TRACKING_LABELS.SERVICE_NOT_FOUND;
}
return TRACKING_LABELS.PAGE_LOAD;
}

const Errors: React.FC<ErrorObject> = ({ error }) => {
const navigate = useNavigate();
const location = useLocation();
const { shell } = React.useContext(ShellContext);
const { tracking, environment } = shell;
const env = environment.getEnvironment();

React.useEffect(() => {
env.then((response) => {
const { applicationName } = response;
const name = `errors::${getTrackingTypology(error)}::${applicationName}`;
tracking.trackPage({
name,
level2: '81',
type: 'navigation',
page_category: location.pathname,
});
});
}, []);

return (
<ErrorBanner
error={error}
onReloadPage={() => navigate(location.pathname, { replace: true })}
onRedirectHome={() => navigate('/', { replace: true })}
/>
);
};

export default Errors;
12 changes: 12 additions & 0 deletions packages/manager/apps/ips/src/components/Loading/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { OdsSpinner } from '@ovhcloud/ods-components/react';

export default function Loading() {
return (
<div className="flex justify-center">
<div>
<OdsSpinner />
</div>
</div>
);
}
Loading

0 comments on commit 287eb9a

Please sign in to comment.