From b55d3fbd27ad45fd9ee97e6297e653262522fbc6 Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Sun, 21 Apr 2024 22:10:35 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20front:=20Implemented=20?= =?UTF-8?q?user=20display=20logic=20in=20grouped=20rows=20user=20molecule?= =?UTF-8?q?=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grouped-rows/user/index.stories.tsx | 51 ++++++++++--------- .../app/molecules/grouped-rows/user/index.tsx | 41 ++++++++++++--- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/tdrive/frontend/src/app/molecules/grouped-rows/user/index.stories.tsx b/tdrive/frontend/src/app/molecules/grouped-rows/user/index.stories.tsx index 566c0d8ed..b1abfe0ca 100644 --- a/tdrive/frontend/src/app/molecules/grouped-rows/user/index.stories.tsx +++ b/tdrive/frontend/src/app/molecules/grouped-rows/user/index.stories.tsx @@ -1,54 +1,54 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import React from 'react'; import { ComponentStory } from '@storybook/react'; import UserBlock from '.'; -import Avatar from '@atoms/avatar'; import { CheckIcon } from '@atoms/icons-agnostic'; +import type { UserType } from '@features/users/types/user'; export default { title: '@molecules/grouped-rows', }; +const mockUser = (first_name: string, last_name: string, email: string, thumbnail?: string) : UserType => + ({ + username: 'anonymous if this is empty', + first_name, last_name, email, thumbnail, + } as UserType); + const Template: ComponentStory = (props: { - title: string; - subtitle: string; + first_name: string; + last_name: string; + email: string; + thumbnail?: string; + className: string; checked: boolean; }) => { return (
-
+
- } - title="Romaric Mourgues" - subtitle="r.mourgues@linagora.com" + className="p-2" + user={mockUser("Romaric", "Mourgues", "r.mourgues@linagora.com", "https://images.freeimages.com/images/small-previews/d67/experimenting-with-nature-1547377.jpg")} suffix={
} - className="py-2 border-b border-gray-300" - /> - } - title="Diana Potokina" - subtitle="r.potokina@linagora.com" - className="py-2 border-b border-gray-300" /> } - title={props.title} - subtitle={props.subtitle} + className={props.className} + user={mockUser(props.first_name, props.last_name, props.email, props.thumbnail)} suffix={ (props.checked && (
- )) || <> + )) } - className="py-2" + /> +
@@ -57,7 +57,10 @@ const Template: ComponentStory = (props: { export const User = Template.bind({}); User.args = { - title: 'Another user', - subtitle: 'Just a test user', + first_name: 'fred ✏️', + last_name: 'ictitiuS editable', + email: "sampleemail@example.com", + className: "p-2 border-t border-gray-300 dark:border-zinc-600", + thumbnail: "", checked: false, }; diff --git a/tdrive/frontend/src/app/molecules/grouped-rows/user/index.tsx b/tdrive/frontend/src/app/molecules/grouped-rows/user/index.tsx index 38606e4ec..f6512bd25 100644 --- a/tdrive/frontend/src/app/molecules/grouped-rows/user/index.tsx +++ b/tdrive/frontend/src/app/molecules/grouped-rows/user/index.tsx @@ -1,16 +1,43 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import React from 'react'; +import { Base, Info } from '@atoms/text'; +import Avatar from '@atoms/avatar'; import BaseBlock from '@molecules/grouped-rows/base'; +import Languages from '@features/global/services/languages-service'; +import type { UserType } from '@features/users/types/user'; +import { getFullName } from '@features/users/utils/get-full-name'; -// @ts-ignore -interface UserBlockProps extends React.InputHTMLAttributes { - avatar: JSX.Element; - title: JSX.Element | string; - subtitle: JSX.Element | string; - suffix?: JSX.Element | string; +interface UserBlockProps { className?: string; + suffix?: JSX.Element | string | false; + title_suffix?: JSX.Element | string | false; + subtitle_suffix?: JSX.Element | string | false; + user?: UserType; + isSelf?: boolean; } export default function UserBlock(props: UserBlockProps) { - return BaseBlock(props); + return + } + title={ + <> + {!!props.user && getFullName(props.user)} + {props.isSelf && {' ' + Languages.t('components.internal-access_specific_rules_you')}} + + } + subtitle={ +
{props.user?.email || ""}
+ } + /> }