Skip to content

Commit

Permalink
[Discover]chore: disable sorting on timestamp column for PPL and SQL
Browse files Browse the repository at this point in the history
Signed-off-by: Joey Liu <[email protected]>
  • Loading branch information
Maosaic committed Jan 24, 2025
1 parent 3fb4b8c commit 81ced5f
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import { getOsdFieldOverrides } from 'src/plugins/data/common';
import { getOsdFieldOverrides } from '../../../../../../plugins/data/common';
import { IndexPattern } from '../../../opensearch_dashboards_services';
import { shortenDottedString } from '../../helpers';

Expand Down Expand Up @@ -56,11 +56,16 @@ export interface ColumnProps {
* prepended, not moveable and removeable
* @param timeFieldName
*/
export function getTimeColumn(timeFieldName: string): ColumnProps {
export function getTimeColumn(
timeFieldName: string,
osdFieldOverrides: {
[key: string]: any;
}
): ColumnProps {
return {
name: timeFieldName,
displayName: 'Time',
isSortable: true,
isSortable: osdFieldOverrides.sortable == null ? true : osdFieldOverrides.sortable,
isRemoveable: false,
colLeftIdx: -1,
colRightIdx: -1,
Expand All @@ -84,9 +89,10 @@ export function getLegacyDisplayedColumns(
if (!Array.isArray(columns) || typeof indexPattern !== 'object' || !indexPattern.getFieldByName) {
return [];
}
// TODO: Remove overrides once we support PPL/SQL sorting
const osdFieldOverrides = getOsdFieldOverrides();

Check warning on line 93 in src/plugins/discover/public/application/components/default_discover_table/helper.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/discover/public/application/components/default_discover_table/helper.tsx#L93

Added line #L93 was not covered by tests
const columnProps = columns.map((column, idx) => {
const field = indexPattern.getFieldByName(column);
const osdFieldOverrides = getOsdFieldOverrides();
return {
name: column,
displayName: isShortDots ? shortenDottedString(column) : column,
Expand All @@ -104,6 +110,6 @@ export function getLegacyDisplayedColumns(
!columns.includes(indexPattern.timeFieldName);

return shouldIncludeTimeField
? [getTimeColumn(indexPattern.timeFieldName as string), ...columnProps]
? [getTimeColumn(indexPattern.timeFieldName as string, osdFieldOverrides), ...columnProps]
: columnProps;
}

0 comments on commit 81ced5f

Please sign in to comment.