From ee88c9e391126615998b5754f1838277b1d913f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Fri, 14 Jun 2024 21:56:29 +0200 Subject: [PATCH] revoke invites and remove users from organizations --- apps/api/src/controllers/export.controller.ts | 4 +- .../profiles/[profileId]/profile-charts.tsx | 6 +-- .../realtime/realtime-live-histogram.tsx | 10 ++--- .../organization/edit-organization.tsx | 9 +++- .../settings/organization/invites/invites.tsx | 40 ++++++++++++++++++ .../settings/organization/members/members.tsx | 38 +++++++++++++++++ .../settings/organization/page.tsx | 42 +++++++++++++++---- .../clients/create-client-success.tsx | 6 +-- .../overview/overview-details-button.tsx | 4 +- .../overview/overview-live-histogram.tsx | 8 ++-- .../components/overview/overview-metrics.tsx | 4 +- .../components/overview/useOverviewWidget.tsx | 4 +- .../src/components/report/chart/Chart.tsx | 8 +--- .../components/report/chart/ChartProvider.tsx | 4 +- .../src/components/report/chart/LazyChart.tsx | 3 +- .../src/components/report/chart/index.tsx | 18 ++++---- .../src/components/report/funnel/Funnel.tsx | 1 - .../src/components/report/funnel/index.tsx | 14 +------ .../src/components/report/reportSlice.ts | 10 ++--- .../src/modals/OverviewChartDetails.tsx | 4 +- apps/dashboard/src/modals/SaveReport.tsx | 4 +- apps/dashboard/src/styles/globals.css | 4 +- apps/worker/package.json | 6 +-- packages/db/src/services/reports.service.ts | 4 +- packages/trpc/src/routers/organization.ts | 32 ++++++++++++++ packages/trpc/src/routers/report.ts | 6 +-- packages/validation/src/index.ts | 10 +++-- packages/validation/src/types.validation.ts | 7 ++++ 28 files changed, 220 insertions(+), 90 deletions(-) diff --git a/apps/api/src/controllers/export.controller.ts b/apps/api/src/controllers/export.controller.ts index ccb9f647..4458840f 100644 --- a/apps/api/src/controllers/export.controller.ts +++ b/apps/api/src/controllers/export.controller.ts @@ -151,9 +151,7 @@ export async function charts( return getChart({ ...query.data, - name: 'export-api', - metric: 'sum', - lineType: 'monotone', chartType: 'linear', + metric: 'sum', }); } diff --git a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/profiles/[profileId]/profile-charts.tsx b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/profiles/[profileId]/profile-charts.tsx index 5214766c..b05e8624 100644 --- a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/profiles/[profileId]/profile-charts.tsx +++ b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/profiles/[profileId]/profile-charts.tsx @@ -4,7 +4,7 @@ import { memo } from 'react'; import { ChartSwitch } from '@/components/report/chart'; import { Widget, WidgetBody, WidgetHead } from '@/components/widget'; -import type { IChartInput } from '@openpanel/validation'; +import type { IChartProps } from '@openpanel/validation'; type Props = { profileId: string; @@ -12,7 +12,7 @@ type Props = { }; const ProfileCharts = ({ profileId, projectId }: Props) => { - const pageViewsChart: IChartInput = { + const pageViewsChart: IChartProps = { projectId, chartType: 'linear', events: [ @@ -45,7 +45,7 @@ const ProfileCharts = ({ profileId, projectId }: Props) => { metric: 'sum', }; - const eventsChart: IChartInput = { + const eventsChart: IChartProps = { projectId, chartType: 'linear', events: [ diff --git a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/realtime-live-histogram.tsx b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/realtime-live-histogram.tsx index 040736a7..a5009da7 100644 --- a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/realtime-live-histogram.tsx +++ b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/realtime-live-histogram.tsx @@ -9,7 +9,7 @@ import { api } from '@/trpc/client'; import { cn } from '@/utils/cn'; import dynamic from 'next/dynamic'; -import type { IChartInput } from '@openpanel/validation'; +import type { IChartProps } from '@openpanel/validation'; interface RealtimeLiveHistogramProps { projectId: string; @@ -18,20 +18,18 @@ interface RealtimeLiveHistogramProps { export function RealtimeLiveHistogram({ projectId, }: RealtimeLiveHistogramProps) { - const report: IChartInput = { + const report: IChartProps = { projectId, events: [ { segment: 'user', filters: [ { - id: '1', name: 'name', operator: 'is', value: ['screen_view', 'session_start'], }, ], - id: 'A', name: '*', displayName: 'Active users', }, @@ -45,7 +43,7 @@ export function RealtimeLiveHistogram({ lineType: 'monotone', previous: false, }; - const countReport: IChartInput = { + const countReport: IChartProps = { name: '', projectId, events: [ @@ -85,7 +83,7 @@ export function RealtimeLiveHistogram({ {staticArray.map((percent, i) => (
))} diff --git a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/edit-organization.tsx b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/edit-organization.tsx index 7a8febba..4febcc99 100644 --- a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/edit-organization.tsx +++ b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/organization/edit-organization.tsx @@ -42,6 +42,7 @@ export default function EditOrganization({ return (
{ mutation.mutate(values); })} @@ -49,12 +50,18 @@ export default function EditOrganization({ Org. details - { Created Status Access + More @@ -62,8 +74,19 @@ function Item({ projects, publicMetadata, status, + organizationId, }: ItemProps) { + const router = useRouter(); const access = (publicMetadata?.access ?? []) as string[]; + const revoke = api.organization.revokeInvite.useMutation({ + onSuccess() { + toast.success(`Invite for ${email} revoked`); + router.refresh(); + }, + onError() { + toast.error(`Failed to revoke invite for ${email}`); + }, + }); return ( {email} @@ -104,6 +127,23 @@ function Item({ All projects )} + + + +