-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ front: WIP: Add separate modal for public link (#50 v3)
- Loading branch information
1 parent
1b29a21
commit f23b9da
Showing
6 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
tdrive/frontend/src/app/views/client/body/drive/modals/public-link/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { atom, useRecoilState } from 'recoil'; | ||
import { useState, useEffect } from 'react'; | ||
|
||
import { useDriveItem } from '@features/drive/hooks/use-drive-item'; | ||
import { useCurrentCompany } from '@features/companies/hooks/use-companies'; | ||
import Languages from 'features/global/services/languages-service'; | ||
import { changePublicLink, hasAnyPublicLinkAccess } from '@features/files/utils/access-info-helpers'; | ||
|
||
import { Subtitle } from '@atoms/text'; | ||
import { Modal, ModalContent } from '@atoms/modal'; | ||
|
||
export type PublicLinkModalType = { | ||
open: boolean; | ||
id: string; | ||
}; | ||
|
||
export const PublicLinkModalAtom = atom<PublicLinkModalType>({ | ||
key: 'PublicLinkModalType', | ||
default: { | ||
open: false, | ||
id: '', | ||
}, | ||
}); | ||
|
||
export const PublicLinkModal = () => { | ||
const [state, setState] = useRecoilState(PublicLinkModalAtom); | ||
const [isOnAdvancedScreen, setIsOnAdvancedScreen] = useState(false); | ||
|
||
return ( | ||
<Modal | ||
open={state.open} | ||
onClose={() => { | ||
setState({ ...state, open: false }); | ||
}} | ||
> | ||
{!!state.id && | ||
<PublicLinkModalContent | ||
id={state.id} | ||
isOnAdvancedScreen={isOnAdvancedScreen} | ||
onShowAdvancedScreen={(active) => setIsOnAdvancedScreen(active)} | ||
/>} | ||
</Modal> | ||
); | ||
}; | ||
|
||
const PublicLinkModalContent = (props: { | ||
id: string, | ||
isOnAdvancedScreen: boolean, | ||
onShowAdvancedScreen: (active: boolean) => void, | ||
}) => { | ||
const { id } = props; | ||
const { item, access, loading, update, refresh } = useDriveItem(id); | ||
const { item: parentItem } = useDriveItem(item?.parent_id || ''); | ||
const { company, refresh: refreshCompany } = useCurrentCompany(); | ||
useEffect(() => { | ||
refresh(id); | ||
refreshCompany(); | ||
}, []); | ||
const havePublicLink = hasAnyPublicLinkAccess(item); | ||
|
||
return ( | ||
<ModalContent | ||
title={ | ||
<> | ||
{Languages.t(props.isOnAdvancedScreen | ||
? 'components.item_context_menu.manage_access_advanced_to' | ||
: 'components.item_context_menu.manage_access_to') + ' '} | ||
<strong>{item?.name}</strong> | ||
</> | ||
} | ||
> | ||
<Subtitle>Im content ! {havePublicLink ? "Got a" : "No"} public link.</Subtitle> | ||
</ModalContent> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters