- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import { flagsHooks } from '@/hooks/flags-hooks';
|
|
import { userHooks } from '@/hooks/user-hooks';
|
|
import { authenticationApi } from '@/lib/authentication-api';
|
|
import { authenticationSession } from '@/lib/authentication-session';
|
|
import { platformApi } from '@/lib/platforms-api';
|
|
import {
|
|
ApEdition,
|
|
ApFlagId,
|
|
isNil,
|
|
Permission,
|
|
PlatformRole,
|
|
} from '@activepieces/shared';
|
|
|
|
export const useAuthorization = () => {
|
|
const { data: edition } = flagsHooks.useFlag(ApFlagId.EDITION);
|
|
|
|
const platformId = authenticationSession.getPlatformId();
|
|
const { data: projectRole, isLoading } = useQuery({
|
|
queryKey: ['project-role', authenticationSession.getProjectId()],
|
|
queryFn: async () => {
|
|
const platform = await platformApi.getCurrentPlatform();
|
|
if (platform.plan.projectRolesEnabled) {
|
|
const projectRole = await authenticationApi.getCurrentProjectRole();
|
|
return projectRole;
|
|
}
|
|
return null;
|
|
},
|
|
retry: false,
|
|
enabled:
|
|
!isNil(edition) && edition !== ApEdition.COMMUNITY && !isNil(platformId),
|
|
});
|
|
|
|
const checkAccess = (permission: Permission) => {
|
|
if (isLoading || edition === ApEdition.COMMUNITY) {
|
|
return true;
|
|
}
|
|
return projectRole?.permissions?.includes(permission) ?? true;
|
|
};
|
|
|
|
return { checkAccess };
|
|
};
|
|
|
|
export const useIsPlatformAdmin = () => {
|
|
const platformRole = userHooks.getCurrentUserPlatformRole();
|
|
return platformRole === PlatformRole.ADMIN;
|
|
};
|