Chor/move table actions (#6157)
* Move table actions * Move table actions Co-authored-by: Peer Richelsen <peeroke@gmail.com>pull/5544/head^2
parent
a076418989
commit
83b60de640
|
@ -23,12 +23,12 @@ import {
|
||||||
TextArea,
|
TextArea,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@calcom/ui";
|
} from "@calcom/ui";
|
||||||
|
import { ActionType, TableActions } from "@calcom/ui";
|
||||||
|
|
||||||
import useMeQuery from "@lib/hooks/useMeQuery";
|
import useMeQuery from "@lib/hooks/useMeQuery";
|
||||||
|
|
||||||
import { EditLocationDialog } from "@components/dialog/EditLocationDialog";
|
import { EditLocationDialog } from "@components/dialog/EditLocationDialog";
|
||||||
import { RescheduleDialog } from "@components/dialog/RescheduleDialog";
|
import { RescheduleDialog } from "@components/dialog/RescheduleDialog";
|
||||||
import TableActions, { ActionType } from "@components/ui/TableActions";
|
|
||||||
|
|
||||||
type BookingListingStatus = RouterInputs["viewer"]["bookings"]["get"]["status"];
|
type BookingListingStatus = RouterInputs["viewer"]["bookings"]["get"]["status"];
|
||||||
|
|
||||||
|
|
|
@ -29,3 +29,5 @@ export {
|
||||||
} from "./form";
|
} from "./form";
|
||||||
export { TopBanner } from "./top-banner";
|
export { TopBanner } from "./top-banner";
|
||||||
export type { TopBannerProps } from "./top-banner";
|
export type { TopBannerProps } from "./top-banner";
|
||||||
|
export { TableActions, DropdownActions } from "./table/TableActions";
|
||||||
|
export type { ActionType } from "./table/TableActions";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { FC } from "react";
|
import React, { FC } from "react";
|
||||||
|
import { IconType } from "react-icons/lib";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
@ -7,18 +8,17 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuPortal,
|
DropdownMenuPortal,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
|
ButtonBaseProps,
|
||||||
Icon,
|
Icon,
|
||||||
} from "@calcom/ui";
|
} from "@calcom/ui";
|
||||||
|
|
||||||
import { SVGComponent } from "@lib/types/SVGComponent";
|
|
||||||
|
|
||||||
export type ActionType = {
|
export type ActionType = {
|
||||||
id: string;
|
id: string;
|
||||||
icon?: SVGComponent;
|
icon?: IconType;
|
||||||
iconClassName?: string;
|
iconClassName?: string;
|
||||||
label: string;
|
label: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
color?: "primary" | "secondary";
|
color?: ButtonBaseProps["color"];
|
||||||
} & (
|
} & (
|
||||||
| { href: string; onClick?: never; actions?: never }
|
| { href: string; onClick?: never; actions?: never }
|
||||||
| { href?: never; onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void; actions?: never }
|
| { href?: never; onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void; actions?: never }
|
||||||
|
@ -33,7 +33,7 @@ const defaultAction = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
const DropdownActions = ({
|
export const DropdownActions = ({
|
||||||
actions,
|
actions,
|
||||||
actionTrigger,
|
actionTrigger,
|
||||||
}: {
|
}: {
|
||||||
|
@ -52,10 +52,10 @@ const DropdownActions = ({
|
||||||
<DropdownMenuPortal>
|
<DropdownMenuPortal>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
{actions.map((action) => (
|
{actions.map((action) => (
|
||||||
<DropdownMenuItem key={action.id} className="focus-visible:outline-none">
|
<DropdownMenuItem key={action.id}>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
color="minimal"
|
color={action.color || "minimal"}
|
||||||
className="w-full rounded-none font-normal"
|
className="w-full rounded-none font-normal"
|
||||||
href={action.href}
|
href={action.href}
|
||||||
StartIcon={action.icon}
|
StartIcon={action.icon}
|
||||||
|
@ -71,7 +71,7 @@ const DropdownActions = ({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const TableActions: FC<Props> = ({ actions }) => {
|
export const TableActions: FC<Props> = ({ actions }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex space-x-2 rtl:space-x-reverse">
|
<div className="flex space-x-2 rtl:space-x-reverse">
|
||||||
|
@ -99,5 +99,3 @@ const TableActions: FC<Props> = ({ actions }) => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TableActions;
|
|
|
@ -27,7 +27,10 @@ export {
|
||||||
Select,
|
Select,
|
||||||
SelectField,
|
SelectField,
|
||||||
SelectWithValidation,
|
SelectWithValidation,
|
||||||
|
TableActions,
|
||||||
|
DropdownActions,
|
||||||
} from "./components";
|
} from "./components";
|
||||||
|
export type { ActionType } from "./components";
|
||||||
export type { AvatarProps, BadgeProps, ButtonBaseProps, ButtonProps, TopBannerProps } from "./components";
|
export type { AvatarProps, BadgeProps, ButtonBaseProps, ButtonProps, TopBannerProps } from "./components";
|
||||||
export { default as CheckboxField } from "./components/form/checkbox/Checkbox";
|
export { default as CheckboxField } from "./components/form/checkbox/Checkbox";
|
||||||
/** ⬇️ TODO - Move these to components */
|
/** ⬇️ TODO - Move these to components */
|
||||||
|
|
Loading…
Reference in New Issue