From 8d42c09b7019f1133bc46c3cda434e0daee6f957 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=F0=9F=92=84=20front:=20Use?= =?UTF-8?q?=20UserBlock=20from=20grouped=20rows=20in=20the=20access=20righ?= =?UTF-8?q?ts=20modal=20(and=20a=20bit=20of=20dark=20mode=20borders)=20(#5?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/app/components/ui/user.jsx | 17 ----- .../body/drive/components/select-users.tsx | 25 +++---- .../modals/update-access/internal-access.tsx | 70 ++++++++----------- .../update-access/public-link-access.tsx | 2 +- 4 files changed, 42 insertions(+), 72 deletions(-) delete mode 100755 tdrive/frontend/src/app/components/ui/user.jsx diff --git a/tdrive/frontend/src/app/components/ui/user.jsx b/tdrive/frontend/src/app/components/ui/user.jsx deleted file mode 100755 index 2dc5802b..00000000 --- a/tdrive/frontend/src/app/components/ui/user.jsx +++ /dev/null @@ -1,17 +0,0 @@ -import React, { Component } from 'react'; -import './elements.scss'; -import UserService from '@features/users/services/current-user-service'; - -export default class User extends React.Component { - render() { - return ( -
-
- {!this.props.mini && UserService.getFullName(this.props.data)} -
- ); - } -} diff --git a/tdrive/frontend/src/app/views/client/body/drive/components/select-users.tsx b/tdrive/frontend/src/app/views/client/body/drive/components/select-users.tsx index d73aad97..b7551640 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/components/select-users.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/components/select-users.tsx @@ -1,7 +1,7 @@ -import React, { useEffect, useRef, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; +import UserBlock from '@molecules/grouped-rows/user'; import { Input } from '@atoms/input/input-text'; import { useSearchUsers } from '@features/users/hooks/use-search-user-list'; -import User from '@components/ui/user'; import { Button } from '@atoms/button/button'; import { UserType } from '@features/users/types/user'; import { InputDecorationIcon } from '@atoms/input/input-decoration-icon'; @@ -99,16 +99,13 @@ export default (props: { )} {shownResults.map((user, i) => { return ( -
0 && i !== (selectedKeyIndex + 1) ? ' border-t' : ''))}> -
-
- -
-
{user.email}
-
-
+ 0 && i !== (selectedKeyIndex + 1) ? ' border-t' : ''))} + suffix={ -
-
+ } + /> ); })} {result.length > maxUserResultsShown && diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/internal-access.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/internal-access.tsx index 612f11a4..e5baf479 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/internal-access.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/internal-access.tsx @@ -1,5 +1,6 @@ import Avatar from '@atoms/avatar'; import { Base, Info } from '@atoms/text'; +import UserBlock from '@molecules/grouped-rows/user'; import { useDriveItem } from '@features/drive/hooks/use-drive-item'; import { DriveFileAccessLevel } from '@features/drive/types'; import { useCurrentUser } from '@features/users/hooks/use-current-user'; @@ -19,7 +20,7 @@ export const InternalAccessManager = ({ id, disabled }: { id: string; disabled: return ( <> {Languages.t('components.internal-access_specific_rules')} -
+
{userEntities @@ -84,48 +85,37 @@ const UserAccessLevel = ({ const { item, loading, update } = useDriveItem(id); const user = useUser(userId); const { user: currentUser } = useCurrentUser(); - const level = - item?.access_info.entities.filter(a => a.type === 'user' && a.id === userId)?.[0]?.level || - 'none'; - + const level = item?.access_info.entities.filter(a => a.type === 'user' && a.id === userId)?.[0]?.level || 'none'; return ( -
-
- -
-
- {!!user && currentUserService.getFullName(user)}{' '} - {user?.id === currentUser?.id && {Languages.t('components.internal-access_specific_rules_you')}} -
-
+ { - update({ - access_info: { - entities: - level === 'remove' - ? item?.access_info?.entities.filter( - e => e.type !== 'user' || e.id !== userId, - ) || [] - : item?.access_info?.entities.map(e => { - if (e.type === 'user' && e.id === userId) { - return { ...e, level }; - } - return e; - }) || [], - public: item?.access_info.public, - }, - }); - }} - /> -
-
+ canRemove={true} + onChange={ + level => + update({ + access_info: { + entities: + level === 'remove' + ? item?.access_info?.entities.filter( + e => e.type !== 'user' || e.id !== userId, + ) || [] + : item?.access_info?.entities.map(e => { + if (e.type === 'user' && e.id === userId) + return { ...e, level }; + return e; + }) || [], + public: item?.access_info.public, + }, + }) + } + /> + } + /> ); }; diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/public-link-access.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/public-link-access.tsx index eb505003..507b69fa 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/public-link-access.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/public-link-access.tsx @@ -35,7 +35,7 @@ export const PublicLinkManager = ({ id, disabled }: { id: string; disabled?: boo {Languages.t('components.public-link-acess.public_link_access')} -
+