feat: add frontend support for public team setting

This commit is contained in:
Daniel Herrmann 2024-03-09 16:25:16 +01:00
parent 19aeedc568
commit c44d9ef732
6 changed files with 58 additions and 1 deletions

View File

@ -920,7 +920,9 @@
"description": "Description",
"descriptionPlaceholder": "Describe the team here, hit '/' for more options…",
"admin": "Admin",
"member": "Member"
"member": "Member",
"isPublic": "Visibility",
"isPublicDescription": "Make team publicly discoverable"
}
},
"keyboardShortcuts": {

View File

@ -10,6 +10,7 @@ export interface ITeam extends IAbstract {
members: ITeamMember[]
right: Right
oidcId: string
isPublic: boolean
createdBy: IUser
created: Date

View File

@ -14,6 +14,7 @@ export default class TeamModel extends AbstractModel<ITeam> implements ITeam {
members: ITeamMember[] = []
right: Right = RIGHTS.READ
oidcId = ''
isPublic: boolean = false
createdBy: IUser = {} // FIXME: seems wrong
created: Date = null

View File

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

View File

@ -33,6 +33,27 @@
>
{{ $t('team.attributes.nameRequired') }}
</p>
<div
v-if="configStore.publicTeamsEnabled"
class="field"
>
<label
class="label"
for="teamIsPublic"
>{{ $t('team.attributes.isPublic') }}</label>
<div
class="control is-expanded"
:class="{ 'is-loading': teamService.loading }"
>
<Fancycheckbox
v-model="team.isPublic"
:disabled="teamMemberService.loading || undefined"
:class="{ 'disabled': teamService.loading }"
>
{{ $t('team.attributes.isPublicDescription') }}
</Fancycheckbox>
</div>
</div>
<div class="field">
<label
class="label"
@ -241,6 +262,7 @@ import {useI18n} from 'vue-i18n'
import {useRoute, useRouter} from 'vue-router'
import Editor from '@/components/input/AsyncEditor'
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
import Multiselect from '@/components/input/multiselect.vue'
import User from '@/components/misc/user.vue'
@ -253,12 +275,14 @@ import {RIGHTS as Rights} from '@/constants/rights'
import {useTitle} from '@/composables/useTitle'
import {success} from '@/message'
import {useAuthStore} from '@/stores/auth'
import {useConfigStore} from '@/stores/config'
import type {ITeam} from '@/modelTypes/ITeam'
import type {IUser} from '@/modelTypes/IUser'
import type {ITeamMember} from '@/modelTypes/ITeamMember'
const authStore = useAuthStore()
const configStore = useConfigStore()
const route = useRoute()
const router = useRouter()
const {t} = useI18n({useScope: 'global'})
@ -305,6 +329,8 @@ async function save() {
}
showErrorTeamnameRequired.value = false
console.log('team.value', team.value)
team.value = await teamService.value.update(team.value)
success({message: t('team.edit.success')})
}

View File

@ -25,6 +25,26 @@
>
</div>
</div>
<div
v-if="configStore.publicTeamsEnabled"
class="field"
>
<label
class="label"
for="teamIsPublic"
>{{ $t('team.attributes.isPublic') }}</label>
<div
class="control is-expanded"
:class="{ 'is-loading': teamService.loading }"
>
<Fancycheckbox
v-model="team.isPublic"
:class="{ 'disabled': teamService.loading }"
>
{{ $t('team.attributes.isPublicDescription') }}
</Fancycheckbox>
</div>
</div>
<p
v-if="showError && team.name === ''"
class="help is-danger"
@ -46,11 +66,14 @@ import TeamModel from '@/models/team'
import TeamService from '@/services/team'
import CreateEdit from '@/components/misc/create-edit.vue'
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
import {useTitle} from '@/composables/useTitle'
import {useRouter} from 'vue-router'
import {success} from '@/message'
import {useConfigStore} from '@/stores/config'
const {t} = useI18n()
const title = computed(() => t('team.create.title'))
useTitle(title)
@ -60,6 +83,8 @@ const teamService = shallowReactive(new TeamService())
const team = reactive(new TeamModel())
const showError = ref(false)
const configStore = useConfigStore()
async function newTeam() {
if (team.name === '') {
showError.value = true