Skip to content

Commit

Permalink
[Data Explorer][Discover 2.0] Change to inspect icon and update hint msg
Browse files Browse the repository at this point in the history
  • Loading branch information
ananzh committed Aug 25, 2023
1 parent 551e432 commit ef72e0b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EuiDataGrid, EuiDataGridSorting, EuiPanel } from '@elastic/eui';
import { IndexPattern } from '../../../opensearch_dashboards_services';
import { fetchTableDataCell } from './data_grid_table_cell_value';
import { buildDataGridColumns, computeVisibleColumns } from './data_grid_table_columns';
import { DocViewExpandButton } from './data_grid_table_docview_expand_button';
import { DocViewInspectButton } from './data_grid_table_docview_inspect_button';
import { DataGridFlyout } from './data_grid_table_flyout';
import { DiscoverGridContextProvider } from './data_grid_table_context';
import { toolbarVisibility } from './constants';
Expand Down Expand Up @@ -45,7 +45,7 @@ export const DataGridTable = ({
displayTimeColumn,
isToolbarVisible = true,
}: DataGridTableProps) => {
const [expandedHit, setExpandedHit] = useState<OpenSearchSearchHit | undefined>();
const [inspectedHit, setInspectedHit] = useState<OpenSearchSearchHit | undefined>();
const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]);
const pagination = usePagination(rowCount);

Expand Down Expand Up @@ -94,9 +94,9 @@ export const DataGridTable = ({
const leadingControlColumns = useMemo(() => {
return [
{
id: 'expandCollapseColumn',
id: 'inspectCollapseColumn',
headerCellRender: () => null,
rowCellRender: DocViewExpandButton,
rowCellRender: DocViewInspectButton,
width: 40,
},
];
Expand Down Expand Up @@ -134,9 +134,9 @@ export const DataGridTable = ({
return (
<DiscoverGridContextProvider
value={{
expandedHit,
inspectedHit,
onFilter,
setExpandedHit,
setInspectedHit,
rows: rows || [],
indexPattern,
}}
Expand All @@ -147,15 +147,15 @@ export const DataGridTable = ({
{table}
</EuiPanel>
</EuiPanel>
{expandedHit && (
{inspectedHit && (
<DataGridFlyout
indexPattern={indexPattern}
hit={expandedHit}
hit={inspectedHit}
columns={columns}
onRemoveColumn={onRemoveColumn}
onAddColumn={onAddColumn}
onFilter={onFilter}
onClose={() => setExpandedHit(undefined)}
onClose={() => setInspectedHit(undefined)}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { IndexPattern } from '../../../opensearch_dashboards_services';
import { DocViewFilterFn, OpenSearchSearchHit } from '../../doc_views/doc_views_types';

export interface DataGridContextProps {
expandedHit?: OpenSearchSearchHit;
inspectedHit?: OpenSearchSearchHit;
onFilter: DocViewFilterFn;
setExpandedHit: (hit?: OpenSearchSearchHit) => void;
setInspectedHit: (hit?: OpenSearchSearchHit) => void;
rows: OpenSearchSearchHit[];
indexPattern: IndexPattern;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { i18n } from '@osd/i18n';
import { EuiToolTip, EuiButtonIcon, EuiDataGridCellValueElementProps } from '@elastic/eui';
import { useDataGridContext } from './data_grid_table_context';

export const DocViewInspectButton = ({ rowIndex }: EuiDataGridCellValueElementProps) => {
const { inspectedHit, setInspectedHit, rows } = useDataGridContext();
const currentInspected = rows[rowIndex];
const isCurrentInspected = currentInspected === inspectedHit;
const inspectHintMsg = i18n.translate('discover.docViews.table.inspectAriaLabel', {
defaultMessage: 'Inspect document details',
});

return (
<EuiToolTip content={inspectHintMsg}>
<EuiButtonIcon
onClick={() => setInspectedHit(isCurrentInspected ? undefined : currentInspected)}
iconType={isCurrentInspected ? 'minimize' : 'inspect'}
aria-label={inspectHintMsg}
/>
</EuiToolTip>
);
};

0 comments on commit ef72e0b

Please sign in to comment.