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(hub-common): add attendees settings pane #1475

Merged
merged 37 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cd9f2e4
feat(hub-common): add attendees settings pane
juliannaeapicella Apr 15, 2024
22de94d
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 15, 2024
1e19b47
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 15, 2024
a9cc3d1
feat(hub-common): test updates
juliannaeapicella Apr 15, 2024
badd322
feat(hub-common): attendees search
juliannaeapicella Apr 17, 2024
383b904
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 17, 2024
24243d7
feat(hub-common): pr feedback
juliannaeapicella Apr 18, 2024
5256bd8
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 18, 2024
f142c4a
feat(hub-common): pr feedback
juliannaeapicella Apr 19, 2024
e3dbb37
Merge branch '8474/events-attendees-pane' of https://github.com/Esri/…
juliannaeapicella Apr 19, 2024
7be994d
feat(hub-common): user enrichment
juliannaeapicella Apr 22, 2024
70b33df
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 22, 2024
60d277b
fix(hub-common): predicate search fix
juliannaeapicella Apr 22, 2024
06ff75d
fix(hub-common): expand shouldUseEventsApi
juliannaeapicella Apr 24, 2024
997aee9
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 24, 2024
5d0d358
fix(hub-common): correct getRegistrations
juliannaeapicella Apr 25, 2024
b8cfad0
Merge branch '8474/events-attendees-pane' of https://github.com/Esri/…
juliannaeapicella Apr 25, 2024
99eb356
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 25, 2024
ccd246b
fix(hub-common): authenticate request
juliannaeapicella Apr 26, 2024
7d0cb16
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 26, 2024
a218f8a
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella Apr 30, 2024
d14ae62
feat(hub-common): test updates
juliannaeapicella May 1, 2024
d55d461
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 2, 2024
9346c12
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 2, 2024
7d19a88
fix(hub-common): getApi merge error
juliannaeapicella May 2, 2024
adffcf6
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 2, 2024
ce75b4d
refactor(hub-common): update package-lock.json
rweber-esri May 3, 2024
b19628c
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 3, 2024
929e14f
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 3, 2024
18fad6f
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 6, 2024
59bf581
feat(hub-common): pr feedback
juliannaeapicella May 6, 2024
f738344
Merge branch '8474/events-attendees-pane' of https://github.com/Esri/…
juliannaeapicella May 6, 2024
b2eb88a
feat(hub-common): add deleteEventAttendees
juliannaeapicella May 7, 2024
cf20463
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 7, 2024
de59757
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 8, 2024
f81d969
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 8, 2024
ee9217d
Merge branch 'master' into 8474/events-attendees-pane
juliannaeapicella May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 30 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/common/src/core/schemas/internal/getEditorSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,16 @@ export async function getEditorSchemas(
import("../../../events/_internal/EventSchemaCreate"),
"hub:event:edit": () =>
import("../../../events/_internal/EventSchemaEdit"),
"hub:event:attendees": () =>
import("../../../events/_internal/EventSchemaAttendeesSettings"),
}[type as EventEditorType]();
const eventUiSchemaModule = await {
"hub:event:create": () =>
import("../../../events/_internal/EventUiSchemaCreate"),
"hub:event:edit": () =>
import("../../../events/_internal/EventUiSchemaEdit"),
"hub:event:attendees": () =>
import("../../../events/_internal/EventUiSchemaAttendeesSettings"),
}[type as EventEditorType]();
schema = eventSchemaModule.buildSchema();
uiSchema = await eventUiSchemaModule.buildUiSchema(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { IConfigurationSchema } from "../../core/schemas/types";

export const buildSchema = (): IConfigurationSchema => {
return {
properties: {
allowRegistration: {
type: "boolean",
enum: [true, false],
default: true,
},
notifyAttendees: {
type: "boolean",
enum: [true, false],
default: true,
},
},
} as IConfigurationSchema;
};
6 changes: 5 additions & 1 deletion packages/common/src/events/_internal/EventSchemaCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
} from "./validations";

export type EventEditorType = (typeof EventEditorTypes)[number];
export const EventEditorTypes = ["hub:event:create", "hub:event:edit"] as const;
export const EventEditorTypes = [
"hub:event:create",
"hub:event:edit",
"hub:event:attendees",
] as const;

