feat: add graphics full tab business logic (MIN-165)
Closes MIN-165
Objective:
Implement export graphics tab business logic
What has been done:
- CheckboxFilter handle radio type
- ImageFormat component
- ImageSize component
- graphics download handler
- unit tests for all above
Merge request reports
Activity
assigned to @AdrianOrlow
added 18 commits
-
cbc2243d...459df684 - 17 commits from branch
development
- 834e532a - feat: merge changes
-
cbc2243d...459df684 - 17 commits from branch
1 import { ZERO } from '@/constants/common'; 2 import { useAppSelector } from '@/redux/hooks/useAppSelector'; 3 import { loadingModelsSelector, modelsDataSelector } from '@/redux/models/models.selectors'; 4 import { useContext } from 'react'; 5 import { CheckboxFilter } from '../../CheckboxFilter'; 6 import { CollapsibleSection } from '../../CollapsibleSection'; 7 import { ExportContext } from '../ExportCompound.context'; 8 9 export const Submap = (): React.ReactNode => { 10 const { setModels, data } = useContext(ExportContext); 11 const currentModels = data.models; changed this line in version 4 of the diff
1 /* eslint-disable react/no-multi-comp */ I understand your intention of unit testing hooks (because of pair programming) - thats why this helper exist. I'm still not huge fan of writing big utilities to allow us to test single function cuz it all could be covered in component tests. Approach to testing like this could be part of team discussion in the future - I see it as opportunity to learn.
10 export const getGraphicsDownloadUrl = ({ 11 backgroundId, 12 modelId, 13 handler, 14 zoom, 15 }: GetGraphicsDownloadUrlProps): string | undefined => { 16 const isAllElementsTruthy = [backgroundId, modelId, handler, zoom].reduce( 17 (a, b) => Boolean(a) && Boolean(b), 18 true, 19 ); 20 21 if (!isAllElementsTruthy) { 22 return undefined; 23 } 24 25 return `${BASE_API_URL}/projects/${PROJECT_ID}/models/${modelId}:downloadImage?backgroundOverlayId=${backgroundId}&handlerClass=${handler}&zoomLevel=${zoom}`; 1 import { ZERO } from '@/constants/common'; 2 import { MapModel } from '@/types/models'; 3 4 const ZOOM_BASE = 6; 5 6 export const getModelExportZoom = (exportWidth: number, model?: MapModel): number => { 1 import { Export } from '../ExportCompound'; Every element is needed, so if any is lacking, data fetch will simply not start
export const getGraphicsDownloadUrl = ({ backgroundId, modelId, handler, zoom, }: GetGraphicsDownloadUrlProps): string | undefined => { const isAllElementsTruthy = [backgroundId, modelId, handler, zoom].reduce( (a, b) => Boolean(a) && Boolean(b), true, );
89 92 }, 90 93 ); 91 94 95 export const imageFormatsSelector = createSelector( 96 configurationMainSelector, 97 state => state?.imageFormats, 98 ); 99 100 export const imageFormatsEntriesSelector = createSelector( 101 imageFormatsSelector, 102 (modelFormats): Record<string, ConfigurationFormatSchema> => { 103 return Object.fromEntries( 104 (modelFormats || []) 105 .flat() 106 .filter((format: ConfigurationFormatSchema): format is ConfigurationFormatSchema => changed this line in version 4 of the diff
91 94 95 export const imageFormatsSelector = createSelector( 96 configurationMainSelector, 97 state => state?.imageFormats, 98 ); 99 100 export const imageFormatsEntriesSelector = createSelector( 101 imageFormatsSelector, 102 (modelFormats): Record<string, ConfigurationFormatSchema> => { 103 return Object.fromEntries( 104 (modelFormats || []) 105 .flat() 106 .filter((format: ConfigurationFormatSchema): format is ConfigurationFormatSchema => 107 Boolean(format), 108 ) 109 .map((format: ConfigurationFormatSchema) => [format.name, format]), changed this line in version 4 of the diff
- src/utils/number/numberToInt.ts 0 → 100644
1 import { ZERO } from '@/constants/common'; 2 3 export const numberToInt = (num: number): number => { changed this line in version 4 of the diff
I noticed one more thing. I would add margin at the bottom to add some space just bellow download button. It could look a bit better to the user
Edited by Tadeusz Miesiącmentioned in commit 29618c1f