Skip to content

Commit 53408d6

Browse files
bugfixes(fe): adjust query examples styles (#1583)
1 parent 60f2747 commit 53408d6

File tree

9 files changed

+113
-91
lines changed

9 files changed

+113
-91
lines changed

odd-platform-ui/src/components/DataModelling/QueryExampleSearchResults/QueryExamplesList.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useMemo } from 'react';
33
import { useSearchQueryExamples } from 'lib/hooks/api/dataModelling/searchQueryExamples';
44
import {
55
EmptyContentPlaceholder,
6+
QueryExamplesListHeader,
67
QueryExamplesListItem,
78
QueryExamplesSkeleton,
89
ScrollableContainer,
@@ -29,22 +30,25 @@ const QueryExamplesList = () => {
2930
);
3031

3132
return (
32-
<ScrollableContainer container id='query-examples-list' $offsetY={165}>
33-
<InfiniteScroll
34-
dataLength={queryExamples.length}
35-
next={fetchNextPage}
36-
hasMore={hasNextPage}
37-
loader={<QueryExamplesSkeleton />}
38-
scrollThreshold='200px'
39-
scrollableTarget='query-examples-list'
40-
>
41-
{queryExamples.map(qe => (
42-
<QueryExamplesListItem queryExample={qe} key={qe.definition} />
43-
))}
44-
{isLoading && <QueryExamplesSkeleton />}
45-
{isEmpty && <EmptyContentPlaceholder offsetTop={215} />}
46-
</InfiniteScroll>
47-
</ScrollableContainer>
33+
<>
34+
<QueryExamplesListHeader />
35+
<ScrollableContainer container id='query-examples-list' $offsetY={165}>
36+
<InfiniteScroll
37+
dataLength={queryExamples.length}
38+
next={fetchNextPage}
39+
hasMore={hasNextPage}
40+
loader={<QueryExamplesSkeleton />}
41+
scrollThreshold='200px'
42+
scrollableTarget='query-examples-list'
43+
>
44+
{queryExamples.map(qe => (
45+
<QueryExamplesListItem queryExample={qe} key={qe.definition} />
46+
))}
47+
{isLoading && <QueryExamplesSkeleton />}
48+
{isEmpty && <EmptyContentPlaceholder offsetTop={215} />}
49+
</InfiniteScroll>
50+
</ScrollableContainer>
51+
</>
4852
);
4953
};
5054

odd-platform-ui/src/components/DataModelling/QueryExamples.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { WithPermissions } from 'components/shared/contexts';
88
import { Permission } from 'generated-sources';
99
import QueryExamplesList from './QueryExampleSearchResults/QueryExamplesList';
1010
import DataModellingTabs from './DataModellingTabs';
11-
import QueryExamplesListHeader from '../shared/elements/QueryExamples/QueryExamplesListHeader';
1211
import QueryExampleForm from './QueryExampleForm/QueryExampleForm';
1312