/**
* @private
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { IArcGISContext } from "../../ArcGISContext";
import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions";
import { IUiSchema } from "../../core/schemas/types";

export const buildUiSchema = async (
i18nScope: string,
options: EntityEditorOptions,
context: IArcGISContext
): Promise<IUiSchema> => {
return {
type: "Layout",
elements: [
{
type: "Section",
elements: [
{
labelKey: `${i18nScope}.fields.allowRegistration.label`,
scope: "/properties/allowRegistration",
type: "Control",
options: {
control: "hub-field-input-tile-select",
type: "radio",
helperText: {
labelKey: `${i18nScope}.fields.allowRegistration.helperText`,
},
labels: [
`{{${i18nScope}.fields.allowRegistration.enabled.label:translate}}`,
`{{${i18nScope}.fields.allowRegistration.disabled.label:translate}}`,
],
descriptions: [
`{{${i18nScope}.fields.allowRegistration.enabled.description:translate}}`,
`{{${i18nScope}.fields.allowRegistration.disabled.description:translate}}`,
],
icons: ["user-calendar", "circle-disallowed"],
layout: "horizontal",
},
},
{
labelKey: `${i18nScope}.fields.notifyAttendees.label`,
scope: "/properties/notifyAttendees",
type: "Control",
options: {
control: "hub-field-input-tile-select",
type: "radio",
helperText: {
labelKey: `${i18nScope}.fields.notifyAttendees.helperText`,
},
labels: [
`{{${i18nScope}.fields.notifyAttendees.enabled.label:translate}}`,
`{{${i18nScope}.fields.notifyAttendees.disabled.label:translate}}`,
],
descriptions: [
`{{${i18nScope}.fields.notifyAttendees.enabled.description:translate}}`,
`{{${i18nScope}.fields.notifyAttendees.disabled.description:translate}}`,
],
icons: ["envelope", "circle-disallowed"],
layout: "horizontal",
},
},
],
},
],
};
};
15 changes: 15 additions & 0 deletions packages/common/src/events/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createEvent as createEventApi,
updateEvent as updateEventApi,
} from "./api/events";
import { deleteRegistration } from "./api";

/**
* @private
Expand Down Expand Up @@ -116,3 +117,17 @@ export async function updateHubEvent(

return mapper.storeToEntity(model, {}) as IHubEvent;
}

/**
* @private
* Remove an Event Attendee
* @param id event attendee id
* @param requestOptions
* @returns Promise<void>
*/
export async function deleteHubEventAttendee(
id: number,
requestOptions: IHubRequestOptions
): Promise<void> {
await deleteRegistration({ registrationId: id, ...requestOptions });
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { expandApi } from "../../utils";
import { shouldUseOgcApi } from "./shouldUseOgcApi";
import { getOgcApiDefinition } from "./getOgcApiDefinition";
import { shouldUseDiscussionsApi } from "./shouldUseDiscussionsApi";
import { shouldUseEventsApi } from "./shouldUseEventsApi";
import { getDiscussionsApiDefinition } from "./getDiscussionsApiDefinition";
import { shouldUseEventsApi } from "./shouldUseEventsApi";

/**
* @private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export function shouldUseEventsApi(
const {
requestOptions: { isPortal },
} = options;
return targetEntity === "event" && !isPortal;
return ["event", "eventAttendee"].includes(targetEntity) && !isPortal;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { IHubSearchResult } from "../../types/IHubSearchResult";
import { IRegistration } from "../../../events/api/orval/api/orval-events";
import { AccessLevel } from "../../../core";
import { getUser, IUser } from "@esri/arcgis-rest-portal";
import { IHubSearchOptions } from "../../types/IHubSearchOptions";
import { getUserHomeUrl } from "../../../urls/getUserHomeUrl";
import { getUserThumbnailUrl } from "../../utils";

/**
* Transforms a given event attendee into a IHubSearchResult
* @param attendee
* @returns
*/
export async function eventAttendeeToSearchResult(
attendee: IRegistration,
options: IHubSearchOptions
): Promise<IHubSearchResult> {
const [user, creator] = await Promise.all([
getUser({
username: attendee.userId,
...options.requestOptions,
}),
getUser({
username: attendee.createdById,
...options.requestOptions,
}),
]);
return {
id: attendee.id.toString(),
access: user.access as AccessLevel,
name: user.fullName,
createdDate: new Date(attendee.createdAt),
createdDateSource: "attendee.createdAt",
updatedDate: new Date(attendee.updatedAt),
updatedDateSource: "attendee.updatedAt",
type: "Event Attendee",
family: "eventAttendee",
owner: creator.username,
rawResult: attendee,
links: {
self: getUserHomeUrl(user.username, options.requestOptions),
siteRelative: `/people/${user.username}`,
thumbnail: user.thumbnail
? getUserThumbnailUrl(
options.requestOptions.portal,
user,
options.requestOptions.authentication?.token
)
: null,
},
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { unique } from "../../../util";
import { IFilter } from "../../types/IHubCatalog";
import { getPredicateValuesByKey } from "./getPredicateValuesByKey";

export const getOptionalPredicateStringsByKey = (
filters: IFilter[],
predicateKey: string
): string => {
const predicateValues = getPredicateValuesByKey(filters, predicateKey);
const str = predicateValues.filter(unique).join(",");
if (str) {
return str;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IFilter } from "../../types/IHubCatalog";

export const getPredicateValuesByKey = (
filters: IFilter[],
predicateKey: string
): any[] => {
const toPredicateValuesByKey = (a1: any[], filter: IFilter): any[] =>
filter.predicates.reduce<any[]>(
(a2, predicate) =>
Object.entries(predicate).reduce(
(a3, [key, val]) => (key === predicateKey ? [...a3, val] : a3),
a2
),
a1
);
return filters.reduce(toPredicateValuesByKey, []);
};