Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: group schema and create group uischema #1666

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/common/src/core/types/IHubGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ export interface IHubGroup

/** Whether members of the group are hidden */
hiddenMembers?: boolean;

/**
* Is it an admin group / is leaving disallowed
*/
leavingDisallowed?: boolean;
mjuniper marked this conversation as resolved.
Show resolved Hide resolved

/**
* Whether the group is an open data group
*/
isOpenData?: boolean;

/**
* The join type for the group
* (invite, request, auto)
* This is mapped to isInvitationOnly and autoJoin
*/
_join?: "invite" | "request" | "auto";
}

/**
Expand Down
86 changes: 84 additions & 2 deletions packages/common/src/groups/_internal/GroupSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,67 @@ export const GroupSchema: IConfigurationSchema = {
},
description: { type: "string" },
_thumbnail: ENTITY_IMAGE_SCHEMA,
access: {
type: "string",
enum: ["private", "org", "public"],
default: "private",
},
isSharedUpdate: { type: "boolean", enum: [false, true], default: false },
leavingDisallowed: { type: "boolean", enum: [false, true], default: false },
isOpenData: { type: "boolean", enum: [false, true], default: false },
membershipAccess: {
type: "string",
enum: ["organization", "collaborators", "anyone"],
default: "anyone",
default: "organization",
},
isViewOnly: {
type: "boolean",
enum: [false, true],
default: false,
},
_join: {
type: "string",
enum: ["invite", "request", "auto"],
default: "invite",
},
hiddenMembers: {
type: "boolean",
enum: [false, true],
default: false,
},
isDiscussable: ENTITY_IS_DISCUSSABLE_SCHEMA,
},
allOf: [
// if the group is a shared update group, it must have a membershipAccess of org or collaborators
// if the group is not public, isOpenData must be false
{
if: {
properties: {
access: { pattern: "(private|org)" },
},
},
then: {
properties: {
isOpenData: { const: false },
},
},
},
// if the group is is an admin group (leavingDisallowed === true), it must have a membershipAccess of organization
{
if: {
properties: {
leavingDisallowed: { const: true },
},
},
then: {
properties: {
membershipAccess: {
type: "string",
const: "organization",
},
},
},
},
// if the group is a shared update group (isSharedUpdate === true), it must have a membershipAccess of org or collaborators
{
if: {
properties: {
Expand All @@ -60,10 +106,46 @@ export const GroupSchema: IConfigurationSchema = {
then: {
properties: {
membershipAccess: {
type: "string",
pattern: "(organization|collaborators)",
},
},
},
},
// if the group has access === 'private', then the _join must be 'invite'
{
if: {
properties: {
access: { const: "private" },
},
},
then: {
properties: {
_join: { const: "invite" },
},
},
},
// if the group is admin (leavingDisallowed === true) or isSharedUpdate === true, _join must be 'invite' or 'request'
{
if: {
anyOf: [
{
properties: {
leavingDisallowed: { const: true },
},
},
{
properties: {
isSharedUpdate: { const: true },
},
},
],
},
then: {
properties: {
_join: { pattern: "(invite|request)" },
},
},
},
],
} as IConfigurationSchema;
Loading
Loading