1413
const QueryExamples: React.FC = () => {
@@ -50,7 +49,6 @@ const QueryExamples: React.FC = () => {
5049
<DataModellingTabs />
5150
</Grid>
5251
<Grid item xs={12}>
53-
<QueryExamplesListHeader />
5452
<QueryExamplesList />
5553
</Grid>
5654
</Grid>

odd-platform-ui/src/components/shared/elements/AppDateRangePicker/AppDateRangePicker.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { useCallback, useEffect, useRef, useState } from 'react';
22
import { addDays, endOfDay, startOfDay } from 'date-fns';
3-
import DatePicker, { type DateObject } from 'react-multi-date-picker';
43
import AppDateRangePickerFooter from 'components/shared/elements/AppDateRangePicker/AppDateRangePickerFooter/AppDateRangePickerFooter';
54
import * as S from 'components/shared/elements/AppDateRangePicker/AppDateRangePickerStyles';
5+
import DatePicker, { type DateObject } from 'react-multi-date-picker';
66

77
interface AppDateRangePickerProps {
88
defaultRange: { beginDate: Date; endDate: Date };
@@ -93,7 +93,6 @@ const AppDateRangePicker: React.FC<AppDateRangePickerProps> = ({
9393
portal
9494
arrow={false}
9595
showOtherDays
96-
multiple
9796
offsetY={4}
9897
numberOfMonths={2}
9998
mapDays={disableSelectedDate}

odd-platform-ui/src/components/shared/elements/QueryExamples/QueryExamplesListHeader.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const QueryExamplesListHeader = () => {
88

99
return (
1010
<Table.HeaderContainer>
11+
<Table.Cell $flex='1 0 1'>
12+
<Typography variant='caption'>#</Typography>
13+
</Table.Cell>
1114
<Table.Cell $flex='1 0 25%'>
1215
<Typography variant='caption'>{t('Definition')}</Typography>
1316
</Table.Cell>
Lines changed: 40 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import React from 'react';
22
import type { QueryExample } from 'generated-sources';
33
import { Permission } from 'generated-sources';
4-
import Button from 'components/shared/elements/Button/Button';
5-
import { PreviewIcon, UnlinkIcon } from 'components/shared/icons';
64
import { WithPermissions } from 'components/shared/contexts';
7-
import ConfirmationDialog from 'components/shared/elements/ConfirmationDialog/ConfirmationDialog';
8-
import { useTranslation } from 'react-i18next';
9-
import { useUnassignEntityQueryExample } from 'lib/hooks/api/dataModelling/queryExamples';
105
import { queryExamplesPath } from 'routes';
6+
import { Typography } from '@mui/material';
7+
import { Link } from 'react-router-dom';
118
import TruncatedCell from '../TruncatedCell/TruncatedCell';
129
import Markdown from '../Markdown/Markdown';
1310
import CollapsibleInfoContainer from '../CollapsibleInfoContainer/CollapsibleInfoContainer';
1411
import * as Table from '../StyledComponents/Table';
12+
import QueryExamplesUnlinkButton from './QueryExamplesUnlinkButton';
1513

1614
interface QueryExampleSearchResultsItemProps {
1715
queryExample: QueryExample;
@@ -21,63 +19,43 @@ interface QueryExampleSearchResultsItemProps {
2119
const QueryExamplesListItem = ({
2220
queryExample,
2321
dataEntityId,
24-
}: QueryExampleSearchResultsItemProps) => {
25-
const { t } = useTranslation();
26-
const { mutateAsync } = useUnassignEntityQueryExample();
27-
28-
return (
29-
<Table.RowContainer>
30-
<Table.Cell $flex='1 0 25%'>
31-
<CollapsibleInfoContainer
32-
style={{ border: 'none' }}
33-
initialMaxHeight={96}
34-
content={<Markdown value={queryExample.definition} disableCopy />}
35-
/>
36-
</Table.Cell>
37-
<Table.Cell $flex='1 0 25%'>
38-
<CollapsibleInfoContainer
39-
style={{ border: 'none' }}
40-
initialMaxHeight={96}
41-
content={<Markdown value={queryExample.query} disableCopy />}
42-
/>
43-
</Table.Cell>
44-
<Table.Cell $flex='1 0'>
45-
<TruncatedCell dataList={queryExample.linkedEntities} externalEntityId={1} />
46-
</Table.Cell>
47-
<Table.HiddenCell $flex='0 0 15%' $justifyContent='right'>
48-
<Button
49-
buttonType='linkGray-m-icon'
50-
sx={{ marginRight: 1 }}
51-
icon={<PreviewIcon />}
52-
to={queryExamplesPath(queryExample.id)}
53-
/>
54-
<WithPermissions permissionTo={Permission.QUERY_EXAMPLE_DATASET_DELETE}>
55-
<ConfirmationDialog
56-
actionTitle={t('Are you sure you want to unlink this query example?')}
57-
actionName={t('Unlink')}
58-
actionText={
59-
<>
60-
Query example #{queryExample.id} {t('will be unlinked')}.
61-
</>
62-
}
63-
onConfirm={() =>
64-
mutateAsync({
65-
exampleId: queryExample.id,
66-
dataEntityId: dataEntityId ?? 0,
67-
})
68-
}
69-
actionBtn={
70-
<Button
71-
buttonType='linkGray-m-icon'
72-
icon={<UnlinkIcon />}
73-
sx={{ marginRight: 1 }}
74-
/>
75-
}
22+
}: QueryExampleSearchResultsItemProps) => (
23+
<Table.RowContainer>
24+
<Table.Cell $flex='1 0 1'>
25+
<Link to={queryExamplesPath(queryExample.id)}>
26+
<Typography variant='caption' color='button.link.normal.color' fontWeight={500}>
27+
{queryExample.id}
28+
</Typography>
29+
</Link>
30+
</Table.Cell>
31+
<Table.Cell $flex='1 0 25%'>
32+
<CollapsibleInfoContainer
33+
style={{ border: 'none' }}
34+
initialMaxHeight={96}
35+
content={<Markdown value={queryExample.definition} disableCopy />}
36+
/>
37+
</Table.Cell>
38+
<Table.Cell $flex='1 0 25%'>
39+
<CollapsibleInfoContainer
40+
style={{ border: 'none' }}
41+
initialMaxHeight={96}
42+
content={<Markdown value={queryExample.query} disableCopy />}
43+
/>
44+
</Table.Cell>
45+
<Table.Cell $flex='1 0'>
46+
<TruncatedCell dataList={queryExample.linkedEntities} externalEntityId={1} />
47+
</Table.Cell>
48+
<Table.HiddenCell $flex='0 0 15%' $justifyContent='right'>
49+
<WithPermissions permissionTo={Permission.QUERY_EXAMPLE_DATASET_DELETE}>
50+
{dataEntityId && (
51+
<QueryExamplesUnlinkButton
52+
queryExampleId={queryExample.id}
53+
dataEntityId={dataEntityId}
7654
/>
77-
</WithPermissions>
78-
</Table.HiddenCell>
79-
</Table.RowContainer>
80-
);
81-
};
55+
)}
56+
</WithPermissions>
57+
</Table.HiddenCell>
58+
</Table.RowContainer>
59+
);
8260

8361
export default QueryExamplesListItem;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import type { DataEntity, QueryExample } from 'generated-sources';
4+
import { useUnassignEntityQueryExample } from 'lib/hooks/api/dataModelling/queryExamples';
5+
import Button from '../Button/Button';
6+
import { UnlinkIcon } from '../../icons';
7+
import ConfirmationDialog from '../ConfirmationDialog/ConfirmationDialog';
8+
9+
interface Props {
10+
dataEntityId: DataEntity['id'];
11+
queryExampleId: QueryExample['id'];
12+
}
13+
14+
const QueryExamplesUnlinkButton = ({ dataEntityId, queryExampleId }: Props) => {
15+
const { t } = useTranslation();
16+
const { mutateAsync: unlink } = useUnassignEntityQueryExample();
17+
return (
18+
<ConfirmationDialog
19+
actionTitle={t('Are you sure you want to unlink this query example?')}
20+
actionName={t('Unlink')}
21+
actionText={
22+
<>
23+
Query example #{queryExampleId} {t('will be unlinked')}.
24+
</>
25+
}
26+
onConfirm={() =>
27+
unlink({
28+
exampleId: queryExampleId,
29+
dataEntityId,
30+
})
31+
}
32+
actionBtn={
33+
<Button
34+
buttonType='linkGray-m-icon'
35+
icon={<UnlinkIcon />}
36+
sx={{ marginRight: 1 }}
37+
/>
38+
}
39+
/>
40+
);
41+
};
42+
43+
export default QueryExamplesUnlinkButton;

odd-platform-ui/src/components/shared/elements/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ export { default as DonutChart } from './DonutChart/DonutChart';
8282
export { default as QueryExamplesListHeader } from './QueryExamples/QueryExamplesListHeader';
8383
export { default as QueryExamplesListItem } from './QueryExamples/QueryExamplesListItem';
8484
export { default as QueryExamplesSkeleton } from './QueryExamples/QueryExamplesSkeleton';
85+
export { default as QueryExamplesUnlinkButton } from './QueryExamples/QueryExamplesUnlinkButton';
8586
export { default as SearchInput } from './SearchInput/SearchInput';

odd-platform-ui/src/components/shared/icons/UnlinkIcon.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from 'react';
22
import { type SvgIconProps } from '@mui/material/SvgIcon';
33
import AppSvgIcon from 'components/shared/icons/AppSvgIcon';
44

5-
const UnlinkIcon: React.FC<SvgIconProps> = ({ sx, ...props }) => (
6-
<AppSvgIcon sx={sx} viewBox='0 0 16 16' {...props}>
5+
const UnlinkIcon: React.FC<SvgIconProps> = ({ sx, stroke, ...props }) => (
6+
<AppSvgIcon sx={sx} viewBox='0 0 16 16' stroke={stroke ?? '#091E42'} {...props}>
77
<svg
88
width='16'
99
height='16'
@@ -16,55 +16,48 @@ const UnlinkIcon: React.FC<SvgIconProps> = ({ sx, ...props }) => (
1616
<path
1717
id='Path'
1818
d='M11.3026 8.47087L13.1879 6.58554C14.2292 5.5442 14.2292 3.85554 13.1879 2.8142V2.8142C12.1466 1.77287 10.4579 1.77287 9.41658 2.8142L7.53125 4.69954'
19-
stroke='#091E42'
2019
strokeWidth='1.5'
2120
strokeLinecap='round'
2221
strokeLinejoin='round'
2322
/>
2423
<path
2524
id='Path_2'
2625
d='M4.69758 7.5293L2.81225 9.41463C1.77092 10.456 1.77092 12.1446 2.81225 13.186V13.186C3.85358 14.2273 5.54225 14.2273 6.58358 13.186L8.46892 11.3006'
27-
stroke='#091E42'
2826
strokeWidth='1.5'
2927
strokeLinecap='round'
3028
strokeLinejoin='round'
3129
/>
3230
<path
3331
id='Path_3'
3432
d='M3.75708 5.64089L2.34375 5.17422'
35-
stroke='#091E42'
3633
strokeWidth='1.5'
3734
strokeLinecap='round'
3835
strokeLinejoin='round'
3936
/>
4037
<path
4138
id='Path_4'
4239
d='M5.63698 3.75904L5.17031 2.3457'
43-
stroke='#091E42'
4440
strokeWidth='1.5'
4541
strokeLinecap='round'
4642
strokeLinejoin='round'
4743
/>
4844
<path
4945
id='Path_5'
5046
d='M12.2422 10.3598L13.6622 10.8264'
51-
stroke='#091E42'
5247
strokeWidth='1.5'
5348
strokeLinecap='round'
5449
strokeLinejoin='round'
5550
/>
5651
<path
5752
id='Path_6'
5853
d='M10.3578 12.2402L10.8245 13.6602'
59-
stroke='#091E42'
6054
strokeWidth='1.5'
6155
strokeLinecap='round'
6256
strokeLinejoin='round'
6357
/>
6458
<path
6559
id='Path_7'
6660
d='M6.11719 9.88661L9.89052 6.11328'
67-
stroke='#091E42'
6861
strokeWidth='1.5'
6962
strokeLinecap='round'
7063
strokeLinejoin='round'

tests/docker/docker-compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ services:
1515
- SPRING_DATASOURCE_URL=jdbc:postgresql://database:5432/${POSTGRES_DATABASE}
1616
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
1717
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
18+
- SPRING_CUSTOM-DATASOURCE_URL=jdbc:postgresql://database:5432/${POSTGRES_DATABASE}?schema=lookup_tables_schema
19+
- SPRING_CUSTOM-DATASOURCE_USERNAME=${POSTGRES_USER}
20+
- SPRING_CUSTOM-DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
1821
depends_on:
1922
- database
2023
ports:

0 commit comments

Comments
 (0)