fix: /members improvements (#17911)

* remove heading for more space

* fix: mobile support for mass attribute assigning bar

* change the order of Members item on Navigation

* refactor NavigationItem to support moreOnMobile property

* fix logic for nav

* decrease column widths on member list

* improve mobile design for mass attribute assign

* adjust mobile ui for DataTableSelectionBar

* add key to EventTypesList

---------

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-12-02 19:13:08 +00:00
1 parent 51c91e41da
commit a5ba2682f6
14 files changed
+85 -54

No files matched your search

@@ -13,8 +13,6 @@ const MembersPage: React.FC = () => {
title={t("organization_members")}
description={t("organization_description")}
withoutSeo
heading={t("organization_members")}
hideHeadingOnMobile
subtitle={t("organization_description")}>
<HeadSeo title={t("organization_members")} description={t("organization_description")} />
@@ -2825,6 +2825,7 @@
"disable_org_url_description": "Redirects {{orgSlug}}.cal.com to {{destination}}",
"single_select": "Single Select",
"multi_select": "Multi Select",
"group_meeting": "Group Meeting",
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
}
@@ -4,6 +4,7 @@ import type { Table } from "@tanstack/react-table";
import { forwardRef } from "react";
import { classNames } from "@calcom/lib";
import { Button, Icon } from "@calcom/ui";
import type { IconName } from "@calcom/ui";
export type ActionItem<TData> =
@@ -20,19 +21,41 @@ export type ActionItem<TData> =
needsXSelected?: number;
};
type ResponsiveButtonProps = {
className?: string;
icon: IconName;
onClick?: () => void;
children: string;
};
const ResponsiveButton = forwardRef<HTMLButtonElement, ResponsiveButtonProps>(
({ className, icon, onClick, children }, ref) => {
return (
<Button ref={ref} onClick={onClick} title={children}>
<Icon name={icon} size={18} className="sm:hidden" />
<Icon name={icon} size={16} className="mr-2 hidden shrink-0 sm:inline" />
<span className="sr-only shrink-0 md:not-sr-only">{children}</span>
</Button>
);
}
);
ResponsiveButton.displayName = "ResponsiveButton";
const Root = forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & { showSelectionCount?: boolean }
>(({ children, ...props }, ref) => {
const { className, style, ...rest } = props;
return (
<div
ref={ref}
className={classNames(
"bg-brand-default text-brand fixed bottom-4 left-1/2 flex w-fit -translate-x-1/2 transform items-center space-x-3 rounded-lg px-4 py-2",
props.className
"bg-brand-default text-brand fixed bottom-0 left-0 z-40 flex w-full items-center space-x-1 overflow-x-auto px-2 py-2 sm:space-x-2 md:bottom-4 md:left-1/2 md:z-auto md:w-fit md:-translate-x-1/2 md:transform md:space-x-3 md:overflow-x-hidden md:rounded-lg md:px-4",
className
)}
style={{ ...props.style }}
{...props}>
style={{ ...style }}
{...rest}>
{children}
</div>
);
@@ -42,4 +65,5 @@ Root.displayName = "Root";
export const DataTableSelectionBar = {
Root,
Button: ResponsiveButton,
};
@@ -1,6 +1,7 @@
import { DataTableSelectionBar } from "@calcom/features/data-table";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Button, ConfirmationDialogContent, Dialog, DialogTrigger, showToast } from "@calcom/ui";
import { ConfirmationDialogContent, Dialog, DialogTrigger, showToast } from "@calcom/ui";
import type { User } from "./MemberList";
@@ -30,7 +31,7 @@ export default function DeleteBulkTeamMembers({ users, onRemove, isOrg, teamId }
return (
<Dialog>
<DialogTrigger asChild>
<Button StartIcon="ban">{t("Delete")}</Button>
<DataTableSelectionBar.Button icon="ban">{t("Delete")}</DataTableSelectionBar.Button>
</DialogTrigger>
<ConfirmationDialogContent
variety="danger"
@@ -1,7 +1,8 @@
import type { Table } from "@tanstack/react-table";
import type { Dispatch, SetStateAction } from "react";
import { useState } from "react";
import { useState, Fragment } from "react";
import { DataTableSelectionBar } from "@calcom/features/data-table";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SchedulingType } from "@calcom/prisma/enums";
@@ -93,7 +94,7 @@ export function EventTypesList({ table, teamId }: Props) {
<>
<Popover>
<PopoverTrigger asChild>
<Button StartIcon="link">{t("add_to_event_type")}</Button>
<DataTableSelectionBar.Button icon="link">{t("add_to_event_type")}</DataTableSelectionBar.Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0 shadow-md" align="start" sideOffset={12}>
<Command>
@@ -108,7 +109,7 @@ export function EventTypesList({ table, teamId }: Props) {
if (events.length === 0 || !teamId) return null;
return (
<>
<Fragment key={teamId}>
{events.map((event) => {
const hosts = event.hosts;
const areAllUsersHostForEventType = selectedUsers.every((user) =>
@@ -143,7 +144,7 @@ export function EventTypesList({ table, teamId }: Props) {
/>
);
})}
</>
</Fragment>
);
})}
</CommandGroup>
@@ -674,19 +674,21 @@ export default function MemberList(props: Props) {
</DataTableToolbar.Root>
{numberOfSelectedRows >= 2 && dynamicLinkVisible && (
<DataTableSelectionBar.Root style={{ bottom: "5rem" }}>
<DataTableSelectionBar.Root className="!bottom-16 md:!bottom-20">
<DynamicLink table={table} domain={domain} />
</DataTableSelectionBar.Root>
)}
{numberOfSelectedRows > 0 && (
<DataTableSelectionBar.Root>
<p className="text-brand-subtle w-full px-2 text-center leading-none">
{numberOfSelectedRows} selected
<DataTableSelectionBar.Root className="justify-center">
<p className="text-brand-subtle px-2 text-center text-xs leading-none sm:text-sm sm:font-medium">
{t("number_selected", { count: numberOfSelectedRows })}
</p>
{numberOfSelectedRows >= 2 && (
<Button onClick={() => setDynamicLinkVisible(!dynamicLinkVisible)} StartIcon="handshake">
Group Meeting
</Button>
<DataTableSelectionBar.Button
onClick={() => setDynamicLinkVisible(!dynamicLinkVisible)}
icon="handshake">
{t("group_meeting")}
</DataTableSelectionBar.Button>
)}
<EventTypesList table={table} teamId={props.team.id} />
<DeleteBulkTeamMembers
@@ -40,6 +40,7 @@ const getNavigationItems = (orgBranding: OrganizationBranding): NavigationItemTy
name: "members",
href: `/settings/organizations/${orgBranding.slug}/members`,
icon: "building",
moreOnMobile: true,
} satisfies NavigationItemType,
]
: []),
@@ -90,17 +91,20 @@ const getNavigationItems = (orgBranding: OrganizationBranding): NavigationItemTy
href: "/apps/routing-forms/forms",
icon: "file-text",
isCurrent: ({ pathname }) => pathname?.startsWith("/apps/routing-forms/") ?? false,
moreOnMobile: true,
},
{
name: "workflows",
href: "/workflows",
icon: "zap",
moreOnMobile: true,
},
{
name: "insights",
href: "/insights",
icon: "chart-bar",
isCurrent: ({ pathname: path, item }) => path?.startsWith(item.href) ?? false,
moreOnMobile: true,
child: [
{
name: "bookings",
@@ -150,36 +154,27 @@ const platformNavigationItems: NavigationItemType[] = [
name: "Billing",
href: "/settings/platform/billing",
icon: "credit-card",
moreOnMobile: true,
},
{
name: "Members",
href: "/settings/platform/members",
icon: "users",
moreOnMobile: true,
},
];
const useNavigationItems = (isPlatformNavigation = false) => {
const orgBranding = useOrgBranding();
return useMemo(() => {
const navigationType = !isPlatformNavigation ? getNavigationItems(orgBranding) : platformNavigationItems;
const moreSeparatorIndex = navigationType.findIndex((item) => item.name === MORE_SEPARATOR_NAME);
const items = !isPlatformNavigation ? getNavigationItems(orgBranding) : platformNavigationItems;
const { desktopNavigationItems, mobileNavigationBottomItems, mobileNavigationMoreItems } = (
!isPlatformNavigation ? getNavigationItems(orgBranding) : platformNavigationItems
).reduce<Record<string, NavigationItemType[]>>(
(items, item, index) => {
// We filter out the "more" separator in` desktop navigation
if (item.name !== MORE_SEPARATOR_NAME) items.desktopNavigationItems.push(item);
// Items for mobile bottom navigation
if (index < moreSeparatorIndex + 1 && !item.onlyDesktop) {
items.mobileNavigationBottomItems.push(item);
} // Items for the "more" menu in mobile navigation
else {
items.mobileNavigationMoreItems.push(item);
}
return items;
},
{ desktopNavigationItems: [], mobileNavigationBottomItems: [], mobileNavigationMoreItems: [] }
const desktopNavigationItems = items.filter((item) => item.name !== MORE_SEPARATOR_NAME);
const mobileNavigationBottomItems = items.filter(
(item) => (!item.moreOnMobile && !item.onlyDesktop) || item.name === MORE_SEPARATOR_NAME
);
const mobileNavigationMoreItems = items.filter(
(item) => item.moreOnMobile && !item.onlyDesktop && item.name !== MORE_SEPARATOR_NAME
);
return { desktopNavigationItems, mobileNavigationBottomItems, mobileNavigationMoreItems };
@@ -21,6 +21,7 @@ export type NavigationItemType = {
pro?: true;
onlyMobile?: boolean;
onlyDesktop?: boolean;
moreOnMobile?: boolean;
isCurrent?: ({
item,
isChild,
@@ -1,6 +1,7 @@
import { DataTableSelectionBar } from "@calcom/features/data-table";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Button, ConfirmationDialogContent, Dialog, DialogTrigger, showToast } from "@calcom/ui";
import { ConfirmationDialogContent, Dialog, DialogTrigger, showToast } from "@calcom/ui";
import type { UserTableUser } from "../types";
@@ -38,7 +39,7 @@ export function DeleteBulkUsers({ users, onRemove }: Props) {
return (
<Dialog>
<DialogTrigger asChild>
<Button StartIcon="ban">{t("Delete")}</Button>
<DataTableSelectionBar.Button icon="ban">{t("Delete")}</DataTableSelectionBar.Button>
</DialogTrigger>
<ConfirmationDialogContent
variety="danger"
@@ -32,10 +32,10 @@ export function DynamicLink<T extends { username: string | null }>({
<>
{isVisible ? (
<div className="w-full gap-1 rounded-lg text-sm font-medium leading-none md:flex">
<div className="max-w-[300px] items-center truncate p-2">
<p>{domainWithoutHttps}</p>
<div className="items-center truncate p-2 md:max-w-[300px]">
<p className="text-center md:text-left">{domainWithoutHttps}</p>
</div>
<div className="ml-auto flex items-center">
<div className="ml-auto flex items-center justify-center md:justify-start">
<Button StartIcon="copy" size="sm" onClick={() => copyToClipboard(dynamicLinkOfSelectedUsers)}>
{!isCopied ? t("copy") : t("copied")}
</Button>
@@ -2,6 +2,7 @@ import type { Table } from "@tanstack/react-table";
import type { Dispatch, SetStateAction } from "react";
import { useState, Fragment } from "react";
import { DataTableSelectionBar } from "@calcom/features/data-table";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SchedulingType } from "@calcom/prisma/enums";
@@ -97,7 +98,7 @@ export function EventTypesList({ table, orgTeams }: Props) {
<>
<Popover>
<PopoverTrigger asChild>
<Button StartIcon="link">{t("add_to_event_type")}</Button>
<DataTableSelectionBar.Button icon="link">{t("add_to_event_type")}</DataTableSelectionBar.Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0 shadow-md" align="start" sideOffset={12}>
<Command>
@@ -3,6 +3,7 @@ import type { ColumnFiltersState } from "@tanstack/react-table";
import { createContext, useContext, useState, useMemo, type PropsWithChildren } from "react";
import type { Dispatch, SetStateAction } from "react";
import { DataTableSelectionBar } from "@calcom/features/data-table";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import slugify from "@calcom/lib/slugify";
@@ -329,7 +330,7 @@ function MassAssignAttributesBulkActionComponent({ table, filters }: Props) {
}
}}>
<PopoverTrigger asChild>
<Button StartIcon="map-pin">{t("add_attributes")}</Button>
<DataTableSelectionBar.Button icon="tags">{t("add_attributes")}</DataTableSelectionBar.Button>
</PopoverTrigger>
{/* We dont really use shadows much - but its needed here */}
<PopoverContent className="p-0 shadow-md" align="start" sideOffset={12}>
@@ -2,6 +2,7 @@ import type { Table } from "@tanstack/react-table";
import type { Dispatch, SetStateAction } from "react";
import { useState } from "react";
import { DataTableSelectionBar } from "@calcom/features/data-table";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc";
@@ -86,7 +87,7 @@ export function TeamListBulkAction({ table }: Props) {
<>
<Popover>
<PopoverTrigger asChild>
<Button StartIcon="users">{t("add_to_team")}</Button>
<DataTableSelectionBar.Button icon="users">{t("add_to_team")}</DataTableSelectionBar.Button>
</PopoverTrigger>
{/* We dont really use shadows much - but its needed here */}
<PopoverContent className="w-[200px] p-0 shadow-md" align="start" sideOffset={12}>
@@ -34,7 +34,7 @@ import {
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc";
import { Avatar, Badge, Button, Checkbox, showToast } from "@calcom/ui";
import { Avatar, Badge, Checkbox, showToast } from "@calcom/ui";
import { useGetUserAttributes } from "@calcom/web/components/settings/platform/hooks/useGetUserAttributes";
import { DeleteBulkUsers } from "./BulkActions/DeleteBulkUsers";
@@ -176,6 +176,7 @@ export function UserListTable() {
meta: {
filterType: attribute.type.toLowerCase() === "text" ? "text" : "select",
},
size: 120,
accessorFn: (data) => data.attributes.find((attr) => attr.attributeId === attribute.id)?.value,
cell: ({ row }) => {
const attributeValues = row.original.attributes.filter(
@@ -280,6 +281,7 @@ export function UserListTable() {
id: "role",
accessorFn: (data) => data.role,
header: "Role",
size: 100,
cell: ({ row, table }) => {
const { role, username } = row.original;
return (
@@ -307,7 +309,7 @@ export function UserListTable() {
id: "teams",
accessorFn: (data) => data.teams.map((team) => team.name),
header: "Teams",
size: 200,
size: 140,
cell: ({ row, table }) => {
const { teams, accepted, email, username } = row.original;
// TODO: Implement click to filter
@@ -546,22 +548,24 @@ export function UserListTable() {
</div>
{numberOfSelectedRows >= 2 && dynamicLinkVisible && (
<DataTableSelectionBar.Root style={{ bottom: "5rem" }}>
<DataTableSelectionBar.Root className="!bottom-16 md:!bottom-20">
<DynamicLink table={table} domain={domain} />
</DataTableSelectionBar.Root>
)}
{numberOfSelectedRows > 0 && (
<DataTableSelectionBar.Root>
<p className="text-brand-subtle w-full px-2 text-center leading-none">
{numberOfSelectedRows} selected
<DataTableSelectionBar.Root className="justify-center">
<p className="text-brand-subtle px-2 text-center text-xs leading-none sm:text-sm sm:font-medium">
{t("number_selected", { count: numberOfSelectedRows })}
</p>
{!isPlatformUser ? (
<>
<TeamListBulkAction table={table} />
{numberOfSelectedRows >= 2 && (
<Button onClick={() => setDynamicLinkVisible(!dynamicLinkVisible)} StartIcon="handshake">
Group Meeting
</Button>
<DataTableSelectionBar.Button
onClick={() => setDynamicLinkVisible(!dynamicLinkVisible)}
icon="handshake">
{t("group_meeting")}
</DataTableSelectionBar.Button>
)}
<MassAssignAttributesBulkAction table={table} filters={columnFilters} />
<EventTypesList table={table} orgTeams={teams} />