Skip to content

Commit

Permalink
feat: group schema and create group uischema
Browse files Browse the repository at this point in the history
affects: @esri/hub-common
  • Loading branch information
mjuniper committed Sep 27, 2024
1 parent 61d22af commit 074e402
Show file tree
Hide file tree
Showing 10 changed files with 923 additions and 152 deletions.
6 changes: 6 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,12 @@ export interface IHubGroup

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

leavingDisallowed?: boolean;

isOpenData?: boolean;

_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

0 comments on commit 074e402

Please sign in to comment.