Skip to content

Commit

Permalink
fix: the scroll issue and name issue in save view (#3604)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat Dabade authored Sep 21, 2023
1 parent 31b898b commit 5c437dd
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 3 deletions.
2 changes: 2 additions & 0 deletions frontend/src/components/ExplorerCard/ExplorerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { useNotifications } from 'hooks/useNotifications';
import { mapCompositeQueryFromQuery } from 'lib/newQueryBuilder/queryBuilderMappers/mapCompositeQueryFromQuery';
import { useState } from 'react';
import { useCopyToClipboard } from 'react-use';
import { popupContainer } from 'utils/selectPopupContainer';

import { ExploreHeaderToolTip, SaveButtonText } from './constants';
import MenuItemGenerator from './MenuItemGenerator';
Expand Down Expand Up @@ -170,6 +171,7 @@ function ExplorerCard({
{viewsData?.data.data && viewsData?.data.data.length && (
<Space>
<Select
getPopupContainer={popupContainer}
loading={isLoading || isRefetching}
showSearch
placeholder="Select a view"
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/components/ExplorerCard/MenuItemGenerator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeleteOutlined } from '@ant-design/icons';
import { Col, Row, Typography } from 'antd';
import { Col, Row, Tooltip, Typography } from 'antd';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useDeleteView } from 'hooks/saveViews/useDeleteView';
import { useHandleExplorerTabChange } from 'hooks/useHandleExplorerTabChange';
Expand All @@ -8,7 +8,11 @@ import { MouseEvent, useCallback } from 'react';

import { MenuItemContainer } from './styles';
import { MenuItemLabelGeneratorProps } from './types';
import { deleteViewHandler, getViewDetailsUsingViewKey } from './utils';
import {
deleteViewHandler,
getViewDetailsUsingViewKey,
trimViewName,
} from './utils';

function MenuItemGenerator({
viewName,
Expand Down Expand Up @@ -71,12 +75,16 @@ function MenuItemGenerator({
});
};

const newViewName = trimViewName(viewName);

return (
<MenuItemContainer onClick={onLabelClickHandler}>
<Row justify="space-between">
<Col span={22}>
<Row>
<Typography.Text strong>{viewName}</Typography.Text>
<Tooltip title={viewName}>
<Typography.Text strong>{newViewName}</Typography.Text>
</Tooltip>
</Row>
<Row>
<Typography.Text type="secondary">Created by {createdBy}</Typography.Text>
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/components/ExplorerCard/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,10 @@ export const deleteViewHandler = ({
},
});
};

export const trimViewName = (viewName: string): string => {
if (viewName.length > 20) {
return `${viewName.substring(0, 20)}...`;
}
return viewName;
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from 'types/api/queryBuilder/queryAutocompleteResponse';
import { DataSource } from 'types/common/queryBuilder';
import { ExtendedSelectOption } from 'types/common/select';
import { popupContainer } from 'utils/selectPopupContainer';
import { transformToUpperCase } from 'utils/transformToUpperCase';

import { selectStyle } from '../QueryBuilderSearch/config';
Expand Down Expand Up @@ -172,6 +173,7 @@ export const AggregatorFilter = memo(function AggregatorFilter({

return (
<AutoComplete
getPopupContainer={popupContainer}
placeholder={placeholder}
style={selectStyle}
showArrow={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { memo, useCallback, useEffect, useState } from 'react';
import { useQueryClient } from 'react-query';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { SelectOption } from 'types/common/select';
import { popupContainer } from 'utils/selectPopupContainer';

import { selectStyle } from '../QueryBuilderSearch/config';
import { GroupByFilterProps } from './GroupByFilter.interfaces';
Expand Down Expand Up @@ -169,6 +170,7 @@ export const GroupByFilter = memo(function GroupByFilter({

return (
<Select
getPopupContainer={popupContainer}
mode="tags"
style={selectStyle}
onSearch={handleSearchKeys}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
import { Having, HavingForm } from 'types/api/queryBuilder/queryBuilderData';
import { DataSource } from 'types/common/queryBuilder';
import { SelectOption } from 'types/common/select';
import { popupContainer } from 'utils/selectPopupContainer';

// ** Types
import { HavingFilterProps } from './HavingFilter.interfaces';
Expand Down Expand Up @@ -224,6 +225,7 @@ export function HavingFilter({

return (
<Select
getPopupContainer={popupContainer}
autoClearSearchValue={false}
mode="multiple"
onSearch={handleSearch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Select, Spin } from 'antd';
import { useGetAggregateKeys } from 'hooks/queryBuilder/useGetAggregateKeys';
import { useMemo } from 'react';
import { DataSource, MetricAggregateOperator } from 'types/common/queryBuilder';
import { popupContainer } from 'utils/selectPopupContainer';

import { selectStyle } from '../QueryBuilderSearch/config';
import { OrderByFilterProps } from './OrderByFilter.interfaces';
Expand Down Expand Up @@ -66,6 +67,7 @@ export function OrderByFilter({

return (
<Select
getPopupContainer={popupContainer}
mode="tags"
style={selectStyle}
onSearch={handleSearchKeys}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TagFilter,
} from 'types/api/queryBuilder/queryBuilderData';
import { DataSource } from 'types/common/queryBuilder';
import { popupContainer } from 'utils/selectPopupContainer';
import { v4 as uuid } from 'uuid';

import { selectStyle } from './config';
Expand Down Expand Up @@ -185,6 +186,7 @@ function QueryBuilderSearch({

return (
<Select
getPopupContainer={popupContainer}
virtual
showSearch
tagRender={onTagRender}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/utils/selectPopupContainer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const popupContainer = (trigger: any): HTMLElement => trigger.parentNode;

0 comments on commit 5c437dd

Please sign in to comment.