feat: add config flag to configure default project view
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Daniel Herrmann 2024-03-02 18:46:58 +01:00
parent 4bb09b69be
commit ef483c7dc3
5 changed files with 16 additions and 1 deletions

View File

@ -62,6 +62,9 @@ service:
allowiconchanges: true
# Allow using a custom logo via external URL.
customlogourl: ''
# Specify default view when opening a project the first time
# Possible options are: 'project.list', 'project.gantt', 'project.table' or 'project.kanban'
defaultprojectview: 'project.list'
sentry:
# If set to true, enables anonymous error tracking of api errors via Sentry. This allows us to gather more

View File

@ -1,3 +1,4 @@
import {computed} from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import type { RouteLocation } from 'vue-router'
import {saveLastVisited} from '@/helpers/saveLastVisited'
@ -9,6 +10,7 @@ import {setTitle} from '@/helpers/setTitle'
import {LINK_SHARE_HASH_PREFIX} from '@/constants/linkShareHash'
import {useProjectStore} from '@/stores/projects'
import {useConfigStore} from '@/stores/config'
import {useAuthStore} from '@/stores/auth'
import {useBaseStore} from '@/stores/base'
@ -78,6 +80,10 @@ const NewProjectComponent = () => import('@/views/project/NewProject.vue')
const EditTeamComponent = () => import('@/views/teams/EditTeam.vue')
const NewTeamComponent = () => import('@/views/teams/NewTeam.vue')
// Project default view
const configStore = useConfigStore()
const defaultProjectView = computed(() => configStore.defaultProjectView)
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
scrollBehavior(to, from, savedPosition) {
@ -354,7 +360,7 @@ const router = createRouter({
}
return {
name: savedProjectView || 'project.list',
name: savedProjectView || defaultProjectView,
params: {projectId: to.params.projectId},
}
},

View File

@ -37,6 +37,7 @@ export interface ConfigState {
providers: IProvider[],
},
},
defaultProjectView: string,
}
export const useConfigStore = defineStore('config', () => {
@ -70,6 +71,7 @@ export const useConfigStore = defineStore('config', () => {
providers: [],
},
},
defaultProjectView: 'project.list',
})
const migratorsEnabled = computed(() => state.availableMigrators?.length > 0)

View File

@ -64,6 +64,7 @@ const (
ServiceMaxAvatarSize Key = `service.maxavatarsize`
ServiceAllowIconChanges Key = `service.allowiconchanges`
ServiceCustomLogoURL Key = `service.customlogourl`
ServiceDefaultProjectView Key = `service.defaultprojectview`
SentryEnabled Key = `sentry.enabled`
SentryDsn Key = `sentry.dsn`
@ -312,6 +313,7 @@ func InitDefaultConfig() {
ServiceMaxAvatarSize.setDefault(1024)
ServiceDemoMode.setDefault(false)
ServiceAllowIconChanges.setDefault(true)
ServiceDefaultProjectView.setDefault("project.list")
// Sentry
SentryDsn.setDefault("https://440eedc957d545a795c17bbaf477497c@o1047380.ingest.sentry.io/4504254983634944")

View File

@ -51,6 +51,7 @@ type vikunjaInfos struct {
TaskCommentsEnabled bool `json:"task_comments_enabled"`
DemoModeEnabled bool `json:"demo_mode_enabled"`
WebhooksEnabled bool `json:"webhooks_enabled"`
DefaultProjectView string `json:"default_project_view"`
}
type authInfo struct {
@ -95,6 +96,7 @@ func Info(c echo.Context) error {
TaskCommentsEnabled: config.ServiceEnableTaskComments.GetBool(),
DemoModeEnabled: config.ServiceDemoMode.GetBool(),
WebhooksEnabled: config.WebhooksEnabled.GetBool(),
DefaultProjectView: config.DefaultProjectView.GetString(),
AvailableMigrators: []string{
(&vikunja_file.FileMigrator{}).Name(),
(&ticktick.Migrator{}).Name(),