Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion linkis-web/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
VUE_APP_HOST=
BACKEND_URL=http://127.0.0.1:9001
VUE_APP_MN_CONFIG_PREFIX=
VUE_APP_MN_CONFIG_SOCKET=/ws/api/entrance/connect
VUE_APP_VERSION=1.8.0
# Enable or disable Python Module feature (true/false)
# Set to false if you cannot access @webank internal npm packages
VUE_APP_ENABLE_PYTHON_MODULE=false
3 changes: 2 additions & 1 deletion linkis-web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
.vscode
.cache
.idea/
.fes

node_modules/
dist/

package-lock.json
apache-linkis-*.tar.gz
./cn.json
.env.*
package-lock.json
122 changes: 122 additions & 0 deletions linkis-web/PYTHON_MODULE_CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Python Module Feature Toggle - Implementation Summary

## Changes Made

### 1. Environment Variable Configuration
**File**: `.env`
- Added `VUE_APP_ENABLE_PYTHON_MODULE=false` (default disabled)
- This controls whether the Python Module feature is available

### 2. Router Configuration
**File**: `src/apps/linkis/router.js`

**Changes**:
- Added environment variable check: `export const isPythonModuleEnabled = process.env.VUE_APP_ENABLE_PYTHON_MODULE === 'true'`
- Modified pythonModule route to be conditionally loaded:
```javascript
...(isPythonModuleEnabled ? [{
name: 'pythonModule',
path: 'pythonModule',
component: () => import('./module/pythonModule/index.vue'),
meta: {
title: 'pythonModule',
publicPage: true,
},
}] : []),
```

### 3. View Component Updates
**File**: `src/apps/linkis/view/linkis/index.vue`

**Changes**:
- Imported `isPythonModuleEnabled` from router
- Added to component data: `isPythonModuleEnabled: isPythonModuleEnabled`
- Modified sidebar menu visibility condition to hide Python Module when disabled:
```javascript
v-if="(!isLogAdmin? ...) && (item.key !== '1-13' || isPythonModuleEnabled)"
```
- Updated default redirect logic in `mounted()`:
```javascript
if(!localStorage.getItem('hasRead')) {
if (isPythonModuleEnabled) {
this.clickToRoute('1-13-1') // Python Module
} else {
this.clickToRoute('1-1') // Global History
}
}
```

## Feature Behavior

### When VUE_APP_ENABLE_PYTHON_MODULE=false (Default)
✅ **Recommended for users without WeBank npm registry access**

- Python Module route is NOT registered
- Python Module menu item is HIDDEN from sidebar
- After login, users are redirected to **Global History** page
- Accessing `/console/pythonModule` directly will show 404 error
- No dependency on internal `@webank` packages required

### When VUE_APP_ENABLE_PYTHON_MODULE=true
⚠️ **Requires WeBank internal npm registry access**

- Python Module route is registered
- Python Module menu item is VISIBLE in sidebar
- After login, users are redirected to **Python Module** page (if first time)
- Accessing `/console/pythonModule` directly works normally
- Requires successful build of PythonModule sub-application

## Testing

To test the feature toggle:

### Test 1: Disabled State (Default)
```bash
# 1. Ensure .env has VUE_APP_ENABLE_PYTHON_MODULE=false
cat linkis-web/.env | grep VUE_APP_ENABLE_PYTHON_MODULE

# 2. Rebuild
cd linkis-web
npm run build

# 3. Verify behavior:
# - Python Module menu should NOT appear in sidebar
# - Login should redirect to Global History
# - /console/pythonModule should return 404
```

### Test 2: Enabled State
```bash
# 1. Update .env
echo "VUE_APP_ENABLE_PYTHON_MODULE=true" >> linkis-web/.env

# 2. Rebuild
cd linkis-web
npm run build

# 3. Verify behavior:
# - Python Module menu should appear in sidebar
# - Login should redirect to Python Module
# - /console/pythonModule should work (if built)
```

## Migration Notes

- **Backward Compatibility**: Default is `false`, so existing deployments won't be affected
- **No Breaking Changes**: All other features remain unchanged
- **Easy Rollback**: Simply set `VUE_APP_ENABLE_PYTHON_MODULE=false` and rebuild

## Documentation

- Detailed configuration guide: `PYTHON_MODULE_CONFIG.md`
- This summary document: `PYTHON_MODULE_CHANGES.md`

