diff --git a/.env.k8sApp b/.env.k8sApp deleted file mode 100644 index 39e520f1ea..0000000000 --- a/.env.k8sApp +++ /dev/null @@ -1,2 +0,0 @@ -VITE_HIDE_DISCORD=true -K8S_CLIENT=true \ No newline at end of file diff --git a/package.json b/package.json index a4c304357a..e5663e476e 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "build": "NODE_OPTIONS=--max_old_space_size=4096 vite build", "serve": "vite preview", "build-light": "NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false vite build", - "build-k8s-app": "NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false VITE_K8S_CLIENT=true vite build", + "build-k8s-app": "NODE_OPTIONS=--max_old_space_size=4096 GENERATE_SOURCEMAP=false vite build --mode K8S_CLIENT", "test": "vitest test", "test-coverage:watch": "npm run test -- --coverage", "test-coverage": "npm run test -- --coverage --watchAll=false", diff --git a/src/components/ClusterNodes/ClusterOverview.tsx b/src/components/ClusterNodes/ClusterOverview.tsx index 96ac52af7e..6b640884fc 100644 --- a/src/components/ClusterNodes/ClusterOverview.tsx +++ b/src/components/ClusterNodes/ClusterOverview.tsx @@ -460,7 +460,7 @@ function ClusterOverview({ isSuperAdmin, selectedCluster }: ClusterOverviewProps = ({ {/* NOTE: visible-hover plays with display prop; therefore need to set display: flex on a new div */}
- {!!clusterData.nodeCount && !clusterListLoader && isSuperAdmin && ( - -
- -
-
+ {!!clusterData.nodeCount && + !clusterListLoader && + (isSuperAdmin || window._env_.K8S_CLIENT) && ( + +
+ +
+
+ )} + {!window._env_.K8S_CLIENT && KubeConfigButton && ( + )} - {KubeConfigButton && }
diff --git a/src/components/ResourceBrowser/ResourceList/ResourceList.tsx b/src/components/ResourceBrowser/ResourceList/ResourceList.tsx index 5a0506db2b..1454b6086d 100644 --- a/src/components/ResourceBrowser/ResourceList/ResourceList.tsx +++ b/src/components/ResourceBrowser/ResourceList/ResourceList.tsx @@ -100,7 +100,7 @@ const ResourceList = () => { [clusterId, clusterOptions], ) - const isSuperAdmin = !!userRole?.result.superAdmin + const isSuperAdmin = (selectedCluster.label && window._env_.K8S_CLIENT) || !!userRole?.result.superAdmin const isOverviewNodeType = nodeType === SIDEBAR_KEYS.overviewGVK.Kind.toLowerCase() const isTerminalNodeType = nodeType === AppDetailsTabs.terminal diff --git a/src/components/cluster/Cluster.tsx b/src/components/cluster/Cluster.tsx index c638cf6d2e..5e69a72b76 100644 --- a/src/components/cluster/Cluster.tsx +++ b/src/components/cluster/Cluster.tsx @@ -49,7 +49,7 @@ import { ReactComponent as VirtualClusterIcon } from '../../assets/icons/ic-virt import { ReactComponent as VirtualEnvIcon } from '../../assets/icons/ic-environment-temp.svg' import { ClusterComponentModal } from './ClusterComponentModal' import { ClusterInstallStatus } from './ClusterInstallStatus' -import { POLLING_INTERVAL, ClusterListProps, AuthenticationType } from './cluster.type' +import { POLLING_INTERVAL, ClusterListProps, AuthenticationType, DEFAULT_CLUSTER_ID } from './cluster.type' import { DOCUMENTATION, SERVER_MODE, ViewType, URLS, CONFIGURATION_TYPES, AppCreationType } from '../../config' import { getEnvName } from './cluster.util' import { DC_ENVIRONMENT_CONFIRMATION_MESSAGE, DeleteComponentsName } from '../../config/constantMessaging' @@ -358,7 +358,7 @@ const Cluster = ({ const drawerRef = useRef(null) const isDefaultCluster = (): boolean => { - return id == 1 + return id == DEFAULT_CLUSTER_ID } const { state } = useForm( @@ -480,7 +480,10 @@ const Cluster = ({ try { const { result } = await getCluster(clusterId) setPrometheusAuth(result.prometheusAuth) - setConfig({ ...result.config, ...(clusterId != 1 ? { bearer_token: DEFAULT_SECRET_PLACEHOLDER } : null) }) + setConfig({ + ...result.config, + ...(clusterId != DEFAULT_CLUSTER_ID ? { bearer_token: DEFAULT_SECRET_PLACEHOLDER } : null), + }) toggleEditMode((t) => !t) } catch (err) { showError(err) @@ -667,7 +670,7 @@ const Cluster = ({ subtitle={subTitle} className="fw-6 dc__mxw-400 dc__truncate-text" /> - {clusterId && ( + {!window._env_.K8S_CLIENT && clusterId && (
)} - {!window._env_.K8S_CLIENT && Array.isArray(newEnvs) && newEnvs.length > 1 ? ( -
-
-
-
{CONFIGURATION_TYPES.ENVIRONMENT}
-
{CONFIGURATION_TYPES.NAMESPACE}
-
{CONFIGURATION_TYPES.DESCRIPTION}
-
-
- {newEnvs - .sort((a, b) => sortCallback('environment_name', a, b)) - .map( - ({ - id, - environment_name, - prometheus_url, - namespace, - default: isProduction, - description, - }) => - environment_name ? ( -
- setEnvironment({ - id, - environmentName: environment_name, - clusterId, - namespace, - prometheusEndpoint: prometheus_url, - isProduction, - description, - }) - } - > - {environment_name && envIcon()} - + {!window._env_.K8S_CLIENT && + (Array.isArray(newEnvs) && newEnvs.length > 1 ? ( +
+
+
+
{CONFIGURATION_TYPES.ENVIRONMENT}
+
{CONFIGURATION_TYPES.NAMESPACE}
+
{CONFIGURATION_TYPES.DESCRIPTION}
+
+
+ {newEnvs + .sort((a, b) => sortCallback('environment_name', a, b)) + .map( + ({ + id, + environment_name, + prometheus_url, + namespace, + default: isProduction, + description, + }) => + environment_name ? (
+ setEnvironment({ + id, + environmentName: environment_name, + clusterId, + namespace, + prometheusEndpoint: prometheus_url, + isProduction, + description, + }) + } > - {environment_name} - - {isProduction && ( -
- Prod -
- )} -
-
{namespace}
-
- {description} -
-
-
- -
- + + {environment_name && envIcon()} + + +
+ {environment_name} + + {isProduction && ( +
+ Prod
- - {envDelete ? ( - - ) : ( + )} +
+
{namespace}
+
+ {description} +
+
+
-
- +
- )} + {envDelete ? ( + + ) : ( + +
+ +
+
+ )} +
-
- ) : null, + ) : null, + )} + {confirmation && ( + )} - {confirmation && ( - - )} -
- ) : ( - clusterId && renderNoEnvironmentTab() - )} +
+ ) : ( + clusterId && renderNoEnvironmentTab() + ))} {editMode && (
diff --git a/src/components/cluster/ClusterForm.tsx b/src/components/cluster/ClusterForm.tsx index 58e3f1ecfb..c181a1d465 100644 --- a/src/components/cluster/ClusterForm.tsx +++ b/src/components/cluster/ClusterForm.tsx @@ -70,7 +70,6 @@ import { ReactComponent as InfoIcon } from '../../assets/icons/info-filled.svg' import ClusterInfoStepsModal from './ClusterInfoStepsModal' import { UPLOAD_STATE } from '@Pages/GlobalConfigurations/DeploymentCharts/types' import UserNameDropDownList from './UseNameListDropdown' -import { clusterId } from '../ClusterNodes/__mocks__/clusterAbout.mock' import { getModuleInfo } from '../v2/devtronStackManager/DevtronStackManager.service' import { RemoteConnectionType } from '../dockerRegistry/dockerType' @@ -140,7 +139,7 @@ export default function ClusterForm({ const authenTicationType = prometheusAuth?.userName ? AuthenticationType.BASIC : AuthenticationType.ANONYMOUS const isDefaultCluster = (): boolean => { - return id == 1 + return id == DEFAULT_CLUSTER_ID } const [deleting, setDeleting] = useState(false) const [confirmation, toggleConfirmation] = useState(false) @@ -164,7 +163,7 @@ export default function ClusterForm({ const [, grafanaModuleStatus] = useAsync( () => getModuleInfo(ModuleNameMap.GRAFANA), - [clusterId], + [DEFAULT_CLUSTER_ID], !window._env_.K8S_CLIENT, ) @@ -442,7 +441,7 @@ export default function ClusterForm({ } const handleOnBlur = (e): void => { - if (id && id !== 1 && !e.target.value) { + if (id && id !== DEFAULT_CLUSTER_ID && !e.target.value) { e.target.value = DEFAULT_SECRET_PLACEHOLDER } } @@ -735,9 +734,7 @@ export default function ClusterForm({ name="token" value={ id - ? id !== 1 - ? DEFAULT_SECRET_PLACEHOLDER - : config?.bearer_token + ? config?.bearer_token ? config.bearer_token : '' : state.token.value @@ -808,7 +805,7 @@ export default function ClusterForm({ className="dc__resizable-textarea__with-max-height w-100" name="certificateAuthorityData" value={ - id && id !== 1 && isTlsConnection + id && id !== DEFAULT_CLUSTER_ID && isTlsConnection ? DEFAULT_SECRET_PLACEHOLDER : state.certificateAuthorityData.value } @@ -833,7 +830,7 @@ export default function ClusterForm({ className="dc__resizable-textarea__with-max-height w-100" name="tlsClientKey" value={ - id && id !== 1 && isTlsConnection + id && id !== DEFAULT_CLUSTER_ID && isTlsConnection ? DEFAULT_SECRET_PLACEHOLDER : state.tlsClientKey.value } @@ -858,7 +855,7 @@ export default function ClusterForm({ className="dc__resizable-textarea__with-max-height w-100" name="tlsClientCert" value={ - id && id !== 1 && isTlsConnection + id && id !== DEFAULT_CLUSTER_ID && isTlsConnection ? DEFAULT_SECRET_PLACEHOLDER : state.tlsClientCert.value } diff --git a/src/components/cluster/cluster.type.ts b/src/components/cluster/cluster.type.ts index 1e690ffaae..4c6a5c3375 100644 --- a/src/components/cluster/cluster.type.ts +++ b/src/components/cluster/cluster.type.ts @@ -20,7 +20,7 @@ import { OptionType } from '../app/types' export const POLLING_INTERVAL = 30000 -export const DEFAULT_CLUSTER_ID = 1 +export const DEFAULT_CLUSTER_ID = window._env_.K8S_CLIENT ? -1 : 1 export const AuthenticationType = { BASIC: 'BASIC', diff --git a/src/index.tsx b/src/index.tsx index 4dac042ea5..296ba3f895 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -38,7 +38,7 @@ declare global { if (!window.__BASE_URL__ || !window.__ORCHESTRATOR_ROOT__) { window.__BASE_URL__ = import.meta.env.BASE_URL || '/dashboard' - window.__ORCHESTRATOR_ROOT__ = import.meta.env.VITE_ORCHESTRATOR_ROOT || 'orchestrator' + window.__ORCHESTRATOR_ROOT__ = import.meta.env.VITE_ORCHESTRATOR_ROOT || '/orchestrator' window.__GRAFANA_ORG_ID__ = import.meta.env.VITE_GRAFANA_ORG_ID || 2 } diff --git a/vite.config.mts b/vite.config.mts index 6b08970ec8..5c5b1f1ff0 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -92,7 +92,7 @@ const jsToBottomNoModule = () => { // https://vitejs.dev/config/ export default defineConfig(({ mode }) => { - process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') } + process.env = { ...process.env, ...loadEnv(mode, process.cwd(), ''), VITE_K8S_CLIENT: `${mode === 'K8S_CLIENT'}` } const baseConfig = { base: '/dashboard', preview: {