Skip to content

Commit

Permalink
Add feature toggle for checklist
Browse files Browse the repository at this point in the history
manuelmeister committed Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f104731 commit f19208d
Showing 8 changed files with 55 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/workflows/reusable-dev-deployment.yml
Original file line number Diff line number Diff line change
@@ -130,6 +130,7 @@ jobs:
--set recaptcha.secret='${{ secrets.RECAPTCHA_SECRET }}' \
--set frontend.loginInfoTextKey=${{ vars.LOGIN_INFO_TEXT_KEY }} \
--set featureToggle.developer=true
--set featureToggle.checklist=true
- name: Finish the GitHub deployment
uses: bobheadxi/[email protected]
1 change: 1 addition & 0 deletions .helm/deploy-to-cluster.sh
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ for i in 1; do
values="$values --set deploymentTime=$(date -u +%s)"
values="$values --set deployedVersion=\"$(git rev-parse --short HEAD)\""
values="$values --set featureToggle.developer=true"
values="$values --set featureToggle.checklist=true"

if [ -n "$BACKUP_SCHEDULE" ]; then
values="$values --set postgresql.backup.schedule=$BACKUP_SCHEDULE"
1 change: 1 addition & 0 deletions .helm/ecamp3/templates/frontend_configmap.yaml
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ data:
RECAPTCHA_SITE_KEY: null,
{{- end }}
FEATURE_DEVELOPER: {{ .Values.featureToggle.developer | default false }},
FEATURE_CHECKLIST: {{ .Values.featureToggle.checklist | default false }},
LOGIN_INFO_TEXT_KEY: '{{ .Values.frontend.loginInfoTextKey }}',
}
deployedVersion: {{ .Values.deployedVersion | quote }}
3 changes: 2 additions & 1 deletion .helm/ecamp3/values.yaml
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ helpLink: # 'https://ecamp3.ch/faq'
# enable/disable feature across the complete deployment
featureToggle:
developer: false # enables various tools/features foreseen for development deployments (language switcher, form controls view, performance measurement view, etc.)
checklist: false # enables various tools/features foreseen for development deployments (language switcher, form controls view, performance measurement view, etc.)

api:
subpath: "/api"
@@ -251,7 +252,7 @@ apiCache:
requests:
cpu: 10m
memory: 20Mi