## Next Steps

For users who want to enable Python Module:
1. Obtain access to WeBank internal npm registry
2. Configure `.npmrc` with registry credentials
3. Set `VUE_APP_ENABLE_PYTHON_MODULE=true` in `.env`
4. Run `npm run installAll` to install all dependencies
5. Run `npm run buildSubModule` to build Python Module
6. Run `npm run build` to build main application
95 changes: 95 additions & 0 deletions linkis-web/PYTHON_MODULE_CONFIG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Python Module Feature Configuration

## Overview

The Python Module feature can be enabled or disabled via environment variable configuration. This feature depends on internal WeBank npm packages (`@webank/fes-design-material`, `@webank/letgo-components`) which are not publicly available.

## Configuration

### Environment Variable

Edit the `.env` file in the `linkis-web` root directory:

```bash
# Enable or disable Python Module feature (true/false)
# Set to false if you cannot access @webank internal npm packages
VUE_APP_ENABLE_PYTHON_MODULE=false
```

### Options

- `VUE_APP_ENABLE_PYTHON_MODULE=true`: Enable Python Module feature
- The Python Module menu item will be displayed in the sidebar
- After login, users will be redirected to the Python Module page
- Requires access to WeBank internal npm registry to build

- `VUE_APP_ENABLE_PYTHON_MODULE=false`: Disable Python Module feature (Default)
- The Python Module menu item will be hidden from the sidebar
- After login, users will be redirected to the Global History page
- No special npm registry access required

## Implementation Details

### Modified Files

1. **`.env`**: Added `VUE_APP_ENABLE_PYTHON_MODULE` environment variable
2. **`src/apps/linkis/router.js`**:
- Added `isPythonModuleEnabled` constant
- Conditionally load pythonModule route
3. **`src/apps/linkis/view/linkis/index.vue`**:
- Import `isPythonModuleEnabled` from router
- Conditionally display pythonModule in sidebar menu
- Modified default redirect logic based on feature flag

### Behavior

When `VUE_APP_ENABLE_PYTHON_MODULE=false`:
- ❌ Python Module route is not registered
- ❌ Python Module menu item is hidden
- ✅ Users are redirected to Global History page after login
- ✅ Direct access to `/console/pythonModule` will show 404

When `VUE_APP_ENABLE_PYTHON_MODULE=true`:
- ✅ Python Module route is registered
- ✅ Python Module menu item is visible
- ✅ Users are redirected to Python Module page after login (if not `hasRead`)
- ✅ Direct access to `/console/pythonModule` works

## Building

After changing the environment variable:

```bash
# Rebuild the project
cd linkis-web
npm run build
```

## For Internal Users

If you have access to WeBank's internal npm registry:

1. Set `VUE_APP_ENABLE_PYTHON_MODULE=true` in `.env`
2. Configure npm registry (contact your administrator for registry URL)
3. Install dependencies: `npm run installAll`
4. Build PythonModule: `npm run buildSubModule`
5. Build main application: `npm run build`

## Troubleshooting

### Issue: 404 Error when accessing Python Module

**Solution**: Check that `VUE_APP_ENABLE_PYTHON_MODULE=true` and rebuild the application

### Issue: Python Module menu not showing

**Solution**:
1. Verify `.env` has `VUE_APP_ENABLE_PYTHON_MODULE=true`
2. Clear browser cache
3. Rebuild: `npm run build`

### Issue: Cannot install dependencies for PythonModule

