Skip to content

Commit

Permalink
fixes reset search
Browse files Browse the repository at this point in the history
Signed-off-by: Ashwin P Chandran <[email protected]>
  • Loading branch information
ashwin-pc committed Aug 25, 2023
1 parent e91fe01 commit c0d3389
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface DiscoverChartProps {
data: DataPublicPluginStart;
hits: number;
resetQuery: () => void;
showResetButton?: boolean;
timeField?: string;
services: DiscoverServices;
}
Expand All @@ -36,6 +37,7 @@ export const DiscoverChart = ({
resetQuery,
timeField,
services,
showResetButton = false,
}: DiscoverChartProps) => {
const { from, to } = data.query.timefilter.timefilter.getTime();
const timeRange = {
Expand All @@ -59,7 +61,11 @@ export const DiscoverChart = ({
return (
<EuiFlexGroup direction="column" gutterSize="none">
<EuiFlexItem grow={false} className="dscChart__hitsCounter">
<HitsCounter hits={hits > 0 ? hits : 0} showResetButton={false} onResetQuery={resetQuery} />
<HitsCounter
hits={hits > 0 ? hits : 0}
showResetButton={showResetButton}
onResetQuery={resetQuery}
/>
</EuiFlexItem>
{timeField && (
<EuiFlexItem className="dscChart__TimechartHeader">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DiscoverChart } from '../../components/chart/chart';
export const DiscoverChartContainer = ({ hits, bucketInterval, chartData }: SearchData) => {
const { services } = useOpenSearchDashboards<DiscoverViewServices>();
const { uiSettings, data } = services;
const { indexPattern } = useDiscoverContext();
const { indexPattern, savedSearch } = useDiscoverContext();

const timeField = indexPattern?.timeFieldName;

Expand All @@ -31,8 +31,12 @@ export const DiscoverChartContainer = ({ hits, bucketInterval, chartData }: Sear
data={data}
hits={hits}
timeField={timeField}
resetQuery={() => {}}
resetQuery={() => {
window.location.href = `#/view/${savedSearch?.id}`;
window.location.reload();
}}
services={services}
showResetButton={!!savedSearch && !!savedSearch.id}
/>
);
};

0 comments on commit c0d3389

Please sign in to comment.