more envs

This commit is contained in:
typescreep
2025-06-11 17:37:45 +03:00
parent 4bfe0b70ea
commit cff729fb43
9 changed files with 58 additions and 19 deletions

3
.env
View File

@@ -1,7 +1,10 @@
VITE_CUSTOMIZATION_API_GROUP=incloud.io
VITE_CUSTOMIZATION_API_VERSION=v1alpha
VITE_PROJECTS_API_GROUP=incloud.io
VITE_PROJECTS_VERSION=v1alpha
VITE_PROJECTS_RESOURCE_NAME=projects
VITE_MARKETPLACE_RESOURCE_NAME=marketplacepanels
VITE_MARKETPLACE_KIND=MarketplacePanel
VITE_INSTANCES_API_GROUP=incloud.io
VITE_INSTANCES_VERSION=v1alpha1
VITE_INSTANCES_RESOURCE_NAME=v1alpha1

View File

@@ -1,8 +1,11 @@
KUBE_API_URL=
CUSTOMIZATION_API_GROUP=
CUSTOMIZATION_API_VERSION=
RPROJECTS_VERSION=
PROJECTS_API_GROUP=
PROJECTS_VERSION=
PROJECTS_RESOURCE_NAME=
MARKETPLACE_RESOURCE_NAME=
MARKETPLACE_KIND=
INSTANCES_API_GROUP=
INSTANCES_VERSION=
INSTANCES_RESOURCE_NAME=

View File

