Skip to content

Commit

Permalink
fix sql data preview - remove sorting and formating as not implemented
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta committed Jan 27, 2025
1 parent 7166c76 commit 8f0211b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 27 deletions.
8 changes: 5 additions & 3 deletions src/components/src/common/data-table/header-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const HeaderCellFactory = (FieldToken: React.FC<FieldTokenProps>) => {
const onCopy = useCallback(() => copyTableColumn(column), [copyTableColumn, column]);
const onSetDisplayFormat = useCallback(
displayFormat => {
setColumnDisplayFormat({[column]: displayFormat.format});
setColumnDisplayFormat?.({[column]: displayFormat.format});
},
[column, setColumnDisplayFormat]
);
Expand Down Expand Up @@ -195,10 +195,12 @@ const HeaderCellFactory = (FieldToken: React.FC<FieldTokenProps>) => {
column={column}
colMeta={colMeta}
toggleMoreOptions={toggleMoreOptions}
sortTableColumn={mode => sortTableColumn(column, mode)}
sortTableColumn={
sortTableColumn ? mode => sortTableColumn(column, mode) : undefined
}
pinTableColumn={onPin}
copyTableColumn={onCopy}
setDisplayFormat={onSetDisplayFormat}
setDisplayFormat={setColumnDisplayFormat ? onSetDisplayFormat : undefined}
/>
</section>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/src/common/data-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export interface DataTableProps {
sortColumn: SortColumn;
sortTableColumn: (column: string, mode?: string) => void;
pinTableColumn: (column: string) => void;
setColumnDisplayFormat: (formats: {[key: string]: string}) => void;
setColumnDisplayFormat?: (formats: {[key: string]: string}) => void;
copyTableColumn: (column: string) => void;
sortOrder?: number[] | null;
showStats?: boolean;
Expand Down
18 changes: 10 additions & 8 deletions src/components/src/common/data-table/option-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type FormatterDropdownProps = {
top: number;
isOpened: boolean;
displayFormat?: string;
setDisplayFormat: (displayFormat: TooltipFormat) => void;
setDisplayFormat?: (displayFormat: TooltipFormat) => void;
onClose: () => void;
formatLabels: TooltipFormat[];
};
Expand All @@ -83,15 +83,17 @@ export const FormatterDropdown: React.FC<FormatterDropdownProps> = (
top,
isOpened,
displayFormat = 'None',
setDisplayFormat,
setDisplayFormat = undefined,
onClose,
formatLabels
} = props;
const selectionIndex = formatLabels.findIndex(label => label.format === displayFormat);

const onSelectDisplayFormat = useCallback(
result => {
setDisplayFormat(result);
if (setDisplayFormat) {
setDisplayFormat(result);
}
onClose();
},
[setDisplayFormat, onClose]
Expand All @@ -117,10 +119,10 @@ export interface OptionDropdownProps {
column: string;
colMeta: ColMeta;
toggleMoreOptions: (column: string) => void;
sortTableColumn: (sort: string) => void;
sortTableColumn?: (sort: string) => void;
pinTableColumn: () => void;
copyTableColumn: () => void;
setDisplayFormat: (displayFormat: any) => void;
setDisplayFormat?: (displayFormat: any) => void;
sortMode?: string;
isSorted?: string;
isPinned?: boolean;
Expand All @@ -142,13 +144,13 @@ const OptionDropdown = (props: OptionDropdownProps) => {
({value}) => {
switch (value) {
case TABLE_OPTION.SORT_ASC:
sortTableColumn(SORT_ORDER.ASCENDING);
sortTableColumn?.(SORT_ORDER.ASCENDING);
break;
case TABLE_OPTION.SORT_DES:
sortTableColumn(SORT_ORDER.DESCENDING);
sortTableColumn?.(SORT_ORDER.DESCENDING);
break;
case TABLE_OPTION.UNSORT:
sortTableColumn(SORT_ORDER.UNSORT);
sortTableColumn?.(SORT_ORDER.UNSORT);
break;
case TABLE_OPTION.PIN:
pinTableColumn();
Expand Down
11 changes: 8 additions & 3 deletions src/constants/src/default-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,13 @@ export const TABLE_OPTION_LIST: TableOption[] = [
value: TABLE_OPTION.SORT_ASC,
display: 'Sort Ascending',
icon: 'ArrowUp',
condition: props => props.sortMode !== SORT_ORDER.ASCENDING
condition: props => props.sortTableColumn && props.sortMode !== SORT_ORDER.ASCENDING
},
{
value: TABLE_OPTION.SORT_DES,
display: 'Sort Descending',
icon: 'ArrowDown',
condition: props => props.sortMode !== SORT_ORDER.DESCENDING
condition: props => props.sortTableColumn && props.sortMode !== SORT_ORDER.DESCENDING
},
{
value: TABLE_OPTION.UNSORT,
Expand All @@ -563,7 +563,12 @@ export const TABLE_OPTION_LIST: TableOption[] = [
condition: props => props.isPinned
},
{value: TABLE_OPTION.COPY, display: 'Copy Column', icon: 'Clipboard'},
{value: TABLE_OPTION.FORMAT_COLUMN, display: 'Format Column', icon: 'Hash'}
{
value: TABLE_OPTION.FORMAT_COLUMN,
display: 'Format Column',
icon: 'Hash',
condition: props => props.setDisplayFormat
}
];

const YELLOW = '248, 194, 28';
Expand Down
3 changes: 0 additions & 3 deletions src/duckdb/src/components/preview-data-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ const PreviewDataPanelWOTheme: React.FC<PreviewDataPanelProps> = ({
cellSizeCache={cellSizeCache}
dataContainer={dataContainer}
pinnedColumns={pinnedColumns}
// sortColumn={sortColumnConfig}
copyTableColumn={copyTableColumn}
pinTableColumn={pinTableColumn}
// sortTableColumn={setTableSortColumn}
setColumnDisplayFormat={setColumnDisplayFormat ?? (() => null)}
/>
);
};
Expand Down
11 changes: 6 additions & 5 deletions src/layers/src/icon-layer/icon-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ export const SVG_ICON_URL = `${KEPLER_UNFOLDED_BUCKET}/icons/svg-icons.json`;
export const iconPosAccessor =
({lat, lng, altitude}: IconLayerColumnsConfig) =>
(dc: DataContainerInterface) =>
d => [
dc.valueAt(d.index, lng.fieldIdx),
dc.valueAt(d.index, lat.fieldIdx),
altitude?.fieldIdx > -1 ? dc.valueAt(d.index, altitude.fieldIdx) : 0
];
d =>
[
dc.valueAt(d.index, lng.fieldIdx),
dc.valueAt(d.index, lat.fieldIdx),
altitude?.fieldIdx > -1 ? dc.valueAt(d.index, altitude.fieldIdx) : 0
];

export const iconAccessor =
({icon}: IconLayerColumnsConfig) =>
Expand Down
8 changes: 4 additions & 4 deletions src/utils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ export function getError(
return Object.prototype.hasOwnProperty.call(err, 'message')
? getError(err.message)
: Object.prototype.hasOwnProperty.call(err, 'error')
? getError(err.error)
: Object.prototype.hasOwnProperty.call(err, 'err')
? getError(err.err)
: JSON.stringify(err);
? getError(err.error)
: Object.prototype.hasOwnProperty.call(err, 'err')
? getError(err.err)
: JSON.stringify(err);
}

return defaultMessage;
Expand Down

0 comments on commit 8f0211b

Please sign in to comment.