Files
cal.diy/packages/ui/v2/core/apps/AppCard.tsx
T
+4 d55ffe8d9d Feat: v2 App Store / Installed Apps (#4220)
* First commit

* Additional changes to meet designs

* Fixing app details disconnect button
App Store category filtering fixed

* Further changes for the fix

* Progress on various fronts

* Fixing e2e tests

* second try fixing e2e tests

* Yet again trying to fix e2e tests

* Missing action for non-credential flow

* Adding missing Add button

* Final tweaks and fixes

* Missing button in empty screen

* fix border radius

* EmptyScreen for calendar

* Dynamic installed app return page with highlights + other fixes

* Removing unneeded code

* App Store V2 Improvements over feat/v2-installed-apps (#4379)

* Removing unneeded text

* Fixing app details disconnect button and number of apps (#4305)

* V2 Settings Shell - Add Teams Section & UI fixes (#4347)

* Add teams to sidebar and fix UI

* Clean up

* V2 Multi-select (Team Select) (#4324)

* --init

* design improved

* further fine tuning

* more fixes

* removed extra JSX tag

* added story

* NIT

* revert to use of CheckedTeamSelect

* Removes comments

Co-authored-by: Peer Richelsen <[email protected]>

* fix: toggle alligment (#4361)

* fix: add checked tranform for switch (#4357)

* fixed input size on mobile, fixed settings (#4360)

* fixing type errors

* Mobile fixes

* Tests fixes

Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: zomars <[email protected]>

* Feat/team owner booking (#3999)

* WIP: testing queries

* feat: add badge

* fix: get only id

* refactor: get bookings query

* WIP: display attendees added

* fix: add type

* Adds skeleton loader to workflows (#4402)

* fix event types skeleton loader

* fix margin in event types

* fix skeleton loader in bookings

* add skeleton loader for workflow list

* add skeleton loader for editing page

* fix border radius of skeleton loader

* fix mobile view workflow list

* add mobile view for skeleton list

* make multi select full with in mobile view

* mobile view for edit skeleton loader

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* V2 settings teams (Profil, Members, Appearance View) (#4350)

* add team profile

* first version for team members page

* finish up design of member list item

* fix dialog buttons

* add missing seats and upgrading information

* add v2 dialog for changing role

* finish basic version of member's schedule

* remove modalContainer

* design fixes team profile page

* show only team info to non admins

* allow all member to check availabilities

* make time available heading sticky

* add dropdown for mobile view

* create team appearance view

* finish appearance page

* use settings layout and add danger zone for member

* add fallback logo

* Add teams to sidebar and fix UI

* add team invitations

* Clean up

* code clean up

* add impersontation and disable autofocus on calendar

* improve team info

* refactor teaminvitelist code and fix leaving a team

* add team pages to settings shell

* add link to create new team

* small fixes

* clean up comments

* V2 Multi-select (Team Select) (#4324)

* --init

* design improved

* further fine tuning

* more fixes

* removed extra JSX tag

* added story

* NIT

* revert to use of CheckedTeamSelect

* Removes comments

Co-authored-by: Peer Richelsen <[email protected]>

* fix: toggle alligment (#4361)

* fix: add checked tranform for switch (#4357)

* fixed input size on mobile, fixed settings (#4360)

* fix image uploader button in safari

* code clean up

* fixing type errors

* Moved v2 team components to features

Adds deprecation notices

* Update SettingsLayout.tsx

* Migrated to features and build fixes

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: zomars <[email protected]>

* add rainbowkit form to v2 event-types (#4349)

Co-authored-by: Omar López <[email protected]>

* v1.9.5

* Fix/daterangepicker css (#4418)

* added styles from external stylesheet

* fixed a border color

* codacy improvements

* more codacy fix

* codacy why u be so dumb

* dynamic import rainbow (only if installed) (#4409)

* Tidyup app cards (#4428)

* Moving API to trpc query

Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: zomars <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: hexcowboy <[email protected]>
Co-authored-by: sean-brydon <[email protected]>

* Abstracting one level the redirectUrl for apps

* Moving enum to a better/working place

* Another try

* Missing code

* Correcting categories look in apps page

* ui tweaks

* Breadcrumb wrong font-weight

* Toast is v1 component and copy updated

* Fix TS error

* Fix TS error

* Update AppsLayout.tsx

* Update InstalledAppsLayout.tsx

* translations and disconnect button with icon

* Reverting file

* Test e2e fix on app-store

* Missing testid in button

* Fix to click categories that are visible

* Going directly to category page as a patch

* Fixing stripe e2e test

* Disconnect is now empty with icon

* Disabled stripe test for now as the navigation is completely changed

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: hexcowboy <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
2022-09-15 19:53:09 +00:00

133 lines
4.9 KiB
TypeScript

import type { Credential } from "@prisma/client";
import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
import { InstallAppButton } from "@calcom/app-store/components";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import showToast from "@calcom/lib/notification";
import { trpc } from "@calcom/trpc/react";
import { App } from "@calcom/types/App";
import { Icon } from "@calcom/ui/Icon";
import Button from "@calcom/ui/v2/core/Button";
import { SkeletonText } from "../skeleton";
interface AppCardProps {
app: App;
credentials?: Credential[];
}
export default function AppCard({ app, credentials }: AppCardProps) {
const { t } = useLocale();
const { isLocaleReady } = useLocale();
const mutation = useAddAppMutation(null, {
onSuccess: () => {
showToast(t("app_successfully_installed"), "success");
},
onError: (error) => {
if (error instanceof Error) showToast(error.message || t("app_could_not_be_installed"), "error");
},
});
const allowedMultipleInstalls = app.categories && app.categories.indexOf("calendar") > -1;
const appAdded = (credentials && credentials.length) || 0;
return (
<div className="relative flex h-64 flex-col rounded-md border border-gray-300 p-5">
<div className="flex">
<img src={app.logo} alt={app.name + " Logo"} className="mb-4 h-12 w-12 rounded-sm" />
</div>
<div className="flex items-center">
<h3 className="font-medium">{app.name}</h3>
</div>
{/* TODO: add reviews <div className="flex text-sm text-gray-800">
<span>{props.rating} stars</span> <StarIcon className="ml-1 mt-0.5 h-4 w-4 text-yellow-600" />
<span className="pl-1 text-gray-500">{props.reviews} reviews</span>
</div> */}
<p
className="mt-2 flex-grow text-sm text-gray-500"
style={{
overflow: "hidden",
display: "-webkit-box",
WebkitBoxOrient: "vertical",
WebkitLineClamp: "3",
}}>
{app.description}
</p>
<div className="mt-5 flex max-w-full flex-row flex-wrap justify-between gap-2">
<Button
color="secondary"
className="flex w-32 flex-grow justify-center"
href={`/apps/${app.slug}`}
data-testid={`app-store-app-card-${app.slug}`}>
{t("details")}
</Button>
{app.isGlobal || (credentials && credentials.length > 0 && allowedMultipleInstalls)
? !app.isGlobal && (
<InstallAppButton
type={app.type}
isProOnly={app.isProOnly}
wrapperClassName="[@media(max-width:260px)]:w-full"
render={({ useDefaultComponent, ...props }) => {
if (useDefaultComponent) {
props = {
onClick: () => {
mutation.mutate({ type: app.type, variant: app.variant, slug: app.slug });
},
};
}
return (
<Button
color="secondary"
className="[@media(max-width:260px)]:w-full [@media(max-width:260px)]:justify-center"
StartIcon={Icon.FiPlus}
{...props}>
{t("install")}
</Button>
);
}}
/>
)
: credentials &&
credentials.length === 0 && (
<InstallAppButton
type={app.type}
isProOnly={app.isProOnly}
wrapperClassName="[@media(max-width:260px)]:w-full"
render={({ useDefaultComponent, ...props }) => {
if (useDefaultComponent) {
props = {
onClick: () => {
mutation.mutate({ type: app.type, variant: app.variant, slug: app.slug });
},
};
}
return (
<Button
StartIcon={Icon.FiPlus}
color="secondary"
className="[@media(max-width:260px)]:w-full [@media(max-width:260px)]:justify-center"
data-testid="install-app-button"
{...props}>
{t("install")}
</Button>
);
}}
/>
)}
</div>
<div className="max-w-44 absolute right-0 mr-4 flex flex-wrap justify-end gap-1">
{appAdded > 0 && (
<span className="rounded-md bg-green-100 px-2 py-1 text-sm font-normal text-green-800">
{t("installed", { count: appAdded })}
</span>
)}
{app.isGlobal && (
<span className="flex items-center rounded-md bg-gray-100 px-2 py-1 text-sm font-normal text-gray-800">
{t("default")}
</span>
)}
</div>
</div>
);
}