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

WIP - Add ability to generate report without uploading #849

Closed
wants to merge 2 commits into from

Conversation

chris1984
Copy link
Member

@chris1984 chris1984 commented Oct 17, 2023

Need to figure out why i'm getting

TabHeader.js:19  Uncaught ReferenceError: restartDisconnected is not defined
at Object.<anonymous> (TabHeader.js:19:14)

And also update the JS snapshots so tests will pass.

@ShimShtein let me know if the backend change looks fine, I sent a link to this pr to @Ron-Lavi so he can help with the JS stuff

Looks like the JS tests GitHub action is failing to even start with our favorite thing

npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR! 
npm ERR! 
npm ERR! Invalid: lock file's [email protected] does not satisfy cosmiconfig-typescript-loader@~4.3.0
npm ERR! 

Copy link
Member

@Ron-Lavi Ron-Lavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chris1984, hope my review is readable, I gave you some other option if you want but since you already invested quite a lot in this PR, I also suggested a small fix to the current issue

Comment on lines +34 to +54
<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}
/>
Copy link
Member

Choose a reason for hiding this comment

The 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 useAPI

import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';

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);
Copy link
Member

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 the TabHeader component to trigger a component re-render

Copy link
Member Author

@chris1984 chris1984 Oct 19, 2023

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.

ouiaId="restart_disconnected"
key="restart_disconnected"
component="button"
onClick={restartDisconnected}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case you would still like to use Redux in this PR,
the prop restartDisconnected would be passed to the TabHeader component, maybe you want to pass the dropdownItems into that component, e.g:

const TabHeader = ({ exitCode, onRestart, onDownload, restartDisconnected, toggleFullScreen }) => {
const dropdownItems = [....]
return <Grid.Row className="tab-header">.......</Grid.Row>
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I put in const dropdownItems = [....] everything lights up red like a stop light 🤣 the error from vscode says

Identifier expected. 'const' is a reserved word that cannot be used here.ts(1359)

@Ron-Lavi
Copy link
Member

Ron-Lavi commented Oct 17, 2023

Looks like the JS tests GitHub action is failing to even start with our favorite thing

npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in >sync. Please update your lock file with `npm install` before continuing.
npm ERR! 
npm ERR! 
npm ERR! Invalid: lock file's [email protected] does not satisfy cosmiconfig-typescript-loader@~4.3.0
npm ERR! 

looks like you need either to update the package.json with `"cosmiconfig-typescript-loader": "^4.0.0",
or update the package-lock.json.plugin with a newer version of "cosmiconfig-typescript-loader"

@chris1984
Copy link
Member Author

cosmiconfig-typescript-loader

Blah that didn't work, I remember we had to pin that to 4.0.0 a while back because the tests started to fail and we got a dependency error. @ShimShtein can probably tell more about it

@chris1984
Copy link
Member Author

Since we are close to the dev freeze, i'm going to close this one out and just open a PR for the backend change and then expose that api to the rails controller so hammer can use it. We can add the UI button at a later time.

@chris1984 chris1984 closed this Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants