chore(root): rename organizationSlug to organizationId (#91)
This commit is contained in:
committed by
GitHub
parent
0221948aab
commit
cd16ac878d
@@ -60,7 +60,7 @@ export function ListReports({ reports, dashboard }: ListReportsProps) {
|
||||
icon={PlusIcon}
|
||||
onClick={() => {
|
||||
router.push(
|
||||
`/${params.organizationSlug}/${
|
||||
`/${params.organizationId}/${
|
||||
params.projectId
|
||||
}/reports?${new URLSearchParams({
|
||||
dashboardId: params.dashboardId,
|
||||
@@ -79,7 +79,7 @@ export function ListReports({ reports, dashboard }: ListReportsProps) {
|
||||
return (
|
||||
<div className="card" key={report.id}>
|
||||
<Link
|
||||
href={`/${params.organizationSlug}/${params.projectId}/reports/${report.id}`}
|
||||
href={`/${params.organizationId}/${params.projectId}/reports/${report.id}`}
|
||||
className="flex items-center justify-between border-b border-border p-4 leading-none [&_svg]:hover:opacity-100"
|
||||
shallow
|
||||
>
|
||||
@@ -163,7 +163,7 @@ export function ListReports({ reports, dashboard }: ListReportsProps) {
|
||||
<Button
|
||||
onClick={() =>
|
||||
router.push(
|
||||
`/${params.organizationSlug}/${
|
||||
`/${params.organizationId}/${
|
||||
params.projectId
|
||||
}/reports?${new URLSearchParams({
|
||||
dashboardId: params.dashboardId,
|
||||
|
||||
@@ -7,7 +7,6 @@ import { ListReports } from './list-reports';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
projectId: string;
|
||||
dashboardId: string;
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ interface ListDashboardsProps {
|
||||
export function ListDashboards({ dashboards }: ListDashboardsProps) {
|
||||
const router = useRouter();
|
||||
const params = useAppParams();
|
||||
const { organizationSlug, projectId } = params;
|
||||
const { organizationId, projectId } = params;
|
||||
const deletion = api.dashboard.delete.useMutation({
|
||||
onError: (error, variables) => {
|
||||
return handleErrorToastOptions({
|
||||
@@ -87,7 +87,7 @@ export function ListDashboards({ dashboards }: ListDashboardsProps) {
|
||||
<Card key={item.id} hover>
|
||||
<div>
|
||||
<Link
|
||||
href={`/${organizationSlug}/${projectId}/dashboards/${item.id}`}
|
||||
href={`/${organizationId}/${projectId}/dashboards/${item.id}`}
|
||||
className="flex flex-col p-4 @container"
|
||||
>
|
||||
<div className="col gap-2">
|
||||
|
||||
@@ -9,7 +9,6 @@ import Events from './events';
|
||||
interface PageProps {
|
||||
params: {
|
||||
projectId: string;
|
||||
organizationSlug: string;
|
||||
};
|
||||
searchParams: Record<string, string>;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function LayoutOrganizationSelector({
|
||||
const router = useRouter();
|
||||
|
||||
const organization = organizations.find(
|
||||
(item) => item.id === params.organizationSlug,
|
||||
(item) => item.id === params.organizationId,
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -14,11 +14,9 @@ import {
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { useAppParams } from '@/hooks/useAppParams';
|
||||
import { pushModal } from '@/modals';
|
||||
import { cn } from '@/utils/cn';
|
||||
import {
|
||||
Building2Icon,
|
||||
CheckIcon,
|
||||
ChevronsUpDown,
|
||||
ChevronsUpDownIcon,
|
||||
PlusIcon,
|
||||
} from 'lucide-react';
|
||||
@@ -27,12 +25,12 @@ import { useState } from 'react';
|
||||
|
||||
import type {
|
||||
getCurrentOrganizations,
|
||||
getProjectsByOrganizationSlug,
|
||||
getProjectsByOrganizationId,
|
||||
} from '@openpanel/db';
|
||||
import Link from 'next/link';
|
||||
|
||||
interface LayoutProjectSelectorProps {
|
||||
projects: Awaited<ReturnType<typeof getProjectsByOrganizationSlug>>;
|
||||
projects: Awaited<ReturnType<typeof getProjectsByOrganizationId>>;
|
||||
organizations?: Awaited<ReturnType<typeof getCurrentOrganizations>>;
|
||||
align?: 'start' | 'end';
|
||||
}
|
||||
@@ -42,22 +40,22 @@ export default function LayoutProjectSelector({
|
||||
align = 'start',
|
||||
}: LayoutProjectSelectorProps) {
|
||||
const router = useRouter();
|
||||
const { organizationSlug, projectId } = useAppParams();
|
||||
const { organizationId, projectId } = useAppParams();
|
||||
const pathname = usePathname() || '';
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const changeProject = (newProjectId: string) => {
|
||||
if (organizationSlug && projectId) {
|
||||
if (organizationId && projectId) {
|
||||
const split = pathname
|
||||
.replace(
|
||||
`/${organizationSlug}/${projectId}`,
|
||||
`/${organizationSlug}/${newProjectId}`,
|
||||
`/${organizationId}/${projectId}`,
|
||||
`/${organizationId}/${newProjectId}`,
|
||||
)
|
||||
.split('/');
|
||||
// slicing here will remove everything after /{orgId}/{projectId}/dashboards [slice here] /xxx/xxx/xxx
|
||||
router.push(split.slice(0, 4).join('/'));
|
||||
} else {
|
||||
router.push(`/${organizationSlug}/${newProjectId}`);
|
||||
router.push(`/${organizationId}/${newProjectId}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -102,7 +100,7 @@ export default function LayoutProjectSelector({
|
||||
))}
|
||||
{projects.length > 10 && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/${organizationSlug}`}>All projects</Link>
|
||||
<Link href={`/${organizationId}`}>All projects</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
@@ -126,7 +124,7 @@ export default function LayoutProjectSelector({
|
||||
onClick={() => changeOrganization(organization.id)}
|
||||
>
|
||||
{organization.name}
|
||||
{organization.id === organizationSlug && (
|
||||
{organization.id === organizationId && (
|
||||
<DropdownMenuShortcut>
|
||||
<CheckIcon size={16} />
|
||||
</DropdownMenuShortcut>
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useEffect, useState } from 'react';
|
||||
import type {
|
||||
IServiceDashboards,
|
||||
IServiceOrganization,
|
||||
getProjectsByOrganizationSlug,
|
||||
getProjectsByOrganizationId,
|
||||
} from '@openpanel/db';
|
||||
|
||||
import LayoutMenu from './layout-menu';
|
||||
@@ -20,9 +20,8 @@ import LayoutProjectSelector from './layout-project-selector';
|
||||
interface LayoutSidebarProps {
|
||||
organizations: IServiceOrganization[];
|
||||
dashboards: IServiceDashboards;
|
||||
organizationSlug: string;
|
||||
projectId: string;
|
||||
projects: Awaited<ReturnType<typeof getProjectsByOrganizationSlug>>;
|
||||
projects: Awaited<ReturnType<typeof getProjectsByOrganizationId>>;
|
||||
}
|
||||
export function LayoutSidebar({
|
||||
organizations,
|
||||
|
||||
@@ -13,22 +13,22 @@ import SideEffects from './side-effects';
|
||||
interface AppLayoutProps {
|
||||
children: React.ReactNode;
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
organizationId: string;
|
||||
projectId: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function AppLayout({
|
||||
children,
|
||||
params: { organizationSlug, projectId },
|
||||
params: { organizationId, projectId },
|
||||
}: AppLayoutProps) {
|
||||
const [organizations, projects, dashboards] = await Promise.all([
|
||||
getCurrentOrganizations(),
|
||||
getCurrentProjects(organizationSlug),
|
||||
getCurrentProjects(organizationId),
|
||||
getDashboardsByProjectId(projectId),
|
||||
]);
|
||||
|
||||
if (!organizations.find((item) => item.id === organizationSlug)) {
|
||||
if (!organizations.find((item) => item.id === organizationId)) {
|
||||
return (
|
||||
<FullPageEmptyState title="Not found" className="min-h-screen">
|
||||
The organization you were looking for could not be found.
|
||||
@@ -48,7 +48,7 @@ export default async function AppLayout({
|
||||
<div id="dashboard">
|
||||
<LayoutSidebar
|
||||
{...{
|
||||
organizationSlug,
|
||||
organizationId,
|
||||
projectId,
|
||||
organizations,
|
||||
projects,
|
||||
|
||||
@@ -13,7 +13,6 @@ import { OverviewReportRange } from './overview-sticky-header';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import ClickToCopy from '@/components/click-to-copy';
|
||||
import { ListPropertiesIcon } from '@/components/events/list-properties-icon';
|
||||
import { ProfileAvatar } from '@/components/profiles/profile-avatar';
|
||||
import { Padding } from '@/components/ui/padding';
|
||||
import { getProfileName } from '@/utils/getters';
|
||||
@@ -16,7 +15,6 @@ import ProfileMetrics from './profile-metrics';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
projectId: string;
|
||||
profileId: string;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@ import Profiles from './profiles';
|
||||
interface PageProps {
|
||||
params: {
|
||||
projectId: string;
|
||||
organizationSlug: string;
|
||||
};
|
||||
searchParams: Record<string, string>;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import RealtimeReloader from './realtime-reloader';
|
||||
|
||||
type Props = {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -35,12 +35,12 @@ interface Props {
|
||||
|
||||
export default function CreateInvite({ projects }: Props) {
|
||||
const router = useRouter();
|
||||
const { organizationSlug } = useAppParams();
|
||||
const { organizationId } = useAppParams();
|
||||
|
||||
const { register, handleSubmit, formState, reset, control } = useForm<IForm>({
|
||||
resolver: zodResolver(zInviteUser),
|
||||
defaultValues: {
|
||||
organizationSlug,
|
||||
organizationId,
|
||||
access: [],
|
||||
role: 'org:member',
|
||||
},
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { TableButtons } from '@/components/data-table';
|
||||
import { InvitesTable } from '@/components/settings/invites';
|
||||
|
||||
import { getInvites, getProjectsByOrganizationSlug } from '@openpanel/db';
|
||||
import { getInvites, getProjectsByOrganizationId } from '@openpanel/db';
|
||||
|
||||
import CreateInvite from './create-invite';
|
||||
|
||||
interface Props {
|
||||
organizationSlug: string;
|
||||
organizationId: string;
|
||||
}
|
||||
|
||||
const InvitesServer = async ({ organizationSlug }: Props) => {
|
||||
const InvitesServer = async ({ organizationId }: Props) => {
|
||||
const [invites, projects] = await Promise.all([
|
||||
getInvites(organizationSlug),
|
||||
getProjectsByOrganizationSlug(organizationSlug),
|
||||
getInvites(organizationId),
|
||||
getProjectsByOrganizationId(organizationId),
|
||||
]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { MembersTable } from '@/components/settings/members';
|
||||
|
||||
import { getMembers, getProjectsByOrganizationSlug } from '@openpanel/db';
|
||||
import { getMembers, getProjectsByOrganizationId } from '@openpanel/db';
|
||||
|
||||
interface Props {
|
||||
organizationSlug: string;
|
||||
organizationId: string;
|
||||
}
|
||||
|
||||
const MembersServer = async ({ organizationSlug }: Props) => {
|
||||
const MembersServer = async ({ organizationId }: Props) => {
|
||||
const [members, projects] = await Promise.all([
|
||||
getMembers(organizationSlug),
|
||||
getProjectsByOrganizationSlug(organizationSlug),
|
||||
getMembers(organizationId),
|
||||
getProjectsByOrganizationId(organizationId),
|
||||
]);
|
||||
|
||||
return <MembersTable data={members} projects={projects} />;
|
||||
|
||||
@@ -14,13 +14,13 @@ import MembersServer from './members';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
organizationId: string;
|
||||
};
|
||||
searchParams: Record<string, string>;
|
||||
}
|
||||
|
||||
export default async function Page({
|
||||
params: { organizationSlug },
|
||||
params: { organizationId },
|
||||
searchParams,
|
||||
}: PageProps) {
|
||||
const tab = parseAsStringEnum(['org', 'members', 'invites'])
|
||||
@@ -29,7 +29,7 @@ export default async function Page({
|
||||
const session = auth();
|
||||
const organization = await db.organization.findUnique({
|
||||
where: {
|
||||
id: organizationSlug,
|
||||
id: organizationId,
|
||||
members: {
|
||||
some: {
|
||||
userId: session.userId,
|
||||
@@ -80,12 +80,8 @@ export default async function Page({
|
||||
</PageTabs>
|
||||
|
||||
{tab === 'org' && <EditOrganization organization={organization} />}
|
||||
{tab === 'members' && (
|
||||
<MembersServer organizationSlug={organizationSlug} />
|
||||
)}
|
||||
{tab === 'invites' && (
|
||||
<InvitesServer organizationSlug={organizationSlug} />
|
||||
)}
|
||||
{tab === 'members' && <MembersServer organizationId={organizationId} />}
|
||||
{tab === 'invites' && <InvitesServer organizationId={organizationId} />}
|
||||
</Padding>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
import PageLayout from '@/app/(app)/[organizationSlug]/[projectId]/page-layout';
|
||||
import { Padding } from '@/components/ui/padding';
|
||||
|
||||
import {
|
||||
getClientsByOrganizationSlug,
|
||||
getProjectsByOrganizationSlug,
|
||||
getClientsByOrganizationId,
|
||||
getProjectsByOrganizationId,
|
||||
} from '@openpanel/db';
|
||||
|
||||
import ListProjects from './list-projects';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
organizationId: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function Page({
|
||||
params: { organizationSlug },
|
||||
}: PageProps) {
|
||||
export default async function Page({ params: { organizationId } }: PageProps) {
|
||||
const [projects, clients] = await Promise.all([
|
||||
getProjectsByOrganizationSlug(organizationSlug),
|
||||
getClientsByOrganizationSlug(organizationSlug),
|
||||
getProjectsByOrganizationId(organizationId),
|
||||
getClientsByOrganizationId(organizationId),
|
||||
]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,7 +4,6 @@ import ListReferences from './list-references';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,19 +8,17 @@ import { getCurrentOrganizations, getCurrentProjects } from '@openpanel/db';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
organizationSlug: string;
|
||||
organizationId: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function Page({
|
||||
params: { organizationSlug },
|
||||
}: PageProps) {
|
||||
export default async function Page({ params: { organizationId } }: PageProps) {
|
||||
const [organizations, projects] = await Promise.all([
|
||||
getCurrentOrganizations(),
|
||||
getCurrentProjects(organizationSlug),
|
||||
getCurrentProjects(organizationId),
|
||||
]);
|
||||
|
||||
const organization = organizations.find((org) => org.id === organizationSlug);
|
||||
const organization = organizations.find((org) => org.id === organizationId);
|
||||
|
||||
if (!organization) {
|
||||
return (
|
||||
@@ -35,7 +33,7 @@ export default async function Page({
|
||||
}
|
||||
|
||||
if (projects.length === 1 && projects[0]) {
|
||||
return redirect(`/${organizationSlug}/${projects[0].id}`);
|
||||
return redirect(`/${organizationId}/${projects[0].id}`);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -10,8 +10,8 @@ type Props = {
|
||||
|
||||
const Connect = async ({ params: { projectId } }: Props) => {
|
||||
const orgs = await getCurrentOrganizations();
|
||||
const organizationSlug = orgs[0]?.id;
|
||||
if (!organizationSlug) {
|
||||
const organizationId = orgs[0]?.id;
|
||||
if (!organizationId) {
|
||||
throw new Error('No organization found');
|
||||
}
|
||||
const project = await getProjectWithClients(projectId);
|
||||
|
||||
@@ -72,7 +72,7 @@ const Verify = ({ project, events }: Props) => {
|
||||
<div className="flex items-center gap-8">
|
||||
{!verified && (
|
||||
<Link
|
||||
href={`/${project.organizationSlug}/${project.id}`}
|
||||
href={`/${project.organizationId}/${project.id}`}
|
||||
className=" text-muted-foreground underline"
|
||||
>
|
||||
Skip for now
|
||||
|
||||
@@ -18,8 +18,8 @@ type Props = {
|
||||
|
||||
const Verify = async ({ params: { projectId } }: Props) => {
|
||||
const orgs = await getCurrentOrganizations();
|
||||
const organizationSlug = orgs[0]?.id;
|
||||
if (!organizationSlug) {
|
||||
const organizationId = orgs[0]?.id;
|
||||
if (!organizationId) {
|
||||
throw new Error('No organization found');
|
||||
}
|
||||
const [project, events] = await Promise.all([
|
||||
|
||||
@@ -100,7 +100,7 @@ const Tracking = ({
|
||||
{organizations.length > 0 ? (
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="organizationSlug"
|
||||
name="organizationId"
|
||||
render={({ field, formState }) => {
|
||||
return (
|
||||
<div>
|
||||
@@ -109,7 +109,7 @@ const Tracking = ({
|
||||
className="w-full"
|
||||
placeholder="Select workspace"
|
||||
icon={Building}
|
||||
error={formState.errors.organizationSlug?.message}
|
||||
error={formState.errors.organizationId?.message}
|
||||
value={field.value}
|
||||
items={
|
||||
organizations
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { StickyBelowHeader } from '@/app/(app)/[organizationSlug]/[projectId]/layout-sticky-below-header';
|
||||
import { OverviewReportRange } from '@/app/(app)/[organizationSlug]/[projectId]/overview-sticky-header';
|
||||
import { Logo } from '@/components/logo';
|
||||
import { OverviewFiltersButtons } from '@/components/overview/filters/overview-filters-buttons';
|
||||
import ServerLiveCounter from '@/components/overview/live-counter';
|
||||
import { OverviewLiveHistogram } from '@/components/overview/overview-live-histogram';
|
||||
import OverviewMetrics from '@/components/overview/overview-metrics';
|
||||
import OverviewTopDevices from '@/components/overview/overview-top-devices';
|
||||
import OverviewTopEvents from '@/components/overview/overview-top-events';
|
||||
@@ -35,7 +33,7 @@ export default async function Page({
|
||||
return notFound();
|
||||
}
|
||||
const projectId = share.projectId;
|
||||
const organization = await getOrganizationBySlug(share.organizationSlug);
|
||||
const organization = await getOrganizationBySlug(share.organizationId);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -54,7 +54,6 @@ export async function POST(request: Request) {
|
||||
data: access
|
||||
.filter((a) => typeof a === 'string')
|
||||
.map((projectId) => ({
|
||||
organizationSlug: membership.organizationId,
|
||||
organizationId: membership.organizationId,
|
||||
projectId: projectId,
|
||||
userId: user.id,
|
||||
@@ -72,7 +71,6 @@ export async function POST(request: Request) {
|
||||
data: access
|
||||
.filter((a): a is string => typeof a === 'string')
|
||||
.map((projectId) => ({
|
||||
organizationSlug: payload.data.organization.slug,
|
||||
organizationId: payload.data.organization.slug,
|
||||
projectId: projectId,
|
||||
userId: payload.data.public_user_data.user_id,
|
||||
@@ -110,7 +108,7 @@ export async function POST(request: Request) {
|
||||
if (payload.type === 'organizationMembership.deleted') {
|
||||
await db.projectAccess.deleteMany({
|
||||
where: {
|
||||
organizationSlug: payload.data.organization.slug,
|
||||
organizationId: payload.data.organization.slug,
|
||||
userId: payload.data.public_user_data.user_id,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user