This is an automated email from the ASF dual-hosted git repository.

chihsuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 8765fa649ef HDDS-17692. [Recon][UI] Block Heatmap Search when path 
validation fails (#11960)
8765fa649ef is described below

commit 8765fa649ef8e3df2b79df2e4ae02f67f5a67b82
Author: sravani <[email protected]>
AuthorDate: Mon Nov 23 17:16:45 2026 +0530

    HDDS-17692. [Recon][UI] Block Heatmap Search when path validation fails 
(#11960)
---
 .../src/__tests__/heatmap/Heatmap.test.tsx         | 20 +++++---
 .../src/v2/pages/heatmap/heatmap.tsx               | 54 ++++++++--------------
 .../ozone-recon-web/src/v2/types/heatmap.types.ts  |  8 ----
 3 files changed, 33 insertions(+), 49 deletions(-)

diff --git 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/Heatmap.test.tsx
 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/Heatmap.test.tsx
index 3d44f067e0f..9d110753a17 100644
--- 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/Heatmap.test.tsx
+++ 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/heatmap/Heatmap.test.tsx
@@ -113,15 +113,23 @@ describe('Heatmap page', () => {
     expect(heatmapRequests).toEqual([{ path: '/', entityType: 'key', 
startDate: '24H' }]);
   });
 
-  test('shows validation error for invalid path characters', async () => {
+  test('searches Ozone paths with special characters without client-side 
validation', async () => {
+    const paths = [
+      '/vol1/b1/a&b#c+d.csv', // encoding: &, #, +
+      '/vol1/my.bucket',
+      '/vol1/key@name',
+    ];
+
     render(<Heatmap />);
     await waitForPlot('root');
 
-    const pathInput = screen.getByPlaceholderText('/');
-    await userEvent.clear(pathInput);
-    await userEvent.type(pathInput, 'bad@path');
-
-    expect(screen.getByText('Please enter valid path')).toBeInTheDocument();
+    for (const path of paths) {
+      await searchPath(path);
+      await waitFor(() => {
+        expect(heatmapRequests.map((request) => request.path)).toContain(path);
+      });
+    }
+    expect(screen.queryByText('Please enter valid 
path')).not.toBeInTheDocument();
   });
 
   test('fetches heatmap for a new path when the user searches', async () => {
diff --git 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
index 10c85f0d3ee..6c46cb9196f 100644
--- 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
+++ 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/heatmap/heatmap.tsx
@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import React, { ChangeEvent, useState, useEffect, useCallback } from 'react';
+import React, { ChangeEvent, useState, useEffect } from 'react';
 import moment, { Moment } from 'moment';
 import { Button, Menu, Input, Dropdown, DatePicker, Form, Result, Spin } from 
'antd';
 import { MenuProps } from 'antd/es/menu';
@@ -24,7 +24,7 @@ import { DownOutlined } from '@ant-design/icons';
 import { showDataFetchError } from '@/utils/common';
 import { useApiData } from '@/v2/hooks/useAPIData.hook';
 import * as CONSTANTS from '@/v2/constants/heatmap.constants';
-import { HeatmapChild, HeatmapResponse, HeatmapState, InputPathState, 
InputPathValidTypes, IResponseError } from '@/v2/types/heatmap.types';
+import { HeatmapChild, HeatmapResponse, HeatmapState } from 
'@/v2/types/heatmap.types';
 import HeatmapPlot from '@/v2/components/plots/heatmapPlot';
 
 import './heatmap.less';
@@ -41,6 +41,15 @@ const DEFAULT_HEATMAP_RESPONSE: HeatmapResponse = {
   minAccessCount: 0
 };
 
+function buildHeatmapReadAccessUrl(startDate: string | number, path: string, 
entityType: string): string {
+  const params = new URLSearchParams({
+    startDate: String(startDate),
+    path,
+    entityType,
+  });
+  return `/api/v1/heatmap/readaccess?${params.toString()}`;
+}
+
 const Heatmap: React.FC<{}> = () => {
   const [state, setState] = useState<HeatmapState>({
     heatmapResponse: DEFAULT_HEATMAP_RESPONSE,
@@ -48,11 +57,7 @@ const Heatmap: React.FC<{}> = () => {
     date: CONSTANTS.TIME_PERIODS[0]
   });
 
-  const [inputPathState, setInputPathState] = useState<InputPathState>({
-    inputPath: CONSTANTS.ROOT_PATH,
-    isInputPathValid: undefined,
-    helpMessage: ''
-  });
+  const [inputPath, setInputPath] = useState<string>(CONSTANTS.ROOT_PATH);
 
   const [searchPath, setSearchPath] = useState<string>(CONSTANTS.ROOT_PATH);
   const [treeEndpointFailed, setTreeEndpointFailed] = useState<boolean>(false);
@@ -64,7 +69,7 @@ const Heatmap: React.FC<{}> = () => {
   // Use the modern hooks pattern for heatmap data - only trigger on 
searchPath change
   const heatmapData = useApiData<HeatmapResponse>(
     isHeatmapEnabled && state.date && searchPath && state.entityType
-      ? 
`/api/v1/heatmap/readaccess?startDate=${state.date}&path=${searchPath}&entityType=${state.entityType}`
+      ? buildHeatmapReadAccessUrl(state.date, searchPath, state.entityType)
       : '',
     DEFAULT_HEATMAP_RESPONSE,
     {
@@ -76,10 +81,7 @@ const Heatmap: React.FC<{}> = () => {
         }
         showDataFetchError(error.message.toString());
         setTreeEndpointFailed(true);
-        setInputPathState(prevState => ({
-          ...prevState,
-          inputPath: CONSTANTS.ROOT_PATH
-        }));
+        setInputPath(CONSTANTS.ROOT_PATH);
         setSearchPath(CONSTANTS.ROOT_PATH);
       }
     }
@@ -100,26 +102,12 @@ const Heatmap: React.FC<{}> = () => {
   }, [heatmapData.data]);
 
   function handleChange(e: ChangeEvent<HTMLInputElement>) {
-    const value = e.target.value;
-    // Only allow letters, numbers,underscores and forward slashes and hyphen
-    const regex = /^[a-zA-Z0-9_/-]*$/;
-
-    let inputValid = undefined;
-    let helpMessage = '';
-    if (!regex.test(value)) {
-      helpMessage = 'Please enter valid path';
-      inputValid = 'error';
-    }
-    setInputPathState({
-      inputPath: value,
-      isInputPathValid: inputValid as InputPathValidTypes,
-      helpMessage: helpMessage
-    });
+    setInputPath(e.target.value);
   }
 
   function handleSubmit() {
-    if (isHeatmapEnabled && state.date && inputPathState.inputPath && 
state.entityType) {
-      setSearchPath(inputPathState.inputPath);
+    if (isHeatmapEnabled && state.date && inputPath && state.entityType) {
+      setSearchPath(inputPath);
     }
   }
 
@@ -173,10 +161,7 @@ const Heatmap: React.FC<{}> = () => {
   };
 
   const updateHeatmapParent = (path: string) => {
-    setInputPathState(prevState => ({
-      ...prevState,
-      inputPath: path
-    }));
+    setInputPath(path);
     setSearchPath(path);
   }
 
@@ -212,7 +197,6 @@ const Heatmap: React.FC<{}> = () => {
   };
 
   const { date, entityType, heatmapResponse } = state;
-  const { inputPath, helpMessage, isInputPathValid } = inputPathState;
   const loading = heatmapData.loading;
 
   const menuCalendar = (
@@ -288,7 +272,7 @@ const Heatmap: React.FC<{}> = () => {
                 <div className='heatmap-filter-section'>
                   <div className='path-input-container'>
                     <h4 style={{ paddingTop: '2%' }}>Path</h4>
-                    <Form.Item className='path-input-element' 
validateStatus={isInputPathValid} help={helpMessage}>
+                    <Form.Item className='path-input-element'>
                       <Input.Search
                         allowClear
                         placeholder={CONSTANTS.ROOT_PATH}
diff --git 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/types/heatmap.types.ts
 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/types/heatmap.types.ts
index a76db22a6fe..8a74a9f6fcb 100644
--- 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/types/heatmap.types.ts
+++ 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/types/heatmap.types.ts
@@ -16,8 +16,6 @@
  * limitations under the License.
  */
 
-export type InputPathValidTypes = 'error' | 'success' | 'warning' | 
'validating' | undefined;
-
 export type HeatmapChild = {
   label: string;
   size: number;
@@ -25,12 +23,6 @@ export type HeatmapChild = {
   color: number;
 }
 
-export type InputPathState = {
-  inputPath: string;
-  isInputPathValid: InputPathValidTypes;
-  helpMessage: string;
-}
-
 export type HeatmapResponse =  {
   label: string;
   path: string;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to