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

Fixing app details disconnect button and number of apps #4305

Merged
merged 20 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7e52e3d
V2 Settings Shell - Add Teams Section & UI fixes (#4347)
joeauyeung Sep 12, 2022
c9ad904
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 12, 2022
1deca81
Feat/team owner booking (#3999)
Udit-takkar Sep 12, 2022
23d16b4
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 12, 2022
50f63ef
Adds skeleton loader to workflows (#4402)
CarinaWolli Sep 12, 2022
729d511
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 12, 2022
7e917cd
V2 settings teams (Profil, Members, Appearance View) (#4350)
CarinaWolli Sep 12, 2022
06ec19c
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 12, 2022
6b2d675
add rainbowkit form to v2 event-types (#4349)
hexcowboy Sep 12, 2022
5f159d6
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 12, 2022
140bb38
v1.9.5
zomars Sep 12, 2022
3c65f6b
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 12, 2022
b2d3432
Fix/daterangepicker css (#4418)
alishaz-polymath Sep 13, 2022
fd1031e
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 13, 2022
5db525a
dynamic import rainbow (only if installed) (#4409)
hexcowboy Sep 13, 2022
8132f80
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 13, 2022
2292343
Tidyup app cards (#4428)
sean-brydon Sep 13, 2022
6c68605
Merge branch 'main' into fix/app-disconnect-filtering
kodiakhq[bot] Sep 13, 2022
72e3a0c
Moving API to trpc query
leog Sep 13, 2022
3e8867c
Merge branch 'feat/v2-installed-apps' into fix/app-disconnect-filtering
leog Sep 13, 2022
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
86 changes: 21 additions & 65 deletions apps/web/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Credential } from "@prisma/client";
import Link from "next/link";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import React, { useState } from "react";

import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
import { InstallAppButton } from "@calcom/app-store/components";
Expand Down Expand Up @@ -59,34 +58,14 @@ const Component = ({
currency: "USD",
useGrouping: false,
}).format(price);
const [existingCredentials, setExistingCredentials] = useState<Credential[]>([]);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
async function getInstalledApp(appCredentialType: string) {
const queryParam = new URLSearchParams();
queryParam.set("app-credential-type", appCredentialType);
try {
const result = await fetch(`/api/apps/installed?${queryParam.toString()}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
}).then((data) => {
setIsLoading(false);
return data;
});
if (result.status === 200) {
const res = await result.json();
setExistingCredentials(res.credentials);
}
} catch (error) {
if (error instanceof Error) {
console.log(error.message);
}
}
}
getInstalledApp(type);
}, [type]);

const [existingCredentials, setExistingCredentials] = useState<number[]>([]);
const appCredentials = trpc.useQuery(["viewer.appCredentialsByType", { appType: type }], {
onSuccess(data) {
setExistingCredentials(data);
},
});

const allowedMultipleInstalls = categories.indexOf("calendar") > -1;

return (
Expand Down Expand Up @@ -116,7 +95,7 @@ const Component = ({
</div>

<div className="mt-4 sm:mt-0 sm:text-right">
{!isLoading ? (
{!appCredentials.isLoading ? (
isGlobal ||
(existingCredentials.length > 0 && allowedMultipleInstalls ? (
<div className="flex space-x-3">
Expand Down Expand Up @@ -146,44 +125,21 @@ const Component = ({
}}
/>
)}
{existingCredentials.length > 0 ? (
<DisconnectIntegration
id={existingCredentials[0].id}
render={(btnProps) => (
<Button
{...btnProps}
color="warn"
data-testid={type + "-integration-disconnect-button"}>
{t("disconnect")}
</Button>
)}
onOpenChange={handleOpenChange}
/>
) : (
<InstallAppButton
type={type}
isProOnly={isProOnly}
render={({ useDefaultComponent, ...props }) => {
if (useDefaultComponent) {
props = {
onClick: () => {
mutation.mutate({ type });
},
loading: mutation.isLoading,
};
}
return (
<Button data-testid="install-app-button" {...props}>
{t("install_app")}
</Button>
);
}}
/>
)}
</div>
) : existingCredentials.length > 0 ? (
<DisconnectIntegration
id={existingCredentials[0]}
render={(btnProps) => (
<Button {...btnProps} color="warn" data-testid={type + "-integration-disconnect-button"}>
{t("disconnect")}
</Button>
)}
onOpenChange={handleOpenChange}
/>
) : (
<InstallAppButton
type={type}
isProOnly={isProOnly}
render={({ useDefaultComponent, ...props }) => {
if (useDefaultComponent) {
props = {
Expand Down
5 changes: 3 additions & 2 deletions apps/web/components/Gates.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import dynamic from "next/dynamic";
import { Dispatch, useState, useEffect } from "react";
import { JSONObject } from "superjson/dist/types";

import RainbowGate from "@calcom/app-store/rainbow/components/RainbowKit";

export type Gate = undefined | "rainbow"; // Add more like ` | "geolocation" | "payment"`

export type GateState = {
Expand All @@ -16,6 +15,8 @@ type GateProps = {
dispatch: Dispatch<Partial<GateState>>;
};

const RainbowGate = dynamic(() => import("@calcom/app-store/rainbow/components/RainbowKit"));

// To add a new Gate just add the gate logic to the switch statement
const Gates: React.FC<GateProps> = ({ children, gates, metadata, dispatch }) => {
const [rainbowToken, setRainbowToken] = useState<string>();
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/ImageUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function CropContainer({
);
}

/** @deprecated Use `packages/ui/v2/core/ImageUploader.tsx` */
export default function ImageUploader({
target,
id,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/availability/SkeletonLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SkeletonText } from "@calcom/ui";

function SkeletonLoader() {
return (
<ul className="animate-pulse divide-y divide-neutral-200 border border-gray-200 bg-white sm:mx-0 sm:overflow-hidden">
<ul className="animate-pulse divide-y divide-neutral-200 rounded-md border border-gray-200 bg-white sm:mx-0 sm:overflow-hidden">
<SkeletonItem />
<SkeletonItem />
<SkeletonItem />
Expand Down
113 changes: 105 additions & 8 deletions apps/web/components/booking/BookingListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,14 @@ function BookingListItem(booking: BookingItemProps) {
"max-w-56 truncate text-sm font-medium leading-6 text-neutral-900 md:max-w-max",
isCancelled ? "line-through" : ""
)}>
{booking.eventType?.team && <strong>{booking.eventType.team.name}: </strong>}
{booking.title}
<span> </span>
{booking.eventType?.team && <Badge variant="gray">{booking.eventType.team.name}</Badge>}

{!!booking?.eventType?.price && !booking.paid && (
<Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">Pending payment</Tag>
)}
{isPending && <Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">{t("unconfirmed")}</Tag>}
</div>
{booking.description && (
<div
Expand All @@ -337,14 +343,12 @@ function BookingListItem(booking: BookingItemProps) {
&quot;{booking.description}&quot;
</div>
)}

{booking.attendees.length !== 0 && (
<a
className="text-sm text-gray-900 hover:text-blue-500"
href={"mailto:" + booking.attendees[0].email}
onClick={(e) => e.stopPropagation()}>
{booking.attendees[0].email}
</a>
<DisplayAttendees
attendees={booking.attendees}
user={booking.user}
currentEmail={user?.email}
/>
)}
{isCancelled && booking.rescheduled && (
<div className="mt-2 inline-block text-left text-sm md:hidden">
Expand Down Expand Up @@ -373,4 +377,97 @@ function BookingListItem(booking: BookingItemProps) {
);
}

interface UserProps {
id: number;
name: string | null;
email: string;
}

const FirstAttendee = ({
user,
currentEmail,
}: {
user: UserProps;
currentEmail: string | null | undefined;
}) => {
return user.email === currentEmail ? (
<div className="inline-block">You</div>
) : (
<a
key={user.email}
className=" hover:text-blue-500"
href={"mailto:" + user.email}
onClick={(e) => e.stopPropagation()}>
{user.name}
</a>
);
};

const Attendee: React.FC<{ email: string; children: React.ReactNode }> = ({ email, children }) => {
return (
<a className=" hover:text-blue-500" href={"mailto:" + email} onClick={(e) => e.stopPropagation()}>
{children}
</a>
);
};

interface AttendeeProps {
name: string;
email: string;
}

const DisplayAttendees = ({
attendees,
user,
currentEmail,
}: {
attendees: AttendeeProps[];
user: UserProps | null;
currentEmail: string | null | undefined;
}) => {
if (attendees.length === 1) {
return (
<div className="text-sm text-gray-900">
{user && <FirstAttendee user={user} currentEmail={currentEmail} />}
<span>&nbsp;and&nbsp;</span>
<Attendee email={attendees[0].email}>{attendees[0].name}</Attendee>
</div>
);
} else if (attendees.length === 2) {
return (
<div className="text-sm text-gray-900">
{user && <FirstAttendee user={user} currentEmail={currentEmail} />}
<span>,&nbsp;</span>
<Attendee email={attendees[0].email}>{attendees[0].name}</Attendee>
<div className="inline-block text-sm text-gray-900">&nbsp;and&nbsp;</div>
<Attendee email={attendees[1].email}>{attendees[1].name}</Attendee>
</div>
);
} else {
return (
<div className="text-sm text-gray-900">
{user && <FirstAttendee user={user} currentEmail={currentEmail} />}
<span>,&nbsp;</span>
<Attendee email={attendees[0].email}>{attendees[0].name}</Attendee>
<span>&nbsp;&&nbsp;</span>
<Tooltip
content={attendees.slice(1).map((attendee, key) => (
<p key={key}>{attendee.name}</p>
))}>
<div className="inline-block">{attendees.length - 1} more</div>
</Tooltip>
</div>
);
}
};

const Tag = ({ children, className = "" }: React.PropsWithChildren<{ className?: string }>) => {
return (
<span
className={`inline-flex items-center rounded-sm bg-yellow-100 px-1.5 py-0.5 text-xs font-medium text-yellow-800 ${className}`}>
{children}
</span>
);
};

export default BookingListItem;
4 changes: 2 additions & 2 deletions apps/web/components/booking/SkeletonLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SkeletonText } from "@calcom/ui";

function SkeletonLoader() {
return (
<ul className="mx-6 mt-6 animate-pulse divide-y divide-neutral-200 border border-gray-200 bg-white sm:overflow-hidden">
<ul className="animate-pulse divide-y divide-neutral-200 rounded-md border border-gray-200 bg-white sm:overflow-hidden">
<SkeletonItem />
<SkeletonItem />
<SkeletonItem />
Expand All @@ -16,7 +16,7 @@ export default SkeletonLoader;

function SkeletonItem() {
return (
<li className="group flex w-full items-center justify-between px-2 py-4 sm:px-6">
<li className="group flex w-full items-center justify-between px-4 py-4 sm:px-6">
<div className="flex-grow truncate text-sm">
<div className="flex">
<div className="flex flex-col space-y-2">
Expand Down
17 changes: 2 additions & 15 deletions apps/web/components/eventtype/SkeletonLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ function SkeletonLoader() {
return (
<SkeletonContainer>
<div className="mb-4 flex items-center">
<SkeletonAvatar className="h-8 w-8" />
<SkeletonAvatar width="8" height="8" />
<div className="space-y-1">
<SkeletonText className="h-4 w-16" />
<SkeletonText className="h-4 w-24" />
</div>
</div>
<ul className="divide-y divide-neutral-200 border border-gray-200 bg-white sm:mx-0 sm:overflow-hidden">
<ul className="divide-y divide-neutral-200 rounded-md border border-gray-200 bg-white sm:mx-0 sm:overflow-hidden">
<SkeletonItem />
<SkeletonItem />
<SkeletonItem />
Expand Down Expand Up @@ -42,19 +42,6 @@ function SkeletonItem() {
</ul>
</div>
</div>
<div className="mt-4 hidden flex-shrink-0 sm:mt-0 sm:ml-5 sm:flex">
<div className="flex justify-between rtl:space-x-reverse">
<div className="cursor-pointer appearance-none rounded-sm border border-transparent p-2 text-neutral-500 hover:border-gray-300 hover:text-neutral-900">
<Icon.FiExternalLink className="h-5 w-5" />
</div>
<div className="cursor-pointer appearance-none rounded-sm border border-transparent p-2 text-neutral-500 hover:border-gray-300 hover:text-neutral-900">
<Icon.FiLink className="h-5 w-5" />
</div>
<div className="cursor-pointer appearance-none rounded-sm border border-transparent p-2 text-neutral-500 hover:border-gray-300 hover:text-neutral-900">
<Icon.FiMoreHorizontal className="h-5 w-5" />
</div>
</div>
</div>
</li>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { User } from "@calcom/prisma/client";
import { trpc } from "@calcom/trpc/react";
import { Button, showToast, TextArea } from "@calcom/ui/v2";
import ImageUploader from "@calcom/ui/v2/core/ImageUploader";

import { AvatarSSR } from "@components/ui/AvatarSSR";
import ImageUploader from "@components/v2/settings/ImageUploader";

interface IUserProfile {
user?: User;
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/team/DisableTeamImpersonation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { trpc } from "@calcom/trpc/react";
import Badge from "@calcom/ui/Badge";
import Button from "@calcom/ui/Button";

/** @deprecated Use `packages/features/ee/teams/components/DisableTeamImpersonation.tsx` */
const DisableTeamImpersonation = ({ teamId, memberId }: { teamId: number; memberId: number }) => {
const { t } = useLocale();

Expand Down
1 change: 1 addition & 0 deletions apps/web/components/team/MemberChangeRoleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type MembershipRoleOption = {
value: MembershipRole;
};

/** @deprecated Use `packages/features/ee/teams/components/MemberChangeRoleModal.tsx` */
export default function MemberChangeRoleModal(props: {
isOpen: boolean;
currentMember: MembershipRole;
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/team/MemberInvitationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type MembershipRoleOption = {

const _options: MembershipRoleOption[] = [{ value: "MEMBER" }, { value: "ADMIN" }, { value: "OWNER" }];

/** @deprecated Use `packages/features/ee/teams/components/MemberInvitationModal.tsx` */
export default function MemberInvitationModal(props: MemberInvitationModalProps) {
const [errorMessage, setErrorMessage] = useState("");
const { t, i18n } = useLocale();
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/team/MemberListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface Props {
member: inferQueryOutput<"viewer.teams.get">["members"][number];
}

/** @deprecated Use `packages/features/ee/teams/components/MemberListItem.tsx` */
export default function MemberListItem(props: Props) {
const { t } = useLocale();

Expand Down
1 change: 1 addition & 0 deletions apps/web/components/team/TeamPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props {
color?: PillColor;
}

/** @deprecated Use `packages/features/ee/teams/components/TeamPill.tsx` */
export default function TeamPill(props: Props) {
return (
<div
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/team/UpgradeToFlexibleProModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Props {
teamId: number;
}

/** @deprecated Use `packages/features/ee/teams/components/UpgradeToFlexibleProModal.tsx` */
export function UpgradeToFlexibleProModal(props: Props) {
const { t } = useLocale();
const [errorMessage, setErrorMessage] = useState<string | null>(null);
Expand Down
Loading