@@ -20,13 +20,18 @@ const CUSTOMIZATION_API_GROUP =
process.env.LOCAL === 'true' ? options?.CUSTOMIZATION_API_GROUP : process.env.CUSTOMIZATION_API_GROUP
const CUSTOMIZATION_API_VERSION =
process.env.LOCAL === 'true' ? options?.CUSTOMIZATION_API_VERSION : process.env.CUSTOMIZATION_API_VERSION
const RPROJECTS_VERSION = process.env.LOCAL === 'true' ? options?.RPROJECTS_VERSION : process.env.RPROJECTS_VERSION
const PROJECTS_API_GROUP = process.env.LOCAL === 'true' ? options?.PROJECTS_API_GROUP : process.env.PROJECTS_API_GROUP
const PROJECTS_VERSION = process.env.LOCAL === 'true' ? options?.PROJECTS_VERSION : process.env.PROJECTS_VERSION
const PROJECTS_RESOURCE_NAME =
process.env.LOCAL === 'true' ? options?.PROJECTS_RESOURCE_NAME : process.env.PROJECTS_RESOURCE_NAME
const MARKETPLACE_RESOURCE_NAME =
process.env.LOCAL === 'true' ? options?.MARKETPLACE_RESOURCE_NAME : process.env.MARKETPLACE_RESOURCE_NAME
const MARKETPLACE_KIND = process.env.LOCAL === 'true' ? options?.MARKETPLACE_KIND : process.env.MARKETPLACE_KIND
const INSTANCES_API_GROUP =
process.env.LOCAL === 'true' ? options?.INSTANCES_API_GROUP : process.env.INSTANCES_API_GROUP
const INSTANCES_VERSION = process.env.LOCAL === 'true' ? options?.INSTANCES_VERSION : process.env.INSTANCES_VERSION
const INSTANCES_RESOURCE_NAME =
process.env.LOCAL === 'true' ? options?.INSTANCES_RESOURCE_NAME : process.env.INSTANCES_RESOURCE_NAME
const healthcheck = require('express-healthcheck')
const promBundle = require('express-prom-bundle')
@@ -105,11 +110,14 @@ app.get(`${basePrefix ? basePrefix : ''}/env.js`, (_, res) => {
${basePrefix ? ` BASEPREFIX: "${basePrefix}",` : ''}
CUSTOMIZATION_API_GROUP: ${JSON.stringify(CUSTOMIZATION_API_GROUP) || '"check envs"'},
CUSTOMIZATION_API_VERSION: ${JSON.stringify(CUSTOMIZATION_API_VERSION) || '"check envs"'},
RPROJECTS_VERSION: ${JSON.stringify(RPROJECTS_VERSION) || '"check envs"'},
PROJECTS_API_GROUP: ${JSON.stringify(PROJECTS_API_GROUP) || '"check envs"'},
PROJECTS_VERSION: ${JSON.stringify(PROJECTS_VERSION) || '"check envs"'},
PROJECTS_RESOURCE_NAME: ${JSON.stringify(PROJECTS_RESOURCE_NAME) || '"check envs"'},
MARKETPLACE_RESOURCE_NAME: ${JSON.stringify(MARKETPLACE_RESOURCE_NAME) || '"check envs"'},
MARKETPLACE_KIND: ${JSON.stringify(MARKETPLACE_KIND) || '"check envs"'},
INSTANCES_VERSION: ${JSON.stringify(INSTANCES_VERSION) || '"check envs"'}
INSTANCES_API_GROUP: ${JSON.stringify(INSTANCES_API_GROUP) || '"check envs"'},
INSTANCES_VERSION: ${JSON.stringify(INSTANCES_VERSION) || '"check envs"'},
INSTANCES_RESOURCE_NAME: ${JSON.stringify(INSTANCES_RESOURCE_NAME) || '"check envs"'}
}
`,
)

View File

@@ -17,7 +17,13 @@ import {
} from '@prorobotech/openapi-k8s-toolkit'
import { useSelector } from 'react-redux'
import { RootState } from 'store/store'
import { BASE_API_GROUP, BASE_API_VERSION, BASE_PROJECTS_VERSION } from 'constants/customizationApiGroupAndVersion'
import {
BASE_API_GROUP,
BASE_API_VERSION,
BASE_PROJECTS_API_GROUP,
BASE_PROJECTS_VERSION,
BASE_PROJECTS_RESOURCE_NAME,
} from 'constants/customizationApiGroupAndVersion'
import { FlexGrow } from 'components'
import { TABLE_PROPS } from 'constants/tableProps'
@@ -30,9 +36,9 @@ export const ListProjects: FC = () => {
const { clusterName } = useParams()
const path = pathname
const cluster = clusterName || ''
const apiGroup = BASE_API_GROUP
const apiGroup = BASE_PROJECTS_API_GROUP
const apiVersion = BASE_PROJECTS_VERSION
const typeName = 'projects'
const typeName = BASE_PROJECTS_RESOURCE_NAME
const isNamespaced = false
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState<false | { name: string; endpoint: string }>(false)

View File

@@ -1,10 +1,14 @@
/* eslint-disable no-underscore-dangle */
export const BASE_API_GROUP = window._env_.CUSTOMIZATION_API_GROUP || import.meta.env.VITE_CUSTOMIZATION_API_GROUP
export const BASE_API_VERSION = window._env_.CUSTOMIZATION_API_VERSION || import.meta.env.VITE_CUSTOMIZATION_API_VERSION
export const BASE_PROJECTS_API_GROUP = window._env_.PROJECTS_API_GROUP || import.meta.env.VITE_PROJECTS_API_GROUP
export const BASE_PROJECTS_VERSION = window._env_.PROJECTS_VERSION || import.meta.env.VITE_PROJECTS_VERSION
export const BASE_PROJECTS_RESOURCE_NAME =
window._env_.PROJECTS_RESOURCE_NAME || import.meta.env.VITE_PROJECTS_RESOURCE_NAME
export const BASE_MARKETPLACE_RESOURCE_NAME =
window._env_.MARKETPLACE_RESOURCE_NAME || import.meta.env.VITE_MARKETPLACE_RESOURCE_NAME
export const BASE_MARKETPLACE_KIND = window._env_.MARKETPLACE_KIND || import.meta.env.VITE_MARKETPLACE_KIND
export const BASE_INSTANCES_API_GROUP = window._env_.INSTANCES_API_GROUP || import.meta.env.VITE_INSTANCES_API_GROUP
export const BASE_INSTANCES_VERSION = window._env_.INSTANCES_VERSION || import.meta.env.VITE_INSTANCES_VERSION
export const BASE_INSTANCES_RESOURCE_NAME =
window._env_.INSTANCES_RESOURCE_NAME || import.meta.env.VITE_INSTANCES_RESOURCE_NAME

View File

@@ -2,9 +2,12 @@ import { useApiResources, TClusterList, TSingleResource } from '@prorobotech/ope
import { useSelector } from 'react-redux'
import { RootState } from 'store/store'
import {
BASE_API_GROUP,
BASE_PROJECTS_API_GROUP,
BASE_PROJECTS_VERSION,
BASE_PROJECTS_RESOURCE_NAME,
BASE_INSTANCES_API_GROUP,
BASE_INSTANCES_VERSION,
BASE_INSTANCES_RESOURCE_NAME,
} from 'constants/customizationApiGroupAndVersion'
const mappedClusterToOptionInSidebar = ({ name }: TClusterList[number]): { value: string; label: string } => ({
@@ -23,18 +26,18 @@ export const useNavSelector = (clusterName?: string, projectName?: string) => {
const { data: projects } = useApiResources({
clusterName: clusterName || '',
namespace: '',
apiGroup: BASE_API_GROUP,
apiGroup: BASE_PROJECTS_API_GROUP,
apiVersion: BASE_PROJECTS_VERSION,
typeName: 'projects',
typeName: BASE_PROJECTS_RESOURCE_NAME,
limit: null,
})
const { data: instances, isSuccess: allInstancesLoadingSuccess } = useApiResources({
clusterName: clusterName || '',
namespace: '',
apiGroup: BASE_API_GROUP,
apiGroup: BASE_INSTANCES_API_GROUP,
apiVersion: BASE_INSTANCES_VERSION,
typeName: 'instances',
typeName: BASE_INSTANCES_RESOURCE_NAME,
limit: null,
})

View File

@@ -5,7 +5,11 @@ import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { TableNonCrdInfo, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion'
import {
BASE_INSTANCES_API_GROUP,
BASE_INSTANCES_VERSION,
BASE_INSTANCES_RESOURCE_NAME,
} from 'constants/customizationApiGroupAndVersion'
type TTableApiPageProps = {
forcedTheme?: 'light' | 'dark'
@@ -21,14 +25,14 @@ export const TableApiPage: FC<TTableApiPageProps> = ({ forcedTheme }) => {
const customBacklink = possibleInstance
? // ? `${baseprefix}/${clusterName}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments`
`${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
`${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
const clustererBacklink = `${baseprefix}/clusters`
// const instancesBacklink =
// apiGroup === 'apps' && apiVersion === 'v1' && typeName === 'deployments'
// ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
// ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}`
// : undefined
// const nonInstanceBackLink = namespace ? customBacklink : clustererBacklink

View File

@@ -5,7 +5,11 @@ import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { TableBuiltinInfo, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion'
import {
BASE_INSTANCES_API_GROUP,
BASE_INSTANCES_VERSION,
BASE_INSTANCES_RESOURCE_NAME,
} from 'constants/customizationApiGroupAndVersion'
type TTableBuiltinPageProps = {
forcedTheme?: 'light' | 'dark'
@@ -20,7 +24,7 @@ export const TableBuiltinPage: FC<TTableBuiltinPageProps> = ({ forcedTheme }) =>
const possibleInstance = syntheticProject && namespace ? namespace : undefined
const customBacklink = possibleInstance
? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
const clustererBacklink = `${baseprefix}/clusters`

View File

@@ -5,7 +5,11 @@ import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { TableCrdInfo, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion'
import {
BASE_INSTANCES_API_GROUP,
BASE_INSTANCES_VERSION,
BASE_INSTANCES_RESOURCE_NAME,
} from 'constants/customizationApiGroupAndVersion'
type TTableCrdPageProps = {
forcedTheme?: 'light' | 'dark'
@@ -19,7 +23,7 @@ export const TableCrdPage: FC<TTableCrdPageProps> = ({ forcedTheme }) => {
const possibleInstance = syntheticProject && namespace ? namespace : undefined
const customBacklink = possibleInstance
? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
const clustererBacklink = `${baseprefix}/clusters`