mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-07 22:35:36 +00:00
Resolve "Add basic feature flag support"
This commit is contained in:
parent
fe61dfe0f8
commit
74666087e9
7 changed files with 76 additions and 0 deletions
|
@ -527,6 +527,9 @@ BASEROW_AIRTABLE_IMPORT_SOFT_TIME_LIMIT = int(
|
|||
os.getenv("BASEROW_AIRTABLE_IMPORT_SOFT_TIME_LIMIT", 60 * 30) # 30 minutes
|
||||
)
|
||||
|
||||
# A comma separated list of feature flags used to enable in-progress or not ready
|
||||
# features for developers. See docs/development/feature-flags.md for more info.
|
||||
FEATURE_FLAGS = [flag.strip() for flag in os.getenv("FEATURE_FLAGS", "").split(",")]
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
|
|
|
@ -135,6 +135,7 @@ x-common-variables: &common-variables
|
|||
PRIVATE_WEB_FRONTEND_URL: http://web-frontend:3000
|
||||
PUBLIC_BACKEND_URL:
|
||||
PUBLIC_WEB_FRONTEND_URL:
|
||||
FEATURE_FLAGS:
|
||||
|
||||
x-common-backend-variables: &common-backend-variables
|
||||
<<: *backend-required-variables
|
||||
|
|
|
@ -15,6 +15,8 @@ found in the root of the Baserow repo.
|
|||
the dev environment.
|
||||
- See [intellij setup](intellij-setup.md) for how to configure Intellij
|
||||
to work well with Baserow for development purposes.
|
||||
- See [feature flags](feature-flags.md) for how Baserow uses basic feature flags for
|
||||
optionally enabling unfinished or unready features.
|
||||
|
||||
## Fixing git blame
|
||||
|
||||
|
|
55
docs/development/feature-flags.md
Normal file
55
docs/development/feature-flags.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
# Feature flags
|
||||
|
||||
Baserow uses basic feature flags currently to allow unfinished features to be merged
|
||||
and/or released.
|
||||
|
||||
## Available Feature Flags
|
||||
|
||||
Add/remove features flags to the list below:
|
||||
|
||||
## Enabling feature flags
|
||||
|
||||
To enable specific feature flags set the environment variable
|
||||
`FEATURE_FLAGS=feature1,feature2,feature3`. Using `dev.sh` this would look like:
|
||||
|
||||
```bash
|
||||
FEATURE_FLAGS=feature1,feature2,feature3 ./dev.sh xyz
|
||||
```
|
||||
|
||||
You could also use a docker-compose `.env` file and set the FEATURE_FLAGS variable in
|
||||
there.
|
||||
|
||||
## Naming convention
|
||||
|
||||
Feature flags should be:
|
||||
|
||||
1. Alphanumeric with dashes.
|
||||
2. Not start or end with spaces (flags from the env variable will be trimmed for ease of
|
||||
use).
|
||||
3. Unique per feature.
|
||||
|
||||
## Creating a feature flag
|
||||
|
||||
### In the Backend
|
||||
|
||||
```python
|
||||
# In your feature file:
|
||||
from django.conf import settings
|
||||
|
||||
if "feature1" in settings.FEATURE_FLAGS:
|
||||
# do the feature
|
||||
```
|
||||
|
||||
### In the Web-frontend
|
||||
|
||||
```javascript
|
||||
methods: {
|
||||
someComponentMethod()
|
||||
{
|
||||
if (this.$featureFlags.includes("feature1"){
|
||||
// do the feature
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -78,6 +78,8 @@ Everything related to contributing and developing for Baserow.
|
|||
helper script.
|
||||
* [IntelliJ setup](./development/intellij-setup.md): How to configure Intellij to work
|
||||
well with Baserow for development purposes.
|
||||
- [Feature flags](feature-flags.md): How Baserow uses basic feature flags for
|
||||
optionally enabling unfinished or unready features.
|
||||
|
||||
## Plugins
|
||||
|
||||
|
|
|
@ -83,6 +83,10 @@ export default function CoreModule(options) {
|
|||
key: 'DISABLE_ANONYMOUS_PUBLIC_VIEW_WS_CONNECTIONS',
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
key: 'FEATURE_FLAGS',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
|
@ -154,6 +158,7 @@ export default function CoreModule(options) {
|
|||
src: path.resolve(__dirname, 'plugins/realTimeHandler.js'),
|
||||
})
|
||||
this.appendPlugin({ src: path.resolve(__dirname, 'plugins/auth.js') })
|
||||
this.appendPlugin({ src: path.resolve(__dirname, 'plugins/featureFlags.js') })
|
||||
|
||||
this.extendRoutes((configRoutes) => {
|
||||
// Remove all the routes created by nuxt.
|
||||
|
|
8
web-frontend/modules/core/plugins/featureFlags.js
Normal file
8
web-frontend/modules/core/plugins/featureFlags.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
export default function ({ app }, inject) {
|
||||
// A comma separated list of feature flags used to enable in-progress or not ready
|
||||
// features for developers. See docs/development/feature-flags.md for more info.
|
||||
const FEATURE_FLAGS = (app.$env.FEATURE_FLAGS || '')
|
||||
.split(',')
|
||||
.map((flag) => flag.trim())
|
||||
inject('featureFlags', FEATURE_FLAGS)
|
||||
}
|
Loading…
Add table
Reference in a new issue