**Solution**:
1. Set `VUE_APP_ENABLE_PYTHON_MODULE=false` to disable the feature
2. Or configure access to WeBank internal npm registry
31 changes: 18 additions & 13 deletions linkis-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"lint": "vue-cli-service lint --no-fix",
"fix": "eslint --ext .js,.vue src --fix",
"precommit": "lint-staged",
"preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions"
"preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
"buildSubModule": "cd src/apps/PythonModule && npm run build:prod && cd ../../..",
"installAll": "npm install && cd src/apps/PythonModule && npm install --legacy-peer-deps && cd ../../.."
},
"husky": {
"hooks": {
Expand All @@ -23,62 +25,65 @@
},
"dependencies": {
"@form-create/iview": "2.5.27",
"axios": "1.12.0",
"babel-polyfill": "6.26.0",
"core-js": "3.27.2",
"axios": "1.12.2",
"dexie": "3.2.3",
"dt-sql-parser": "3.0.5",
"eslint": "7.21.0",
"eslint-plugin-vue": "9.6.0",
"echarts": "^5.6.0",
"highlight.js": "10.7.0",
"hint.css": "^2.7.0",
"iview": "3.5.4",
"jsencrypt": "3.2.1",
"lodash": "4.17.21",
"md5": "2.3.0",
"mitt": "1.2.0",
"moment": "2.29.4",
"monaco-editor": "0.30.1",
"object-to-formdata": "4.2.2",
"path-browserify": "1.0.1",
"postcss": "8.4.31",
"qs": "6.11.0",
"reconnecting-websocket": "4.4.0",
"sass": "1.77.8",
"sql-formatter": "2.3.3",
"svgo": "3.0.2",
"v-jsoneditor": "1.4.5",
"vue": "3.0.0",
"vue": "2.6.12",
"vue-i18n": "8.22.1",
"vue-router": "3.4.8",
"vuedraggable": "2.24.3",
"vuescroll": "4.16.1",
"worker-loader": "3.0.8",
"echarts": "^5.1.1"
"xterm": "5.3.0",
"xterm-addon-fit": "0.8.0"
},
"devDependencies": {
"@intlify/vue-i18n-loader": "1.0.0",
"@vue/cli-plugin-babel": "5.0.8",
"@vue/cli-plugin-babel": "5.0.1",
"@vue/cli-plugin-eslint": "5.0.8",
"@vue/cli-service": "5.0.8",
"@vue/eslint-config-standard": "4.0.0",
"archiver": "3.1.1",
"autoprefixer": "10.4.14",
"babel-eslint": "10.1.0",
"babel-polyfill": "6.26.0",
"copy-webpack-plugin": "9.1.0",
"core-js": "3.27.2",
"csp-html-webpack-plugin": "5.1.0",
"eslint": "7.21.0",
"eslint-plugin-vue": "9.6.0",
"filemanager-webpack-plugin": "7.0.0",
"husky": "1.3.1",
"lint-staged": "13.1.1",
"material-design-icons": "3.0.1",
"mitt": "1.2.0",
"monaco-editor-webpack-plugin": "6.0.0",
"node-sass": "8.0.0",
"npm-force-resolutions": "0.0.10",
"postcss": "8.4.21",
"sass-loader": "10.4.1",
"svg-sprite-loader": "6.0.0",
"vue-cli-plugin-mockjs": "0.1.3",
"vue-template-compiler": "2.6.12",
"webpack-virtual-modules": "0.3.2"
},
"resolutions": {
"postcss": "8.4.31"
"postcss": "8.4.21"
}
}
9 changes: 9 additions & 0 deletions linkis-web/src/apps/PythonModule/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* text=auto
* text eol=lf
*.png binary
*.gif binary
*.ttf binary
*.woff binary
*.eot binary
*.woff binary
*.otf binary
2 changes: 1 addition & 1 deletion linkis-web/src/apps/PythonModule/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
~ limitations under the License.
-->

<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
Expand Down
32 changes: 32 additions & 0 deletions linkis-web/src/apps/PythonModule/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"dependencies": {
"core-js": "3.35.1",
"vue": "3.3.9",
"@vueuse/core": "10.9.0",
"lodash-es": "4.17.21",
"@qlin/request": "0.2.6",
"@webank/letgo-components": "1.1.4",
"@fesjs/fes-design": "0.8.60",
"@webank/fes-design-material": "0.2.31",
"@fesjs/traction-widget": "1.9.1",
"dayjs": "1.11.9",
"lodash": "4.17.21",
"@fesjs/fes": "3.1.10",
"@fesjs/plugin-model": "3.0.1",
"@fesjs/plugin-request": "4.0.0-rc.3",
"@fesjs/plugin-locale": "4.2.5",
"@fesjs/builder-vite": "4.0.2"
},
"name": "linkis",
"version": "1.0.0",
"scripts": {
"build:test": "cross-env FES_ENV=test fes build",
"build:prod": "cross-env FES_ENV=prod fes build",
"analyze": "cross-env ANALYZE=1 fes build",
"dev": "fes dev"
},
"devDependencies": {
"typescript": "5.3.3",
"cross-env": "7.0.3"
}
}
Loading