autoscaling:
enabled: false
minReplicas: 1
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@
<script>
import { camelCase } from 'lodash'
import { errorToMultiLineToast } from '@/components/toast/toasts'
import { getEnv } from '@/environment.js'
export default {
name: 'ButtonNestedContentNodeAdd',
@@ -82,7 +83,7 @@ export default {
return []
}
return this.preferredContentTypes()
.items.filter((ct) => this.showResponsiveLayout(ct))
.items.filter((ct) => this.showResponsiveLayout(ct) && this.showChecklistNode(ct))
.sort(this.sortContentTypeByTranslatedName)
},
nonpreferredContentTypesItems() {
@@ -104,6 +105,9 @@ export default {
contentTypesLoading() {
return this.api.get().contentTypes()._meta.loading
},
featureChecklistEnabled() {
return getEnv().FEATURE_CHECKLIST ?? false
},
},
methods: {
contentTypeNameKey(contentType) {
@@ -117,6 +121,9 @@ export default {
contentType.name !== 'ResponsiveLayout' || this.parentContentNode.parent === null
)
},
showChecklistNode(contentType) {
return contentType.name === 'Checklist' ? this.featureChecklistEnabled : true
},
sortContentTypeByTranslatedName(ct1, ct2) {
const ct1name = this.$i18n.tc(this.contentTypeNameKey(ct1))
const ct2name = this.$i18n.tc(this.contentTypeNameKey(ct2))
1 change: 1 addition & 0 deletions frontend/src/environment.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ export function getEnv() {
NEWS_LINK: env.NEWS_LINK ?? 'https://ecamp3.ch/blog',
HELP_LINK: env.HELP_LINK ?? 'https://ecamp3.ch/faq',
FEATURE_DEVELOPER: (env.VITE_FEATURE_DEVELOPER ?? 'true') === 'true',
FEATURE_CHECKLIST: (env.VITE_FEATURE_CHECKLIST ?? 'true') === 'true',
LOGIN_INFO_TEXT_KEY: env.VITE_LOGIN_INFO_TEXT_KEY ?? 'dev',
}
}
58 changes: 34 additions & 24 deletions frontend/src/router.js
Original file line number Diff line number Diff line change
@@ -338,24 +338,29 @@ export default new Router({
}),
},
},
{
name: 'admin/checklists/checklist',
path: '/camps/:campId/:campTitle?/admin/checklist/:checklistId/:checklistName?',
components: {
navigation: NavigationCamp,
default: () => import('./views/checklist/Checklist.vue'),
aside: () => import('./views/checklist/SideBarChecklist.vue'),
},
beforeEnter: all([requireAuth, requireCamp, requireChecklist]),
props: {
navigation: (route) => ({ camp: campFromRoute(route) }),
aside: (route) => ({ camp: campFromRoute(route) }),
default: (route) => ({
camp: campFromRoute(route),
checklist: checklistFromRoute(route),
}),
},
},
...(getEnv().FEATURE_CHECKLIST
? [
// Checklist-Pages:
{
name: 'admin/checklists/checklist',
path: '/camps/:campId/:campTitle?/admin/checklist/:checklistId/:checklistName?',
components: {
navigation: NavigationCamp,
default: () => import('./views/checklist/Checklist.vue'),
aside: () => import('./views/checklist/SideBarChecklist.vue'),
},
beforeEnter: all([requireAuth, requireCamp, requireChecklist]),
props: {
navigation: (route) => ({ camp: campFromRoute(route) }),
aside: (route) => ({ camp: campFromRoute(route) }),
default: (route) => ({
camp: campFromRoute(route),
checklist: checklistFromRoute(route),
}),
},
},
]
: []),
{
path: '/camps/:campId/:campTitle?/admin',
components: {
@@ -402,12 +407,17 @@ export default new Router({
component: () => import('./views/admin/Print.vue'),
props: (route) => ({ camp: campFromRoute(route) }),
},
{
path: 'checklists',
name: 'admin/checklists',
component: () => import('./views/admin/Checklists.vue'),
props: (route) => ({ camp: campFromRoute(route) }),
},
...(getEnv().FEATURE_CHECKLIST
? [
// Checklist-Pages:
{
path: 'checklists',
name: 'admin/checklists',
component: () => import('./views/admin/Checklists.vue'),
props: (route) => ({ camp: campFromRoute(route) }),
},
]
: []),
{
path: 'materiallists',
name: 'camp/material',
7 changes: 7 additions & 0 deletions frontend/src/views/admin/SideBarAdmin.vue
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
icon="mdi-account-group-outline"
/>
<SidebarListItem
v-if="featureChecklistEnabled"
:to="adminRoute(camp, 'checklists')"
title="Checklists"
icon="mdi-clipboard-list-outline"
@@ -41,6 +42,7 @@ import SideBar from '@/components/navigation/SideBar.vue'
import { adminRoute, campRoute } from '@/router.js'
import { campRoleMixin } from '@/mixins/campRoleMixin.js'
import SidebarListItem from '@/components/layout/SidebarListItem.vue'
import { getEnv } from '@/environment.js'
export default {
name: 'SideBarAdmin',
@@ -52,6 +54,11 @@ export default {
required: true,
},
},
computed: {
featureChecklistEnabled() {
return getEnv().FEATURE_CHECKLIST ?? false
},
},
methods: { adminRoute, campRoute },
}
</script>

0 comments on commit f19208d

Please sign in to comment.