diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/public-link/public-link-access.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/public-link/public-link-access.tsx deleted file mode 100644 index 4b56cc23..00000000 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/public-link/public-link-access.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { Subtitle } from '@atoms/text'; -import { useDriveItem, getPublicLink } from '@features/drive/hooks/use-drive-item'; -import { Input } from 'app/atoms/input/input-text'; -import { useState } from 'react'; -import { AccessLevelDropdown } from '../../components/access-level-dropdown'; -import Languages from 'features/global/services/languages-service'; -import { UserGroupIcon } from '@heroicons/react/outline'; -import type { DriveFileAccessLevelForPublicLink } from 'app/features/drive/types'; -import { changePublicLink } from '@features/files/utils/access-info-helpers'; -import { CopyLinkButton } from './copy-link-button'; - -export const PublicLinkManager = ({ id, disabled }: { id: string; disabled?: boolean }) => { - const { item, loading, update } = useDriveItem(id); - const publicLink = getPublicLink(item); - const defaultPublicLinkLevel = 'read'; - const publicLinkLevel = item?.access_info?.public?.level || 'none'; - const havePublicLink = publicLinkLevel !== 'none'; - const [publicLinkCreationLevel, setPublicLinkCreationLevel] = useState(defaultPublicLinkLevel); - const publicLinkCreationLevelSafe = havePublicLink ? publicLinkLevel || defaultPublicLinkLevel : publicLinkCreationLevel; - const updatePublicLinkLevel = (level: DriveFileAccessLevelForPublicLink) => { - item && update(changePublicLink(item, { level })); - if (level === 'none') - setPublicLinkCreationLevel(defaultPublicLinkLevel); - }; - - return ( - <> -
- - {Languages.t('components.public-link-acess.public_link_access')} - -
-
-
- target.select()} - theme={havePublicLink ? "blue" : "outline"} - value={havePublicLink ? publicLink : Languages.t('components.public-link-acess.public-link-placeholder')} - /> - -
-
-
-
- -
-
- {Languages.t('components.public-link-access-level-' + (havePublicLink ? 'update' : 'create'))} -
-
- { - if (havePublicLink) { - updatePublicLinkLevel(level); - } else { - setPublicLinkCreationLevel(level); - } - }} - /> -
-
-
- - ); -}; diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/cute-depiction-of-folder-hierarchy.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/cute-depiction-of-folder-hierarchy.tsx deleted file mode 100644 index c7c4ff2e..00000000 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/cute-depiction-of-folder-hierarchy.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Base } from '@atoms/text'; -import { FolderIcon } from '@heroicons/react/outline'; -import { DocumentIcon } from '@views/client/body/drive/documents/document-icon'; -import type { DriveItem } from 'app/features/drive/types'; - -export const CuteDepictionOfFolderHierarchy = (props: { - file?: DriveItem, - parent?: DriveItem, -}) => - <> - -
- -
-
- {props.parent?.name} -
- - -
- └ -
-
- -
-
- {props.file?.name} -
- - ; diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx index 091fde1c..86c73c43 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx @@ -1,20 +1,13 @@ -import A from '@atoms/link'; -import { Info } from '@atoms/text'; import { Modal, ModalContent } from '@atoms/modal'; import { useDriveItem } from '@features/drive/hooks/use-drive-item'; -import { useState, useEffect } from 'react'; +import { useEffect } from 'react'; import { atom, useRecoilState } from 'recoil'; import { InternalAccessManager } from './internal-access'; -import { PublicLinkManager } from '../public-link/public-link-access'; import { useCurrentCompany } from '@features/companies/hooks/use-companies'; import Languages from 'features/global/services/languages-service'; import FeatureTogglesService, { FeatureNames, } from '@features/global/services/feature-toggles-service'; -import { ArrowLeftIcon, LockClosedIcon } from '@heroicons/react/outline'; -import { PublicLinkAccessOptions } from '../public-link/public-link-access-options'; -import { CuteDepictionOfFolderHierarchy } from './cute-depiction-of-folder-hierarchy'; -import { InheritAccessOptions } from './inherit-access-options'; import { changePublicLink, hasAnyPublicLinkAccess } from '@features/files/utils/access-info-helpers'; export type AccessModalType = { @@ -32,60 +25,22 @@ export const AccessModalAtom = atom({ export const AccessModal = () => { const [state, setState] = useRecoilState(AccessModalAtom); - const [isOnAdvancedScreen, setIsOnAdvancedScreen] = useState(false); return ( { - if (isOnAdvancedScreen) - setIsOnAdvancedScreen(false); - else - setState({ ...state, open: false }); - }} - closeIcon={isOnAdvancedScreen && } + onClose={() => setState({ ...state, open: false })} > {!!state.id && setIsOnAdvancedScreen(active)} - />} + />} ); }; -const SwitchToAdvancedSettingsPanel = (props: { - disabled: boolean, - onShowAdvancedScreen: (active: boolean) => void, -}) => -
-
- -
-
-
Advanced security settings
-
Set password, expiration date, etc.
-
-
- { - if (!props.disabled) - props.onShowAdvancedScreen(true); - }} - > - Change - -
-
; - const AccessModalContent = (props: { id: string, - isOnAdvancedScreen: boolean, - onShowAdvancedScreen: (active: boolean) => void, }) => { const { id } = props; const { item, access, loading, update, refresh } = useDriveItem(id); @@ -95,25 +50,21 @@ const AccessModalContent = (props: { refresh(id); refreshCompany(); }, []); - const havePublicLink = hasAnyPublicLinkAccess(item); - const haveAdvancedSettings = parentItem?.parent_id !== null || havePublicLink; return ( - {Languages.t(props.isOnAdvancedScreen - ? 'components.item_context_menu.manage_access_advanced_to' - : 'components.item_context_menu.manage_access_to') + ' '} + {Languages.t('components.internal-access_manage_title') + ' '} {item?.name} } > - - - {FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_SEARCH_USERS) && ( - - )} +
+ {FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_SEARCH_USERS) && ( + + )} +
); }; diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/inherit-access-options.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/inherit-access-options.tsx deleted file mode 100644 index eb7589fd..00000000 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/inherit-access-options.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import Languages from 'features/global/services/languages-service'; - -import type { DriveItem } from 'app/features/drive/types'; -import { - changeAllChannelAccessLevels, - changeCompanyAccessLevel, - changeInheritedAccess, - getCompanyAccessLevel, - getFirstChannelAccessLevel, - getInheritedAccessLevel, -} from '@features/files/utils/access-info-helpers'; - -import { Base, Info, Subtitle } from '@atoms/text'; -import { Checkbox } from '@atoms/input/input-checkbox'; -import { AccessLevelDropdown } from '../../components/access-level-dropdown'; -import AlertManager from '@features/global/services/alert-manager-service'; - -export const InheritAccessOptions = (props: { - item?: DriveItem, - disabled: boolean, - onUpdate: (item: Partial) => void, -}) => { - // TODO: The default to 'manage' surprises me but it's what previous code did, as this commit is a refactoring, aim is to not affect function - const folderEntityLevel = getInheritedAccessLevel(props.item) || 'manage'; - const companyEntityLevel = getCompanyAccessLevel(props.item); - const channelEntitiesLevel = getFirstChannelAccessLevel(props.item); - - return ( - <> - {(companyEntityLevel || folderEntityLevel === 'none' || channelEntitiesLevel) && - {Languages.t('components.internal-access_access_manage')}} - - {
-
- {Languages.t('components.internal-access_inherit_parent')} -
- {Languages.t('components.internal-access_inherit_parent_perm')} -
-
- { - props.item && props.onUpdate(changeInheritedAccess(props.item, status ? 'manage' : 'none')); - }} - value={folderEntityLevel === 'manage'} - /> -
-
- } - - { companyEntityLevel && folderEntityLevel === 'none' && ( -
-
- {Languages.t('components.internal-access_company_member')} -
-
- { - props.item && props.onUpdate(changeCompanyAccessLevel(props.item, level === 'remove' ? false : level)); - }} - level={companyEntityLevel} - /> -
-
- )} - - {channelEntitiesLevel && ( -
-
- {Languages.t('components.internal-access_cannal')} -
- - {channelEntitiesLevel.length} {Languages.t('components.internal-access_cannal_info')} - -
-
- { - if (level === 'remove') - AlertManager.confirm( - async () => { - //Remove channel access - props.item && props.onUpdate(changeAllChannelAccessLevels(props.item, false)); - }, - () => { /* Do nothing */ }, - { - text: Languages.t('components.internal-access_cannal_info_give_back'), - }, - ); - else - props.item && props.onUpdate(changeAllChannelAccessLevels(props.item, level)); - }} - level={channelEntitiesLevel} - /> -
-
- )} - - ); -}; -