Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): add filter to fieldOptions when dragging a column #15707

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions ui/src/timeMachine/components/view_options/TableOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ export class TableOptions extends Component<Props, {}> {
onSetDecimalPlaces,
} = this.props

const filteredColumns = fieldOptions.filter(
col =>
col.internalName !== 'time' &&
col.internalName !== '' &&
col.internalName !== 'result' &&
col.internalName !== 'table'
)
const filteredColumns = this.filterFieldOptions(fieldOptions)

const {fixFirstColumn, sortBy} = tableOptions

Expand Down Expand Up @@ -139,13 +133,27 @@ export class TableOptions extends Component<Props, {}> {
)
}

private filterFieldOptions = (fieldOptions: FieldOption[]) => {
return fieldOptions.filter(
col =>
col.internalName !== 'time' &&
col.internalName !== '' &&
col.internalName !== 'result' &&
col.internalName !== 'table'
)
}

private handleChangeSortBy = (sortBy: FieldOption) => {
const {tableOptions, onSetTableOptions} = this.props
onSetTableOptions({...tableOptions, sortBy})
}

private handleMoveColumn = (dragIndex: number, hoverIndex: number) => {
const fieldOptions = move(this.props.fieldOptions, dragIndex, hoverIndex)
const fieldOptions = move(
this.filterFieldOptions(this.props.fieldOptions),
dragIndex,
hoverIndex
)
this.props.onSetFieldOptions(fieldOptions)
}

Expand Down