✨(frontend) enhance document sharing components
- Refactored DocShareAddMemberList to simplify button styling and improve loading state handling. - Updated DocShareAddMemberListItem and DocShareMemberItem to enhance spacing and button color for better visual consistency. - Improved DocShareInvitationItem and SearchUserRow with new theming and spacing tokens for a more cohesive design. - Adjusted padding and layout in DocShareModal and DocShareModalFooter for improved responsiveness. - Enhanced DocVisibility component with updated padding and text styling for better readability. - Cleaned up unused imports and optimized component structures for maintainability.
This commit is contained in:
committed by
Anthony LC
parent
fc27043e9e
commit
7c696fc1ec
@@ -44,7 +44,7 @@ export function useUpdateDocLink({
|
|||||||
mutationFn: updateDocLink,
|
mutationFn: updateDocLink,
|
||||||
onSuccess: (data, variable) => {
|
onSuccess: (data, variable) => {
|
||||||
listInvalideQueries?.forEach((queryKey) => {
|
listInvalideQueries?.forEach((queryKey) => {
|
||||||
void queryClient.resetQueries({
|
void queryClient.invalidateQueries({
|
||||||
queryKey: [queryKey],
|
queryKey: [queryKey],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -149,11 +149,7 @@ export const DocShareAddMemberList = ({
|
|||||||
currentRole={invitationRole}
|
currentRole={invitationRole}
|
||||||
onSelectRole={setInvitationRole}
|
onSelectRole={setInvitationRole}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button onClick={() => void onInvite()} disabled={isLoading}>
|
||||||
onClick={() => void onInvite()}
|
|
||||||
size="small"
|
|
||||||
disabled={isLoading}
|
|
||||||
>
|
|
||||||
{t('Invite')}
|
{t('Invite')}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -23,20 +23,26 @@ export const DocShareAddMemberListItem = ({ user, onRemoveUser }: Props) => {
|
|||||||
$height="fit-content"
|
$height="fit-content"
|
||||||
$justify="center"
|
$justify="center"
|
||||||
$align="center"
|
$align="center"
|
||||||
$gap={spacing.xs}
|
$gap={spacing['3xs']}
|
||||||
$background={color['greyscale-250']}
|
$background={color['greyscale-250']}
|
||||||
$padding={{ horizontal: spacing['2xs'], vertical: spacing['3xs'] }}
|
$padding={{
|
||||||
|
left: spacing['xs'],
|
||||||
|
right: spacing['4xs'],
|
||||||
|
vertical: spacing['4xs'],
|
||||||
|
}}
|
||||||
$css={css`
|
$css={css`
|
||||||
color: ${color['greyscale-1000']};
|
color: ${color['greyscale-1000']};
|
||||||
font-size: ${fontSize['xs']};
|
font-size: ${fontSize['xs']};
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<Text $margin={{ top: '-3px' }}>{user.full_name || user.email}</Text>
|
<Text $variation="1000" $size="xs">
|
||||||
|
{user.full_name || user.email}
|
||||||
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
color="primary-text"
|
color="tertiary-text"
|
||||||
size="nano"
|
size="nano"
|
||||||
onClick={() => onRemoveUser?.(user)}
|
onClick={() => onRemoveUser?.(user)}
|
||||||
icon={<Icon $variation="500" $size="sm" iconName="close" />}
|
icon={<Icon $variation="600" $size="sm" iconName="close" />}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
IconOptions,
|
IconOptions,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { User } from '@/core';
|
import { User } from '@/core';
|
||||||
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
import { Doc, Role } from '@/features/docs/doc-management';
|
import { Doc, Role } from '@/features/docs/doc-management';
|
||||||
import {
|
import {
|
||||||
useDeleteDocInvitation,
|
useDeleteDocInvitation,
|
||||||
@@ -24,6 +25,8 @@ type Props = {
|
|||||||
};
|
};
|
||||||
export const DocShareInvitationItem = ({ doc, invitation }: Props) => {
|
export const DocShareInvitationItem = ({ doc, invitation }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { spacingsTokens } = useCunninghamTheme();
|
||||||
|
const spacing = spacingsTokens();
|
||||||
const fakeUser: User = {
|
const fakeUser: User = {
|
||||||
id: invitation.email,
|
id: invitation.email,
|
||||||
full_name: invitation.email,
|
full_name: invitation.email,
|
||||||
@@ -84,10 +87,11 @@ export const DocShareInvitationItem = ({ doc, invitation }: Props) => {
|
|||||||
data-testid={`doc-share-invitation-row-${invitation.email}`}
|
data-testid={`doc-share-invitation-row-${invitation.email}`}
|
||||||
>
|
>
|
||||||
<SearchUserRow
|
<SearchUserRow
|
||||||
|
isInvitation={true}
|
||||||
alwaysShowRight={true}
|
alwaysShowRight={true}
|
||||||
user={fakeUser}
|
user={fakeUser}
|
||||||
right={
|
right={
|
||||||
<Box $direction="row" $align="center">
|
<Box $direction="row" $align="center" $gap={spacing['2xs']}>
|
||||||
<DocRoleDropdown
|
<DocRoleDropdown
|
||||||
currentRole={invitation.role}
|
currentRole={invitation.role}
|
||||||
onSelectRole={onUpdate}
|
onSelectRole={onUpdate}
|
||||||
@@ -99,7 +103,7 @@ export const DocShareInvitationItem = ({ doc, invitation }: Props) => {
|
|||||||
data-testid="doc-share-invitation-more-actions"
|
data-testid="doc-share-invitation-more-actions"
|
||||||
options={moreActions}
|
options={moreActions}
|
||||||
>
|
>
|
||||||
<IconOptions $variation="600" />
|
<IconOptions isHorizontal $variation="600" />
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
DropdownMenuOption,
|
DropdownMenuOption,
|
||||||
IconOptions,
|
IconOptions,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
import { SearchUserRow } from '@/features/docs/doc-share/component/SearchUserRow';
|
import { SearchUserRow } from '@/features/docs/doc-share/component/SearchUserRow';
|
||||||
import { useWhoAmI } from '@/features/docs/doc-share/hooks/useWhoAmI';
|
import { useWhoAmI } from '@/features/docs/doc-share/hooks/useWhoAmI';
|
||||||
import { useResponsiveStore } from '@/stores';
|
import { useResponsiveStore } from '@/stores';
|
||||||
@@ -25,6 +26,8 @@ export const DocShareMemberItem = ({ doc, access }: Props) => {
|
|||||||
const { isLastOwner, isOtherOwner } = useWhoAmI(access);
|
const { isLastOwner, isOtherOwner } = useWhoAmI(access);
|
||||||
const { toast } = useToastProvider();
|
const { toast } = useToastProvider();
|
||||||
const { isDesktop } = useResponsiveStore();
|
const { isDesktop } = useResponsiveStore();
|
||||||
|
const { spacingsTokens } = useCunninghamTheme();
|
||||||
|
const spacing = spacingsTokens();
|
||||||
const isNotAllowed =
|
const isNotAllowed =
|
||||||
isOtherOwner || !!isLastOwner || !doc.abilities.accesses_manage;
|
isOtherOwner || !!isLastOwner || !doc.abilities.accesses_manage;
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@ export const DocShareMemberItem = ({ doc, access }: Props) => {
|
|||||||
alwaysShowRight={true}
|
alwaysShowRight={true}
|
||||||
user={access.user}
|
user={access.user}
|
||||||
right={
|
right={
|
||||||
<Box $direction="row" $align="center">
|
<Box $direction="row" $align="center" $gap={spacing['2xs']}>
|
||||||
<DocRoleDropdown
|
<DocRoleDropdown
|
||||||
currentRole={access.role}
|
currentRole={access.role}
|
||||||
onSelectRole={onUpdate}
|
onSelectRole={onUpdate}
|
||||||
@@ -86,6 +89,7 @@ export const DocShareMemberItem = ({ doc, access }: Props) => {
|
|||||||
{isDesktop && doc.abilities.accesses_manage && (
|
{isDesktop && doc.abilities.accesses_manage && (
|
||||||
<DropdownMenu options={moreActions}>
|
<DropdownMenu options={moreActions}>
|
||||||
<IconOptions
|
<IconOptions
|
||||||
|
isHorizontal
|
||||||
data-testid="doc-share-member-more-actions"
|
data-testid="doc-share-member-more-actions"
|
||||||
$variation="600"
|
$variation="600"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -171,15 +171,12 @@ export const DocShareModal = ({ doc, onClose }: Props) => {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
height: ${isDesktop
|
height: ${isDesktop
|
||||||
? '400px'
|
? '400px'
|
||||||
: 'calc(100vh - 49px - 68px - 237px)'};
|
: 'calc(100vh - 49px - 68px - 229px)'};
|
||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{canShare && selectedUsers.length > 0 && (
|
{canShare && selectedUsers.length > 0 && (
|
||||||
<Box
|
<Box $padding={{ horizontal: 'base' }} $margin={{ top: '11px' }}>
|
||||||
$padding={{ horizontal: 'base' }}
|
|
||||||
$margin={{ vertical: '11px' }}
|
|
||||||
>
|
|
||||||
<DocShareAddMemberList
|
<DocShareAddMemberList
|
||||||
doc={doc}
|
doc={doc}
|
||||||
selectedUsers={selectedUsers}
|
selectedUsers={selectedUsers}
|
||||||
|
|||||||
@@ -27,14 +27,18 @@ export const DocShareModalFooter = ({ doc, onClose }: Props) => {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<HorizontalSeparator />
|
<HorizontalSeparator $withPadding={true} />
|
||||||
{canShare && (
|
{canShare && (
|
||||||
<>
|
<>
|
||||||
<DocVisibility doc={doc} />
|
<DocVisibility doc={doc} />
|
||||||
<HorizontalSeparator />
|
<HorizontalSeparator />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Box $direction="row" $justify="space-between" $padding="base">
|
<Box
|
||||||
|
$direction="row"
|
||||||
|
$justify="space-between"
|
||||||
|
$padding={{ horizontal: 'base', bottom: 'base' }}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
fullWidth={false}
|
fullWidth={false}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -86,11 +86,11 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
$padding={{ horizontal: isDesktop ? 'base' : 'sm' }}
|
$padding={{ horizontal: 'base' }}
|
||||||
aria-label={t('Doc visibility card')}
|
aria-label={t('Doc visibility card')}
|
||||||
$gap={spacing['base']}
|
$gap={spacing['base']}
|
||||||
>
|
>
|
||||||
<Text $weight="700" $variation="1000">
|
<Text $weight="700" $size="sm" $variation="700">
|
||||||
{t('Link parameters')}
|
{t('Link parameters')}
|
||||||
</Text>
|
</Text>
|
||||||
<Box
|
<Box
|
||||||
@@ -104,6 +104,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
|
|||||||
<Box
|
<Box
|
||||||
$direction="row"
|
$direction="row"
|
||||||
$align={isDesktop ? 'center' : undefined}
|
$align={isDesktop ? 'center' : undefined}
|
||||||
|
$padding={{ horizontal: '2xs' }}
|
||||||
$gap={spacing['3xs']}
|
$gap={spacing['3xs']}
|
||||||
>
|
>
|
||||||
<DropdownMenu
|
<DropdownMenu
|
||||||
|
|||||||
@@ -12,30 +12,36 @@ type Props = {
|
|||||||
user: User;
|
user: User;
|
||||||
alwaysShowRight?: boolean;
|
alwaysShowRight?: boolean;
|
||||||
right?: QuickSearchItemContentProps['right'];
|
right?: QuickSearchItemContentProps['right'];
|
||||||
|
isInvitation?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SearchUserRow = ({
|
export const SearchUserRow = ({
|
||||||
user,
|
user,
|
||||||
right,
|
right,
|
||||||
alwaysShowRight = false,
|
alwaysShowRight = false,
|
||||||
|
isInvitation = false,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const hasFullName = user.full_name != null && user.full_name !== '';
|
const hasFullName = user.full_name != null && user.full_name !== '';
|
||||||
const { spacingsTokens } = useCunninghamTheme();
|
const { spacingsTokens, colorsTokens } = useCunninghamTheme();
|
||||||
const spacings = spacingsTokens();
|
const spacings = spacingsTokens();
|
||||||
|
const colors = colorsTokens();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<QuickSearchItemContent
|
<QuickSearchItemContent
|
||||||
right={right}
|
right={right}
|
||||||
alwaysShowRight={alwaysShowRight}
|
alwaysShowRight={alwaysShowRight}
|
||||||
left={
|
left={
|
||||||
<Box $direction="row" $align="center" $gap={spacings['2xs']}>
|
<Box $direction="row" $align="center" $gap={spacings['xs']}>
|
||||||
<UserAvatar user={user} />
|
<UserAvatar
|
||||||
|
user={user}
|
||||||
|
background={isInvitation ? colors['greyscale-400'] : undefined}
|
||||||
|
/>
|
||||||
<Box $direction="column">
|
<Box $direction="column">
|
||||||
<Text $size="sm" $weight="500" $variation="1000">
|
<Text $size="sm" $weight="500" $variation="1000">
|
||||||
{hasFullName ? user.full_name : user.email}
|
{hasFullName ? user.full_name : user.email}
|
||||||
</Text>
|
</Text>
|
||||||
{hasFullName && (
|
{hasFullName && (
|
||||||
<Text $size="xs" $variation="600">
|
<Text $size="xs" $margin={{ top: '-2px' }} $variation="600">
|
||||||
{user.email}
|
{user.email}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user