-
Notifications
You must be signed in to change notification settings - Fork 32
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
WIP - Add ability to generate report without uploading #849
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,57 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Grid, Button, Icon } from 'patternfly-react'; | ||
import { Grid, Button, Icon, DropdownItem, Dropdown, DropdownToggle, DropdownToggleAction } from 'patternfly-react'; | ||
import { noop } from 'foremanReact/common/helpers'; | ||
import { sprintf, translate as __ } from 'foremanReact/common/I18n'; | ||
import { isExitCodeLoading } from '../../ForemanInventoryHelpers'; | ||
import './tabHeader.scss'; | ||
|
||
const TabHeader = ({ exitCode, onRestart, onDownload, toggleFullScreen }) => ( | ||
const onActionToggle = () => { | ||
setIsActionOpen(prev => !prev); | ||
}; | ||
|
||
const dropdownItems = [ | ||
<DropdownItem | ||
aria-label="restart_disconnected" | ||
ouiaId="restart_disconnected" | ||
key="restart_disconnected" | ||
component="button" | ||
onClick={restartDisconnected} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in case you would still like to use Redux in this PR, const TabHeader = ({ exitCode, onRestart, onDownload, restartDisconnected, toggleFullScreen }) => {
const dropdownItems = [....]
return <Grid.Row className="tab-header">.......</Grid.Row>
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I put in Identifier expected. 'const' is a reserved word that cannot be used here.ts(1359) |
||
isDisabled={isExitCodeLoading(exitCode)} | ||
> | ||
{__('Restart without uploading')} | ||
</DropdownItem>, | ||
]; | ||
|
||
const TabHeader = ({ exitCode, onRestart, onDownload, restartDisconnected, toggleFullScreen }) => ( | ||
<Grid.Row className="tab-header"> | ||
<Grid.Col sm={6}> | ||
<p>{sprintf(__('Exit Code: %s'), exitCode)}</p> | ||
</Grid.Col> | ||
<Grid.Col sm={6}> | ||
<div className="tab-action-buttons"> | ||
{onRestart ? ( | ||
<Button | ||
bsStyle="primary" | ||
onClick={onRestart} | ||
disabled={isExitCodeLoading(exitCode)} | ||
> | ||
{__('Restart')} | ||
</Button> | ||
<Dropdown | ||
aria-label="restart_dropdown" | ||
ouiaId="restart_dropdown" | ||
toggle={ | ||
<DropdownToggle | ||
aria-label="restart_report_toggle" | ||
ouiaId="restart_report_toggle" | ||
splitButtonItems={[ | ||
<DropdownToggleAction key="action" aria-label="bulk_actions" onClick={onRestart}> | ||
{__('Restart')} | ||
</DropdownToggleAction>, | ||
]} | ||
splitButtonVariant="action" | ||
toggleVariant="primary" | ||
onToggle={onActionToggle} | ||
isDisabled={isExitCodeLoading(exitCode)} | ||
/> | ||
} | ||
isOpen={isActionOpen} | ||
dropdownItems={dropdownItems} | ||
/> | ||
Comment on lines
+34
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have already done a lot of work to fit this in, but if interested this could have been implemented in a separate component with "newer" technologies even without using redux actions reducers and all that stuff. for the API call you could use
|
||
) : null} | ||
{onDownload ? ( | ||
<Button onClick={onDownload}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this setter coming from?
I think it would be better to use React's
useState
inside theTabHeader
component to trigger a component re-renderThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied and pasted that in from the Katello Errata tab, since we needed an
onActionToggle
That was probably a bad idea, but I am guessing we are missing something else.