-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): resolved telegraf bucket dropdown bug and undefined token is…
…sue (#17363)
- Loading branch information
Showing
10 changed files
with
216 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Libraries | ||
import React, {FC} from 'react' | ||
import {connect} from 'react-redux' | ||
import { | ||
Button, | ||
ComponentColor, | ||
ComponentSize, | ||
ComponentStatus, | ||
IconFont, | ||
} from '@influxdata/clockface' | ||
|
||
// Decorator | ||
import {Notification} from 'src/types' | ||
|
||
// Components | ||
import FancyScrollbar from 'src/shared/components/fancy_scrollbar/FancyScrollbar' | ||
import CopyButton from 'src/shared/components/CopyButton' | ||
|
||
// Actions | ||
import {generateTelegrafToken} from 'src/dataLoaders/actions/dataLoaders' | ||
|
||
export interface Props { | ||
configID: string | ||
token: string | ||
onCopyText?: (text: string, status: boolean) => Notification | ||
testID?: string | ||
label: string | ||
} | ||
|
||
interface DispatchProps { | ||
onGenerateTelegrafToken: typeof generateTelegrafToken | ||
} | ||
|
||
const TokenCodeSnippet: FC<Props & DispatchProps> = ({ | ||
token, | ||
onCopyText, | ||
testID, | ||
label = 'Code Snippet', | ||
}) => { | ||
const handleRefreshClick = () => { | ||
const {configID, onGenerateTelegrafToken} = this.props | ||
onGenerateTelegrafToken(configID) | ||
} | ||
|
||
return ( | ||
<div className="code-snippet" data-testid={testID}> | ||
<FancyScrollbar | ||
autoHide={false} | ||
autoHeight={true} | ||
maxHeight={400} | ||
className="code-snippet--scroll" | ||
> | ||
<div className="code-snippet--text"> | ||
<pre> | ||
export INFLUX_TOKEN=<i>{token || '<INFLUX_TOKEN>'}</i> | ||
</pre> | ||
</div> | ||
</FancyScrollbar> | ||
<div className="code-snippet--footer"> | ||
<div> | ||
<CopyButton | ||
textToCopy={token} | ||
onCopyText={onCopyText} | ||
contentName="Script" | ||
/> | ||
<Button | ||
size={ComponentSize.ExtraSmall} | ||
status={ | ||
token === '' ? ComponentStatus.Default : ComponentStatus.Disabled | ||
} | ||
text="Generate New Token" | ||
titleText="Generate New Token" | ||
icon={IconFont.Refresh} | ||
color={ComponentColor.Success} | ||
onClick={handleRefreshClick} | ||
className="new-token--btn" | ||
/> | ||
</div> | ||
<label className="code-snippet--label">{label}</label> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const mdtp: DispatchProps = { | ||
onGenerateTelegrafToken: generateTelegrafToken, | ||
} | ||
|
||
export default connect<{}, DispatchProps>( | ||
null, | ||
mdtp | ||
)(TokenCodeSnippet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.