add "only platform admin can create groups" and "only groups can create events" restrictions

This commit is contained in:
setop
2021-10-06 18:00:50 +02:00
committed by Thomas Citharel
parent 7885151220
commit 7940d69d5a
13 changed files with 135 additions and 34 deletions

View File

@@ -44,6 +44,7 @@
"
>
<b-button
v-if="!hideCreateEventsButton"
tag="router-link"
:to="{ name: RouteName.CREATE_EVENT }"
type="is-primary"
@@ -313,6 +314,10 @@ export default class NavBar extends Vue {
});
return changeIdentity(this.$apollo.provider.defaultClient, identity);
}
get hideCreateEventsButton(): boolean {
return !!this.config?.restrictions?.onlyGroupsCanCreateEvents;
}
}
</script>
<style lang="scss" scoped>

View File

@@ -69,6 +69,10 @@ export const CONFIG = gql`
eventCreation
koenaConnect
}
restrictions {
onlyAdminCanCreateGroups
onlyGroupsCanCreateEvents
}
auth {
ldap
oauthProviders {

View File

@@ -84,6 +84,10 @@ export interface IConfig {
groups: boolean;
koenaConnect: boolean;
};
restrictions: {
onlyAdminCanCreateGroups: boolean;
onlyGroupsCanCreateEvents: boolean;
};
federating: boolean;
version: string;
auth: {

View File

@@ -14,6 +14,13 @@
</li>
</ul>
</nav>
<div class="buttons" v-if="showCreateGroupsButton">
<router-link
class="button is-primary"
:to="{ name: RouteName.CREATE_GROUP }"
>{{ $t("Create group") }}</router-link
>
</div>
<div v-if="groups">
<b-switch v-model="local">{{ $t("Local") }}</b-switch>
<b-switch v-model="suspended">{{ $t("Suspended") }}</b-switch>
@@ -100,6 +107,8 @@
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { CONFIG } from "@/graphql/config";
import { IConfig } from "@/types/config.model";
import { LIST_GROUPS } from "@/graphql/group";
import RouteName from "../../router/name";
import EmptyContent from "../../components/Utils/EmptyContent.vue";
@@ -110,6 +119,7 @@ const PROFILES_PER_PAGE = 10;
@Component({
apollo: {
config: CONFIG,
groups: {
query: LIST_GROUPS,
variables() {
@@ -139,6 +149,7 @@ export default class GroupProfiles extends Vue {
PROFILES_PER_PAGE = PROFILES_PER_PAGE;
config!: IConfig;
RouteName = RouteName;
async onPageChange(): Promise<void> {
@@ -185,6 +196,10 @@ export default class GroupProfiles extends Vue {
this.pushRouter({ suspended: suspended ? "1" : "0" });
}
get showCreateGroupsButton(): boolean {
return !!this.config?.restrictions?.onlyAdminCanCreateGroups;
}
onFiltersChange({
preferredUsername,
domain,

View File

@@ -10,7 +10,7 @@
)
}}
</p>
<div class="buttons">
<div class="buttons" v-if="!hideCreateEventButton">
<router-link
class="button is-primary"
:to="{ name: RouteName.CREATE_EVENT }"
@@ -126,6 +126,8 @@
</template>
<script lang="ts">
import { CONFIG } from "../../graphql/config";
import { IConfig } from "../../types/config.model";
import { Component, Vue } from "vue-property-decorator";
import { ParticipantRole } from "@/types/enums";
import RouteName from "@/router/name";
@@ -147,6 +149,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
EventListCard,
},
apollo: {
config: CONFIG,
futureParticipations: {
query: LOGGED_USER_PARTICIPATIONS,
fetchPolicy: "cache-and-network",
@@ -197,6 +200,8 @@ export default class MyEvents extends Vue {
limit = 10;
config!: IConfig;
futureParticipations: IParticipant[] = [];
hasMoreFutureParticipations = true;
@@ -286,6 +291,10 @@ export default class MyEvents extends Vue {
(participation) => participation.event.id !== eventid
);
}
get hideCreateEventButton(): boolean {
return !!this.config?.restrictions?.onlyGroupsCanCreateEvents;
}
}
</script>

View File

@@ -8,7 +8,7 @@
)
}}
</p>
<div class="buttons">
<div class="buttons" v-if="!hideCreateGroupButton">
<router-link
class="button is-primary"
:to="{ name: RouteName.CREATE_GROUP }"
@@ -72,6 +72,8 @@
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { CONFIG } from "@/graphql/config";
import { IConfig } from "@/types/config.model";
import { LOGGED_USER_MEMBERSHIPS } from "@/graphql/actor";
import { LEAVE_GROUP } from "@/graphql/group";
import GroupMemberCard from "@/components/Group/GroupMemberCard.vue";
@@ -90,6 +92,9 @@ import RouteName from "../../router/name";
Invitations,
},
apollo: {
config: {
query: CONFIG,
},
membershipsPages: {
query: LOGGED_USER_MEMBERSHIPS,
fetchPolicy: "cache-and-network",
@@ -114,6 +119,8 @@ export default class MyGroups extends Vue {
RouteName = RouteName;
config!: IConfig;
page = 1;
limit = 10;
@@ -177,6 +184,10 @@ export default class MyGroups extends Vue {
![MemberRole.INVITED, MemberRole.REJECTED].includes(member.role)
);
}
get hideCreateGroupButton(): boolean {
return !!this.config?.restrictions?.onlyAdminCanCreateGroups;
}
}
</script>