Skip to content

Commit

Permalink
chore(ui): add filter and group concepts to tags in redux
Browse files Browse the repository at this point in the history
  • Loading branch information
hoorayimhelping committed Nov 26, 2019
1 parent 380b411 commit a90899e
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 202 deletions.
5 changes: 5 additions & 0 deletions http/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7862,6 +7862,11 @@ components:
type: array
items:
type: string
aggregateFunctionType:
$ref: '#/components/schemas/BuilderAggregateFunctionType'
BuilderAggregateFunctionType:
type: string
enum: ['filter', 'group']
BuilderFunctionsType:
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
'ts-jest': {
tsConfig: 'tsconfig.test.json',
diagnostics: {
ignoreCodes: [6133] // ignore `'foo' is declared but its value is never read.`
ignoreCodes: [6133, 6192] // ignore unused variable errors
},
},
},
Expand Down
225 changes: 59 additions & 166 deletions ui/src/timeMachine/actions/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,220 +10,113 @@ import {

// Types
import {Dispatch} from 'redux-thunk'
import {GetState} from 'src/types'
import {RemoteDataState} from 'src/types'
import {GetState, RemoteDataState} from 'src/types'
import {BuilderAggregateFunctionType} from 'src/client/generatedRoutes'
import {BuilderFunctionsType} from '@influxdata/influx'

export type Action =
| SetBuilderBucketSelectionAction
| SetBuilderBucketsAction
| SetBuilderBucketsStatusAction
| SetBuilderTagKeysAction
| SetBuilderTagKeysStatusAction
| SetBuilderTagValuesAction
| SetBuilderTagValuesStatusAction
| SetBuilderTagKeySelectionAction
| SetBuilderTagValuesSelectionAction
| AddTagSelectorAction
| RemoveTagSelectorAction
| SetFunctionsAction
| SelectAggregateWindowAction
| SetValuesSearchTermAction
| SetKeysSearchTermAction
| SetBuilderTagsStatusAction

interface SetBuilderBucketsStatusAction {
type: 'SET_BUILDER_BUCKETS_STATUS'
payload: {bucketsStatus: RemoteDataState}
}
| ReturnType<typeof setBuilderAggregateFunctionType>
| ReturnType<typeof setBuilderBucket>
| ReturnType<typeof setBuilderBuckets>
| ReturnType<typeof setBuilderBucketsStatus>
| ReturnType<typeof setBuilderTagKeys>
| ReturnType<typeof setBuilderTagKeysStatus>
| ReturnType<typeof setBuilderTagValues>
| ReturnType<typeof setBuilderTagValuesStatus>
| ReturnType<typeof setBuilderTagKeySelection>
| ReturnType<typeof setBuilderTagValuesSelection>
| ReturnType<typeof addTagSelectorSync>
| ReturnType<typeof removeTagSelectorSync>
| ReturnType<typeof setFunctions>
| ReturnType<typeof selectAggregateWindow>
| ReturnType<typeof setValuesSearchTerm>
| ReturnType<typeof setKeysSearchTerm>
| ReturnType<typeof setBuilderTagsStatus>

export const setBuilderAggregateFunctionType = (
builderAggregateFunctionType: BuilderAggregateFunctionType,
index: number
) => ({
type: 'SET_BUILDER_AGGREGATE_FUNCTION_TYPE' as 'SET_BUILDER_AGGREGATE_FUNCTION_TYPE',
payload: {builderAggregateFunctionType, index},
})

const setBuilderBucketsStatus = (
bucketsStatus: RemoteDataState
): SetBuilderBucketsStatusAction => ({
type: 'SET_BUILDER_BUCKETS_STATUS',
const setBuilderBucketsStatus = (bucketsStatus: RemoteDataState) => ({
type: 'SET_BUILDER_BUCKETS_STATUS' as 'SET_BUILDER_BUCKETS_STATUS',
payload: {bucketsStatus},
})

interface SetBuilderBucketsAction {
type: 'SET_BUILDER_BUCKETS'
payload: {buckets: string[]}
}

export const setBuilderBuckets = (
buckets: string[]
): SetBuilderBucketsAction => ({
type: 'SET_BUILDER_BUCKETS',
export const setBuilderBuckets = (buckets: string[]) => ({
type: 'SET_BUILDER_BUCKETS' as 'SET_BUILDER_BUCKETS',
payload: {buckets},
})

interface SetBuilderBucketSelectionAction {
type: 'SET_BUILDER_BUCKET_SELECTION'
payload: {bucket: string; resetSelections: boolean}
}

const setBuilderBucket = (
bucket: string,
resetSelections: boolean
): SetBuilderBucketSelectionAction => ({
type: 'SET_BUILDER_BUCKET_SELECTION',
const setBuilderBucket = (bucket: string, resetSelections: boolean) => ({
type: 'SET_BUILDER_BUCKET_SELECTION' as 'SET_BUILDER_BUCKET_SELECTION',
payload: {bucket, resetSelections},
})

interface SetBuilderTagsStatusAction {
type: 'SET_BUILDER_TAGS_STATUS'
payload: {status: RemoteDataState}
}

export const setBuilderTagsStatus = (
status: RemoteDataState
): SetBuilderTagsStatusAction => ({
type: 'SET_BUILDER_TAGS_STATUS',
export const setBuilderTagsStatus = (status: RemoteDataState) => ({
type: 'SET_BUILDER_TAGS_STATUS' as 'SET_BUILDER_TAGS_STATUS',
payload: {status},
})

interface SetBuilderTagKeysAction {
type: 'SET_BUILDER_TAG_KEYS'
payload: {index: number; keys: string[]}
}

const setBuilderTagKeys = (
index: number,
keys: string[]
): SetBuilderTagKeysAction => ({
type: 'SET_BUILDER_TAG_KEYS',
const setBuilderTagKeys = (index: number, keys: string[]) => ({
type: 'SET_BUILDER_TAG_KEYS' as 'SET_BUILDER_TAG_KEYS',
payload: {index, keys},
})

interface SetBuilderTagKeysStatusAction {
type: 'SET_BUILDER_TAG_KEYS_STATUS'
payload: {index: number; status: RemoteDataState}
}

const setBuilderTagKeysStatus = (
index: number,
status: RemoteDataState
): SetBuilderTagKeysStatusAction => ({
type: 'SET_BUILDER_TAG_KEYS_STATUS',
const setBuilderTagKeysStatus = (index: number, status: RemoteDataState) => ({
type: 'SET_BUILDER_TAG_KEYS_STATUS' as 'SET_BUILDER_TAG_KEYS_STATUS',
payload: {index, status},
})

interface SetBuilderTagValuesAction {
type: 'SET_BUILDER_TAG_VALUES'
payload: {index: number; values: string[]}
}

const setBuilderTagValues = (
index: number,
values: string[]
): SetBuilderTagValuesAction => ({
type: 'SET_BUILDER_TAG_VALUES',
const setBuilderTagValues = (index: number, values: string[]) => ({
type: 'SET_BUILDER_TAG_VALUES' as 'SET_BUILDER_TAG_VALUES',
payload: {index, values},
})

interface SetBuilderTagValuesStatusAction {
type: 'SET_BUILDER_TAG_VALUES_STATUS'
payload: {index: number; status: RemoteDataState}
}

const setBuilderTagValuesStatus = (
index: number,
status: RemoteDataState
): SetBuilderTagValuesStatusAction => ({
type: 'SET_BUILDER_TAG_VALUES_STATUS',
const setBuilderTagValuesStatus = (index: number, status: RemoteDataState) => ({
type: 'SET_BUILDER_TAG_VALUES_STATUS' as 'SET_BUILDER_TAG_VALUES_STATUS',
payload: {index, status},
})

interface SetBuilderTagKeySelectionAction {
type: 'SET_BUILDER_TAG_KEY_SELECTION'
payload: {index: number; key: string}
}

const setBuilderTagKeySelection = (
index: number,
key: string
): SetBuilderTagKeySelectionAction => ({
type: 'SET_BUILDER_TAG_KEY_SELECTION',
const setBuilderTagKeySelection = (index: number, key: string) => ({
type: 'SET_BUILDER_TAG_KEY_SELECTION' as 'SET_BUILDER_TAG_KEY_SELECTION',
payload: {index, key},
})

interface SetBuilderTagValuesSelectionAction {
type: 'SET_BUILDER_TAG_VALUES_SELECTION'
payload: {index: number; values: string[]}
}

const setBuilderTagValuesSelection = (
index: number,
values: string[]
): SetBuilderTagValuesSelectionAction => ({
type: 'SET_BUILDER_TAG_VALUES_SELECTION',
const setBuilderTagValuesSelection = (index: number, values: string[]) => ({
type: 'SET_BUILDER_TAG_VALUES_SELECTION' as 'SET_BUILDER_TAG_VALUES_SELECTION',
payload: {index, values},
})

interface AddTagSelectorAction {
type: 'ADD_TAG_SELECTOR'
}

const addTagSelectorSync = (): AddTagSelectorAction => ({
type: 'ADD_TAG_SELECTOR',
const addTagSelectorSync = () => ({
type: 'ADD_TAG_SELECTOR' as 'ADD_TAG_SELECTOR',
})

interface RemoveTagSelectorAction {
type: 'REMOVE_TAG_SELECTOR'
payload: {index: number}
}

const removeTagSelectorSync = (index: number): RemoveTagSelectorAction => ({
type: 'REMOVE_TAG_SELECTOR',
const removeTagSelectorSync = (index: number) => ({
type: 'REMOVE_TAG_SELECTOR' as 'REMOVE_TAG_SELECTOR',
payload: {index},
})

interface SetFunctionsAction {
type: 'SELECT_BUILDER_FUNCTION'
payload: {functions: BuilderFunctionsType[]}
}

export const setFunctions = (
functions: BuilderFunctionsType[]
): SetFunctionsAction => ({
type: 'SELECT_BUILDER_FUNCTION',
export const setFunctions = (functions: BuilderFunctionsType[]) => ({
type: 'SELECT_BUILDER_FUNCTION' as 'SELECT_BUILDER_FUNCTION',
payload: {functions},
})

interface SelectAggregateWindowAction {
type: 'SELECT_AGGREGATE_WINDOW'
payload: {period: string}
}

export const selectAggregateWindow = (
period: string
): SelectAggregateWindowAction => ({
type: 'SELECT_AGGREGATE_WINDOW',
export const selectAggregateWindow = (period: string) => ({
type: 'SELECT_AGGREGATE_WINDOW' as 'SELECT_AGGREGATE_WINDOW',
payload: {period},
})

interface SetValuesSearchTermAction {
type: 'SET_BUILDER_VALUES_SEARCH_TERM'
payload: {index: number; searchTerm: string}
}

interface SetKeysSearchTermAction {
type: 'SET_BUILDER_KEYS_SEARCH_TERM'
payload: {index: number; searchTerm: string}
}

export const setValuesSearchTerm = (
index: number,
searchTerm: string
): SetValuesSearchTermAction => ({
type: 'SET_BUILDER_VALUES_SEARCH_TERM',
export const setValuesSearchTerm = (index: number, searchTerm: string) => ({
type: 'SET_BUILDER_VALUES_SEARCH_TERM' as 'SET_BUILDER_VALUES_SEARCH_TERM',
payload: {index, searchTerm},
})

export const setKeysSearchTerm = (
index: number,
searchTerm: string
): SetKeysSearchTermAction => ({
type: 'SET_BUILDER_KEYS_SEARCH_TERM',
export const setKeysSearchTerm = (index: number, searchTerm: string) => ({
type: 'SET_BUILDER_KEYS_SEARCH_TERM' as 'SET_BUILDER_KEYS_SEARCH_TERM',
payload: {index, searchTerm},
})

Expand Down
Loading

0 comments on commit a90899e

Please sign in to comment.