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(dataloader-buckets): default bucket selection should not be system bucket #16413

Merged
merged 4 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
1. [16435](https://github.com/influxdata/influxdb/pull/16435): Time labels are no longer squished to the left
1. [16427](https://github.com/influxdata/influxdb/pull/16427): Fixed underlying issue with disappearing queries made in Advanced Mode
1. [16439](https://github.com/influxdata/influxdb/pull/16439): Prevent negative zero and allow zero to have decimal places
1. [16376](https://github.com/influxdata/influxdb/pull/16413): Limit data loader bucket selection to non system buckets

### UI Improvements

Expand Down
8 changes: 3 additions & 5 deletions ui/src/dataLoaders/components/BucketsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ class BucketsDropdown extends PureComponent<Props> {
return []
}

const nonSystemBuckets = buckets.filter(bucket => {
if (!isSystemBucket(bucket.name)) {
return bucket
}
})
const nonSystemBuckets = buckets.filter(
bucket => !isSystemBucket(bucket.name)
)

return nonSystemBuckets.map(b => (
<Dropdown.Item
Expand Down
36 changes: 13 additions & 23 deletions ui/src/dataLoaders/components/collectorsWizard/CollectorsWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {AppState, Bucket, Organization, ResourceType} from 'src/types'
// Selectors
import {getAll} from 'src/resources/selectors'
import {getOrg} from 'src/organizations/selectors'
import {isSystemBucket} from 'src/buckets/selectors'

export interface CollectorsStepProps {
currentStepIndex: number
Expand Down Expand Up @@ -84,24 +85,17 @@ interface StateProps {
org: Organization
}

interface State {
buckets: Bucket[]
}

type Props = StateProps & DispatchProps
type AllProps = Props & WithRouterProps

@ErrorHandling
class CollectorsWizard extends PureComponent<AllProps, State> {
constructor(props: AllProps) {
super(props)
this.state = {
buckets: [],
}
}

class CollectorsWizard extends PureComponent<AllProps> {
public componentDidMount() {
this.handleSetBucketInfo()
const {bucket, buckets} = this.props
if (!bucket && (buckets && buckets.length)) {
const {orgID, name, id} = buckets[0]
this.props.onSetBucketInfo(orgID, name, id)
}
this.props.onSetCurrentStepIndex(0)
}

Expand Down Expand Up @@ -134,15 +128,6 @@ class CollectorsWizard extends PureComponent<AllProps, State> {
)
}

private handleSetBucketInfo = () => {
const {bucket, buckets} = this.props
if (!bucket && (buckets && buckets.length)) {
const {orgID, name, id} = buckets[0]

this.props.onSetBucketInfo(orgID, name, id)
}
}

private handleDismiss = () => {
const {router, org} = this.props

Expand Down Expand Up @@ -187,6 +172,11 @@ const mstp = (state: AppState): StateProps => {
} = state

const buckets = getAll<Bucket>(state, ResourceType.Buckets)

const nonSystemBuckets = buckets.filter(
bucket => !isSystemBucket(bucket.name)
)

const org = getOrg(state)

return {
Expand All @@ -197,7 +187,7 @@ const mstp = (state: AppState): StateProps => {
substep,
username: name,
bucket,
buckets,
buckets: nonSystemBuckets,
org,
}
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/onboarding/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ const setOrganizationID = (orgID: string): SetOrganizationID => ({
})

interface SetBucketID {
type: 'SET_BUCKET_ID'
type: 'SET_ONBOARDING_BUCKET_ID'
payload: {bucketID: string}
}

export const setBucketID = (bucketID: string): SetBucketID => ({
type: 'SET_BUCKET_ID',
type: 'SET_ONBOARDING_BUCKET_ID',
payload: {bucketID},
})

Expand Down
2 changes: 1 addition & 1 deletion ui/src/onboarding/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default (state = INITIAL_STATE, action: Action): OnboardingState => {
return {...state, stepStatuses}
case 'SET_ORG_ID':
return {...state, orgID: action.payload.orgID}
case 'SET_BUCKET_ID':
case 'SET_ONBOARDING_BUCKET_ID':
return {...state, bucketID: action.payload.bucketID}
default:
return state
Expand Down
17 changes: 0 additions & 17 deletions ui/src/telegrafs/components/Collectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import NoBucketsWarning from 'src/buckets/components/NoBucketsWarning'
import GetResources from 'src/shared/components/GetResources'

// Actions
import {setBucketInfo} from 'src/dataLoaders/actions/steps'
import {updateTelegraf, deleteTelegraf} from 'src/telegrafs/actions/thunks'

// Decorators
Expand All @@ -33,12 +32,10 @@ import {ErrorHandling} from 'src/shared/decorators/errors'
// Types
import {Telegraf, OverlayState, AppState, Bucket, ResourceType} from 'src/types'
import {
setDataLoadersType,
setTelegrafConfigID,
setTelegrafConfigName,
clearDataLoaders,
} from 'src/dataLoaders/actions/dataLoaders'
import {DataLoaderType} from 'src/types/dataLoaders'
import {SortTypes} from 'src/shared/utils/sort'

// Selectors
Expand All @@ -52,8 +49,6 @@ interface StateProps {
}

interface DispatchProps {
onSetBucketInfo: typeof setBucketInfo
onSetDataLoadersType: typeof setDataLoadersType
onSetTelegrafConfigID: typeof setTelegrafConfigID
onSetTelegrafConfigName: typeof setTelegrafConfigName
onClearDataLoaders: typeof clearDataLoaders
Expand Down Expand Up @@ -193,20 +188,10 @@ class Collectors extends PureComponent<Props, State> {

private handleAddCollector = () => {
const {
buckets,
onSetBucketInfo,
onSetDataLoadersType,
router,
params: {orgID},
} = this.props

if (buckets && buckets.length) {
const {orgID, name, id} = buckets[0]
onSetBucketInfo(orgID, name, id)
}

onSetDataLoadersType(DataLoaderType.Scraping)

router.push(`/orgs/${orgID}/load-data/telegrafs/new`)
}

Expand Down Expand Up @@ -273,8 +258,6 @@ const mstp = (state: AppState): StateProps => {
}

const mdtp: DispatchProps = {
onSetBucketInfo: setBucketInfo,
onSetDataLoadersType: setDataLoadersType,
onSetTelegrafConfigID: setTelegrafConfigID,
onSetTelegrafConfigName: setTelegrafConfigName,
onClearDataLoaders: clearDataLoaders,
Expand Down