Skip to content
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
2 changes: 1 addition & 1 deletion packages/client/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const tennisClubMembershipEventWithCustomAction = {
actions: tennisClubMembershipEvent.actions.concat([
{
type: ActionType.CUSTOM,
customActionType: 'CONFIRM',
customActionType: 'Approve',
label: {
id: 'event.tennis-club-membership.action.confirm.label',
defaultMessage: 'Confirm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ function useCustomActionConfigs(
customActionModal: React.ReactNode
customActionConfigs: ActionMenuItem[]
} {
// eslint-disable-next-line react-hooks/exhaustive-deps
const scopes = useSelector(getScope) ?? []
const { eventConfiguration } = useEventConfiguration(event.type)
const { customActionModal, onCustomAction } = useCustomActionModal(event)
Expand All @@ -593,6 +594,14 @@ function useCustomActionConfigs(
(action): action is CustomActionConfig =>
action.type === ActionType.CUSTOM
)
.filter((action) =>
configurableEventScopeAllowed(
scopes,
['record.custom-action'],
event.type,
action.customActionType
)
)
Comment on lines +597 to +604
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was already done somewhere, as custom actions didnt show up unless you had the scope for it! I was mistaken I guess 😲

Copy link
Contributor Author

@Nil20 Nil20 Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah! we weren't giving multiple custom action scopes to a single user, that's probably why it wasn't caught until now

.map((action) => ({
label: action.label,
icon: action.icon ?? ('PencilLine' as const),
Expand All @@ -603,7 +612,13 @@ function useCustomActionConfigs(
type: ActionType.CUSTOM,
customActionType: action.customActionType
}))
}, [eventConfiguration, onCustomAction, isDownloadedAndAssignedToUser])
}, [
eventConfiguration.actions,
scopes,
event.type,
isDownloadedAndAssignedToUser,
onCustomAction
])

const hasCustomActionScope = configurableEventScopeAllowed(
scopes,
Expand Down
18 changes: 15 additions & 3 deletions packages/commons/src/events/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
ConfigurableScopeType,
findScope,
getAuthorizedEventsFromScopes,
RecordScopeType,
Scope
Scope,
RecordScopeType
} from '../scopes'
import {
ClientSpecificAction,
Expand Down Expand Up @@ -65,7 +65,8 @@ export function hasAnyOfScopes(a: Scope[], b: Scope[]) {
export function configurableEventScopeAllowed(
scopes: Scope[],
allowedConfigurableScopes: ConfigurableScopeType[],
eventType: string
eventType: string,
customActionType?: string
) {
// Find the scopes that are authorized for the given action
const parsedScopes = allowedConfigurableScopes
Expand All @@ -74,6 +75,17 @@ export function configurableEventScopeAllowed(

// Ensure that the given event type is authorized in the found scopes
const authorizedEvents = getAuthorizedEventsFromScopes(parsedScopes)
const firstScope = parsedScopes[0]
if (
parsedScopes.length > 0 &&
firstScope.type === 'record.custom-action' &&
customActionType
) {
const allowedCustomActionTypes = firstScope.options.customActionType
if (!allowedCustomActionTypes.includes(customActionType)) {
return false
}
}
return authorizedEvents.includes(eventType)
}

Expand Down
1 change: 1 addition & 0 deletions packages/commons/src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const AvailableIcons = z.enum([
'Users',
'WarningCircle',
'X',
'ChatText',
'CircleWavyCheck',
'CircleWavyQuestion',
'ArchiveBox',
Expand Down
2 changes: 1 addition & 1 deletion packages/commons/src/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export const ConfigurableActionScopes = z.discriminatedUnion('type', [
CustomActionScope
])

type ConfigurableRawScopes = z.infer<typeof ConfigurableRawScopes>
export type ConfigurableRawScopes = z.infer<typeof ConfigurableRawScopes>
export type ConfigurableScopeType = ConfigurableRawScopes['type']

type FlattenedSearchScope = {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/Icon/all-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export {
WarningCircle,
Webcam,
X,
Stamp
Stamp,
ChatText
} from 'phosphor-react'
export * from './custom-icons'
1 change: 1 addition & 0 deletions packages/components/src/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export const Pagination = ({
})}
</StyledPagination>
<Button
id="next-page-button"
type="icon"
size="small"
onClick={() => {
Expand Down