-
Notifications
You must be signed in to change notification settings - Fork 824
feat: add new setting for encrypted PDFs size limit for previews #3329
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
Open
nazabucciarelli
wants to merge
4
commits into
master
Choose a base branch
from
add-blob-allowed-protocol
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+140
−6
Open
Changes from all commits
Commits
Show all changes
4 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const DEFAULT_E2E_PDF_PREVIEW_SIZE_LIMIT_MB = 10; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { DEFAULT_E2E_PDF_PREVIEW_SIZE_LIMIT_MB } from '../../constants'; | ||
| import { safeSelect } from '../../store'; | ||
|
|
||
| export const getE2ePdfPreviewSizeLimit = (): number => | ||
| safeSelect(({ e2ePdfPreviewSizeLimit }) => e2ePdfPreviewSizeLimit) ?? | ||
| DEFAULT_E2E_PDF_PREVIEW_SIZE_LIMIT_MB; |
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
74 changes: 74 additions & 0 deletions
74
src/ui/components/SettingsView/features/E2ePdfPreviewSizeLimit.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,74 @@ | ||
| import { | ||
| Field, | ||
| FieldLabel, | ||
| FieldHint, | ||
| InputBox, | ||
| Box, | ||
| } from '@rocket.chat/fuselage'; | ||
| import type { ChangeEvent } from 'react'; | ||
| import { useCallback, useId } from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { useDispatch, useSelector } from 'react-redux'; | ||
| import type { Dispatch } from 'redux'; | ||
|
|
||
| import type { RootAction } from '../../../../store/actions'; | ||
| import type { RootState } from '../../../../store/rootReducer'; | ||
| import { SETTINGS_SET_E2E_PDF_PREVIEW_SIZE_LIMIT_CHANGED } from '../../../actions'; | ||
|
|
||
| type E2ePdfPreviewSizeLimitProps = { | ||
| className?: string; | ||
| }; | ||
|
|
||
| export const E2ePdfPreviewSizeLimit = (props: E2ePdfPreviewSizeLimitProps) => { | ||
| const e2ePdfPreviewSizeLimit = useSelector( | ||
| ({ e2ePdfPreviewSizeLimit }: RootState) => e2ePdfPreviewSizeLimit | ||
| ); | ||
| const dispatch = useDispatch<Dispatch<RootAction>>(); | ||
| const { t } = useTranslation(); | ||
|
|
||
| const handleChange = useCallback( | ||
| (event: ChangeEvent<HTMLInputElement>) => { | ||
| const value = parseInt(event.currentTarget.value, 10); | ||
| if (!isNaN(value) && value > 0) { | ||
| dispatch({ | ||
| type: SETTINGS_SET_E2E_PDF_PREVIEW_SIZE_LIMIT_CHANGED, | ||
| payload: value, | ||
| }); | ||
| } | ||
| }, | ||
| [dispatch] | ||
| ); | ||
|
|
||
| const id = useId(); | ||
|
|
||
| return ( | ||
| <Field className={props.className} marginBlock='x16'> | ||
| <Box | ||
| display='flex' | ||
| flexDirection='row' | ||
| justifyContent='space-between' | ||
| alignItems='flex-start' | ||
| > | ||
| <Box display='flex' flexDirection='column'> | ||
| <FieldLabel htmlFor={id}> | ||
| {t('settings.options.e2ePdfPreviewSizeLimit.title')} | ||
| </FieldLabel> | ||
| <FieldHint> | ||
| {t('settings.options.e2ePdfPreviewSizeLimit.description')} | ||
| </FieldHint> | ||
| </Box> | ||
| <Box display='flex' alignItems='center' style={{ paddingTop: '4px' }}> | ||
| <InputBox | ||
| id={id} | ||
| type='number' | ||
| min={1} | ||
| step={1} | ||
| value={e2ePdfPreviewSizeLimit} | ||
| onChange={handleChange} | ||
| style={{ maxWidth: '5rem' }} | ||
| /> | ||
|
nazabucciarelli marked this conversation as resolved.
|
||
| </Box> | ||
| </Box> | ||
| </Field> | ||
| ); | ||
| }; | ||
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,21 @@ | ||
| import type { Reducer } from 'redux'; | ||
|
|
||
| import { APP_SETTINGS_LOADED } from '../../app/actions'; | ||
| import { DEFAULT_E2E_PDF_PREVIEW_SIZE_LIMIT_MB } from '../../constants'; | ||
| import type { ActionOf } from '../../store/actions'; | ||
| import { SETTINGS_SET_E2E_PDF_PREVIEW_SIZE_LIMIT_CHANGED } from '../actions'; | ||
|
|
||
| export const e2ePdfPreviewSizeLimit: Reducer< | ||
| number, | ||
| | ActionOf<typeof SETTINGS_SET_E2E_PDF_PREVIEW_SIZE_LIMIT_CHANGED> | ||
| | ActionOf<typeof APP_SETTINGS_LOADED> | ||
| > = (state = DEFAULT_E2E_PDF_PREVIEW_SIZE_LIMIT_MB, action) => { | ||
| switch (action.type) { | ||
| case APP_SETTINGS_LOADED: | ||
| return action.payload.e2ePdfPreviewSizeLimit ?? state; | ||
| case SETTINGS_SET_E2E_PDF_PREVIEW_SIZE_LIMIT_CHANGED: | ||
| return action.payload; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| default: | ||
| return state; | ||
| } | ||
| }; | ||
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.