feat: [CDE-129]: added flag gitspace_enabled (#2214)

* feat: [CDE-129]: fixed lint
* feat: [CDE-129]: fixed lint
* feat: [CDE-129]: updated flag gitspace_enabled
* feat: [CDE-129]: updated webpack
* feat: [CDE-129]: updated webpack
* feat: [CDE-129]: added flag gitspace_enabled
unified-ui
Deepesh Kumar 2024-07-13 04:28:07 +00:00 committed by Harness
parent 6f7d1079d9
commit 0a5ed06f02
7 changed files with 14 additions and 12 deletions

View File

@ -26,6 +26,7 @@ type ConfigOutput struct {
UserSignupAllowed bool `json:"user_signup_allowed"`
PublicResourceCreationEnabled bool `json:"public_resource_creation_enabled"`
SSHEnabled bool `json:"ssh_enabled"`
GitspaceEnabled bool `json:"gitspace_enabled"`
}
// HandleGetConfig returns an http.HandlerFunc that processes an http.Request
@ -44,6 +45,7 @@ func HandleGetConfig(config *types.Config, sysCtrl *system.Controller) http.Hand
SSHEnabled: config.SSH.Enable,
UserSignupAllowed: userSignupAllowed,
PublicResourceCreationEnabled: config.PublicResourceCreationEnabled,
GitspaceEnabled: config.Gitspace.Enable,
})
}
}

View File

@ -399,6 +399,9 @@ type Config struct {
DefaultBaseImage string `envconfig:"GITNESS_GITSPACE_DEFAULT_BASE_IMAGE" default:"mcr.microsoft.com/devcontainers/base:dev-ubuntu-24.04"` //nolint:lll
// DefaultBindMountTargetPath is the target for bind mount in the Gitspace container.
DefaultBindMountTargetPath string `envconfig:"GITNESS_GITSPACE_DEFAULT_BIND_MOUNT_TARGET_PATH" default:"/gitspace"` //nolint:lll
Enable bool `envconfig:"GITNESS_GITSPACE_ENABLE" default:"false"`
// DefaultBindMountTargetPath is the source for bind mount in the Gitspace container.
// Sub-directories will be created from this eg <DefaultBindMountSourceBasePath>/gitspace/space1/space2/config1
// If left blank, it will be set to $HOME/.gitness

View File

@ -30,7 +30,6 @@ const moduleFederationConfig = require('./moduleFederation.config')
const moduleFederationConfigCDE = require('./cde/moduleFederation.config')
const CONTEXT = process.cwd()
const DEV = process.env.NODE_ENV === 'development'
const ENABLE_GITSPACE = process.env.ENABLE_GITSPACE === 'true'
const getModuleFields = () => {
if (process.env.MODULE === 'cde') {
@ -224,8 +223,7 @@ module.exports = {
moduleFederationPlugin,
new DefinePlugin({
'process.env': '{}', // required for @blueprintjs/core
__DEV__: DEV,
__ENABLE_GITSPACE__: ENABLE_GITSPACE
__DEV__: DEV
}),
new GenerateStringTypesPlugin(),
new RetryChunkLoadPlugin({

View File

@ -34,13 +34,12 @@ const API_URL = process.env.API_URL ?? 'http://localhost:3000'
const HOST = 'localhost'
const PORT = getPortByModule()
const STANDALONE = process.env.STANDALONE === 'true'
const ENABLE_GITSPACE = process.env.ENABLE_GITSPACE === 'true'
const CONTEXT = process.cwd()
const prodConfig = require('./webpack.prod')
console.info(`Starting development build... http://${HOST}:${PORT}`)
console.info('Environment variables:')
console.table({ STANDALONE, ENABLE_GITSPACE, HOST, PORT, API_URL })
console.table({ STANDALONE, HOST, PORT, API_URL })
const devConfig = {
mode: 'development',

View File

@ -19,12 +19,12 @@
"webpack:cde": "NODE_ENV=development MODULE=cde webpack serve --config config/webpack.dev.js",
"typed-scss": "typed-scss-modules src --watch",
"dev": "run-p webpack typed-scss",
"dev:cde": "MODULE=cde ENABLE_GITSPACE=true run-p webpack:cde typed-scss",
"dev:cde": "MODULE=cde run-p webpack:cde typed-scss",
"test": "jest src --silent",
"test:watch": "jest --watch",
"build": "rm -rf dist && webpack --config config/webpack.prod.js",
"build:cde": "rm -rf dist && MODULE=cde ENABLE_GITSPACE=true webpack --config config/webpack.prod.js",
"lint": "eslint --fix --rulesdir ./scripts/eslint-rules --ext .ts --ext .tsx src",
"build:cde": "rm -rf dist && MODULE=cde webpack --config config/webpack.prod.js",
"lint": "eslint --rulesdir ./scripts/eslint-rules --ext .ts --ext .tsx src",
"prettier": "prettier --check \"./src/**/*.{ts,tsx,css,scss}\"",
"coverage": "npm test --coverage",
"typecheck": "tsc",

3
web/src/global.d.ts vendored
View File

@ -17,9 +17,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
declare const __DEV__: boolean
/* eslint-disable @typescript-eslint/no-explicit-any */
declare const __ENABLE_GITSPACE__: boolean
declare module '*.png' {
const value: string
export default value

View File

@ -19,6 +19,7 @@ import { Container, Layout } from '@harnessio/uicore'
import { Render } from 'react-jsx-match'
import { useHistory, useRouteMatch } from 'react-router-dom'
import { FingerprintLockCircle, BookmarkBook, UserSquare, Settings } from 'iconoir-react'
import { useGet } from 'restful-react'
import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata'
import { useStrings } from 'framework/strings'
import type { SpaceSpaceOutput } from 'services/code'
@ -38,6 +39,8 @@ export const DefaultMenu: React.FC = () => {
const routeMatch = useRouteMatch()
const isCommitSelected = useMemo(() => routeMatch.path === '/:space*/:repoName/commit/:commitRef*', [routeMatch])
const { data: systemConfig } = useGet({ path: 'api/v1/system/config' })
const isFilesSelected = useMemo(
() =>
!isCommitSelected &&
@ -172,7 +175,7 @@ export const DefaultMenu: React.FC = () => {
</Container>
</Render>
{__ENABLE_GITSPACE__ && (
{systemConfig?.gitspace_enabled && (
<Render when={selectedSpace}>
<NavMenuItem
className=""