diff --git a/frontend/codegen.ts b/frontend/codegen.ts
new file mode 100644
index 000000000..be9cdbdb5
--- /dev/null
+++ b/frontend/codegen.ts
@@ -0,0 +1,27 @@
+import { CodegenConfig } from '@graphql-codegen/cli';
+
+const schemaUrl =
+ (process.env.GRAPHQL_URL || 'https://graphql.preprod.crownlabs.polito.it') +
+ '/schema';
+
+const config: CodegenConfig = {
+ schema: {
+ [schemaUrl]: { handleAsSDL: true },
+ },
+ documents: ['./src/**/*.{graphql,ts}'],
+ generates: {
+ './src/generated-types.tsx': {
+ config: {
+ preResolveTypes: true,
+ },
+ plugins: [
+ 'typescript',
+ 'typescript-operations',
+ 'typescript-react-apollo',
+ ],
+ },
+ },
+ config: {},
+};
+
+export default config;
diff --git a/frontend/codegen.yml b/frontend/codegen.yml
deleted file mode 100644
index 3e5e39a4d..000000000
--- a/frontend/codegen.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-overwrite: true
-schema: schema.graphql
-documents: './src/**/*.{graphql,ts}'
-generates:
- src/generated-types.tsx:
- config:
- withComponent: true
- preResolveTypes: true
- plugins:
- - 'typescript'
- - 'typescript-operations'
- - 'typescript-react-apollo'
diff --git a/frontend/package.json b/frontend/package.json
index dfd1c459b..7658db458 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -5,7 +5,6 @@
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@apollo/client": "^3.3.20",
- "@apollo/react-hooks": "^4.0.0",
"@craco/craco": "^6.1.1",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
@@ -28,7 +27,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
- "typescript": "^4.1.2",
+ "typescript": "^5.6.3",
"web-vitals": "^1.0.1",
"ws": "^8.2.2"
},
@@ -39,7 +38,7 @@
"prepare": "cd .. && husky install frontend/.husky",
"check-format-lint": "prettier --check **/*.{ts,tsx,js,jsx,json,css,graphql} && eslint . --ext .ts --ext .tsx --ext .js --ext .jsx --max-warnings=0",
"pre-commit": "lint-staged",
- "generate": "curl https://graphql.preprod.crownlabs.polito.it/schema -o schema.graphql && graphql-codegen --config codegen.yml ; rm -f schema.graphql"
+ "generate": "graphql-codegen"
},
"eslintConfig": {
"extends": [
@@ -96,11 +95,10 @@
]
},
"devDependencies": {
- "@graphql-codegen/cli": "1.21.6",
- "@graphql-codegen/introspection": "1.18.2",
- "@graphql-codegen/typescript": "1.22.4",
- "@graphql-codegen/typescript-operations": "1.18.3",
- "@graphql-codegen/typescript-react-apollo": "2.2.8",
+ "@graphql-codegen/cli": "^5.0.3",
+ "@graphql-codegen/typescript": "^4.1.1",
+ "@graphql-codegen/typescript-operations": "^4.3.1",
+ "@graphql-codegen/typescript-react-apollo": "^4.3.2",
"@tailwindcss/postcss7-compat": "npm:@tailwindcss/postcss7-compat",
"autoprefixer": "^9",
"eslint-config-prettier": "^8.3.0",
diff --git a/frontend/src/components/activePage/TableInstance/RowInstanceActions/RowInstanceActionsDropdown.tsx b/frontend/src/components/activePage/TableInstance/RowInstanceActions/RowInstanceActionsDropdown.tsx
index 93ab548a4..d70f6bab8 100644
--- a/frontend/src/components/activePage/TableInstance/RowInstanceActions/RowInstanceActionsDropdown.tsx
+++ b/frontend/src/components/activePage/TableInstance/RowInstanceActions/RowInstanceActionsDropdown.tsx
@@ -71,12 +71,12 @@ const RowInstanceActionsDropdown: FC = ({
};
const statusComponents = {
- Ready: {
+ [Phase.Ready]: {
menuKey: 'stop',
menuIcon: ,
menuText: 'Stop',
},
- Off: {
+ [Phase.Off]: {
menuKey: 'start',
menuIcon: ,
menuText: 'Start',
diff --git a/frontend/src/components/activePage/TableInstance/RowInstanceStatus/RowInstanceStatus.tsx b/frontend/src/components/activePage/TableInstance/RowInstanceStatus/RowInstanceStatus.tsx
index b4c564de2..debd12e18 100644
--- a/frontend/src/components/activePage/TableInstance/RowInstanceStatus/RowInstanceStatus.tsx
+++ b/frontend/src/components/activePage/TableInstance/RowInstanceStatus/RowInstanceStatus.tsx
@@ -18,26 +18,36 @@ const RowInstanceStatus: FC = ({ ...props }) => {
const font20px = { fontSize: '20px' };
const statusIcon = {
- Unknown: ,
- CreationLoopBackoff: (
+ [Phase.Empty]: (
),
- Running: ,
- Importing: (
+ [Phase.CreationLoopBackoff]: (
+
+ ),
+ [Phase.Running]: (
),
- ResourceQuotaExceeded: (
+ [Phase.Importing]: (
+
+ ),
+ [Phase.ResourceQuotaExceeded]: (
),
- Ready: (
+ [Phase.Ready]: (
),
- Failed: (
+ [Phase.Failed]: (
),
- Off: ,
- Starting: ,
- Stopping: ,
+ [Phase.Off]: (
+
+ ),
+ [Phase.Starting]: (
+
+ ),
+ [Phase.Stopping]: (
+
+ ),
};
return (
diff --git a/frontend/src/components/workspaces/ModalCreateTemplate/ModalCreateTemplate.tsx b/frontend/src/components/workspaces/ModalCreateTemplate/ModalCreateTemplate.tsx
index ce8305af6..45cfcae36 100644
--- a/frontend/src/components/workspaces/ModalCreateTemplate/ModalCreateTemplate.tsx
+++ b/frontend/src/components/workspaces/ModalCreateTemplate/ModalCreateTemplate.tsx
@@ -11,6 +11,7 @@ import {
import Button from 'antd-button-color';
import {
CreateTemplateMutation,
+ EnvironmentType,
useWorkspaceTemplatesQuery,
} from '../../../generated-types';
import { FetchResult } from '@apollo/client';
@@ -24,7 +25,7 @@ export type Image = {
registry: string;
};
-type Vmorcontainer = 'Container' | 'VM';
+type Vmorcontainer = EnvironmentType.VirtualMachine | EnvironmentType.Container;
type Template = {
name?: string;
@@ -316,14 +317,16 @@ const ModalCreateTemplate: FC = ({ ...props }) => {
image: String(value),
registry: imageFound?.registry,
vmorcontainer:
- imageFound?.vmorcontainer[0] ?? 'Container',
+ imageFound?.vmorcontainer[0] ??
+ EnvironmentType.Container,
persistent: false,
gui: true,
};
});
form.setFieldsValue({
image: value,
- vmorcontainer: imageFound?.vmorcontainer[0] ?? 'Container',
+ vmorcontainer:
+ imageFound?.vmorcontainer[0] ?? EnvironmentType.Container,
});
}
}}
diff --git a/frontend/src/components/workspaces/WorkspaceContainer/WorkspaceContainer.tsx b/frontend/src/components/workspaces/WorkspaceContainer/WorkspaceContainer.tsx
index 8308e8acc..02ca7c63b 100644
--- a/frontend/src/components/workspaces/WorkspaceContainer/WorkspaceContainer.tsx
+++ b/frontend/src/components/workspaces/WorkspaceContainer/WorkspaceContainer.tsx
@@ -9,7 +9,7 @@ import {
useCreateTemplateMutation,
useImagesQuery,
} from '../../../generated-types';
-import { Workspace } from '../../../utils';
+import { JSONDeepCopy, Workspace, WorkspaceRole } from '../../../utils';
import UserListLogic from '../../accountPage/UserListLogic/UserListLogic';
import Box from '../../common/Box';
import ModalCreateTemplate from '../ModalCreateTemplate';
@@ -24,7 +24,7 @@ export interface IWorkspaceContainerProps {
const getImages = (dataImages: ImagesQuery) => {
let images: Image[] = [];
- dataImages?.imageList?.images?.forEach(i => {
+ JSONDeepCopy(dataImages?.imageList?.images)?.forEach(i => {
const registry = i?.spec?.registryName!;
const imagesRaw = i?.spec?.images;
imagesRaw?.forEach(ir => {
@@ -36,7 +36,7 @@ const getImages = (dataImages: ImagesQuery) => {
versionsInImageName = [
{
name: latestVersion,
- vmorcontainer: ['VM'],
+ vmorcontainer: [EnvironmentType.VirtualMachine],
registry: registry!,
},
];
@@ -44,7 +44,7 @@ const getImages = (dataImages: ImagesQuery) => {
versionsInImageName = ir?.versions?.map(v => {
return {
name: `${ir?.name!}:${v}`,
- vmorcontainer: ['Container'],
+ vmorcontainer: [EnvironmentType.Container],
registry: registry!,
};
})!;
@@ -122,7 +122,7 @@ const WorkspaceContainer: FC = ({ ...props }) => {
),
- left: workspace.role === 'manager' && (
+ left: workspace.role === WorkspaceRole.manager && (
),
- right: workspace.role === 'manager' && (
+ right: workspace.role === WorkspaceRole.manager && (