-
Notifications
You must be signed in to change notification settings - Fork 301
🛂(frontend) block edition to not connected users #945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
113 changes: 113 additions & 0 deletions
113
src/frontend/apps/impress/src/features/docs/doc-header/components/AlertNetwork.tsx
This file contains hidden or 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,113 @@ | ||
import { Button, Modal, ModalSize } from '@openfun/cunningham-react'; | ||
import { t } from 'i18next'; | ||
import { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { css } from 'styled-components'; | ||
|
||
import { Box, BoxButton, Icon, Text } from '@/components'; | ||
import { useCunninghamTheme } from '@/cunningham'; | ||
|
||
export const AlertNetwork = () => { | ||
const { t } = useTranslation(); | ||
const { colorsTokens, spacingsTokens } = useCunninghamTheme(); | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<Box> | ||
<Box | ||
$direction="row" | ||
$justify="space-between" | ||
$width="100%" | ||
$background={colorsTokens['warning-100']} | ||
$radius={spacingsTokens['3xs']} | ||
$padding="xs" | ||
$flex={1} | ||
$align="center" | ||
$gap={spacingsTokens['3xs']} | ||
$css={css` | ||
border: 1px solid var(--c--theme--colors--warning-300); | ||
`} | ||
> | ||
<Box $direction="row" $gap={spacingsTokens['2xs']}> | ||
<Icon iconName="mobiledata_off" $theme="warning" $variation="600" /> | ||
<Text $theme="warning" $variation="600" $weight={500}> | ||
{t('Your network do not allow you to edit')} | ||
</Text> | ||
</Box> | ||
<BoxButton | ||
$direction="row" | ||
$gap={spacingsTokens['3xs']} | ||
$align="center" | ||
onClick={() => setIsModalOpen(true)} | ||
> | ||
<Icon | ||
iconName="info" | ||
$theme="warning" | ||
$variation="600" | ||
$size="16px" | ||
$weight="500" | ||
$margin={{ top: 'auto' }} | ||
/> | ||
<Text $theme="warning" $variation="600" $weight="500" $size="xs"> | ||
{t('Know more')} | ||
</Text> | ||
</BoxButton> | ||
</Box> | ||
</Box> | ||
{isModalOpen && ( | ||
<AlertNetworkModal onClose={() => setIsModalOpen(false)} /> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
interface AlertNetworkModalProps { | ||
onClose: () => void; | ||
} | ||
|
||
export const AlertNetworkModal = ({ onClose }: AlertNetworkModalProps) => { | ||
return ( | ||
<Modal | ||
isOpen | ||
closeOnClickOutside | ||
onClose={() => onClose()} | ||
rightActions={ | ||
<> | ||
<Button aria-label={t('OK')} onClick={onClose}> | ||
{t('OK')} | ||
</Button> | ||
</> | ||
} | ||
size={ModalSize.MEDIUM} | ||
title={ | ||
<Text | ||
$size="h6" | ||
as="h6" | ||
$margin={{ all: '0' }} | ||
$align="flex-start" | ||
$variation="1000" | ||
> | ||
{t("Why can't I edit?")} | ||
</Text> | ||
} | ||
> | ||
<Box | ||
aria-label={t('Content modal to explain why the user cannot edit')} | ||
className="--docs--modal-alert-network" | ||
$margin={{ top: 'xs' }} | ||
> | ||
<Text $size="sm" $variation="600"> | ||
{t( | ||
'The network configuration of your workstation or internet connection does not allow editing shared documents.', | ||
)} | ||
</Text> | ||
<Text $size="sm" $variation="600" $margin={{ top: 'xs' }}> | ||
{t( | ||
'Docs use WebSockets to enable real-time editing. These communication channels allow instant and bidirectional exchanges between your browser and our servers. To access collaborative editing, please contact your IT department to enable WebSockets.', | ||
)} | ||
</Text> | ||
</Box> | ||
</Modal> | ||
); | ||
}; |
39 changes: 39 additions & 0 deletions
39
src/frontend/apps/impress/src/features/docs/doc-header/components/AlertPublic.tsx
This file contains hidden or 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,39 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
import { css } from 'styled-components'; | ||
|
||
import { Box, Icon, Text } from '@/components'; | ||
import { useCunninghamTheme } from '@/cunningham'; | ||
|
||
export const AlertPublic = ({ isPublicDoc }: { isPublicDoc: boolean }) => { | ||
const { t } = useTranslation(); | ||
const { colorsTokens, spacingsTokens } = useCunninghamTheme(); | ||
|
||
return ( | ||
<Box | ||
aria-label={t('Public document')} | ||
$color={colorsTokens['primary-800']} | ||
$background={colorsTokens['primary-050']} | ||
$radius={spacingsTokens['3xs']} | ||
$direction="row" | ||
$padding="xs" | ||
$flex={1} | ||
$align="center" | ||
$gap={spacingsTokens['3xs']} | ||
$css={css` | ||
border: 1px solid var(--c--theme--colors--primary-300, #e3e3fd); | ||
`} | ||
> | ||
<Icon | ||
$theme="primary" | ||
$variation="800" | ||
data-testid="public-icon" | ||
iconName={isPublicDoc ? 'public' : 'vpn_lock'} | ||
/> | ||
<Text $theme="primary" $variation="800" $weight="500"> | ||
{isPublicDoc | ||
? t('Public document') | ||
: t('Document accessible to any connected person')} | ||
</Text> | ||
</Box> | ||
); | ||
}; |
This file contains hidden or 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
3 changes: 2 additions & 1 deletion
3
src/frontend/apps/impress/src/features/docs/doc-management/hooks/index.ts
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './useCollaboration'; | ||
export * from './useTrans'; | ||
export * from './useCopyDocLink'; | ||
export * from './useIsCollaborativeEditable'; | ||
export * from './useTrans'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.