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
Feat(cli-terminal): Create cli-terminal #4762
Feat(cli-terminal): Create cli-terminal #4762
Conversation
/kind feature |
d188f87
to
5e91d37
Compare
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.
I know there is still some work left to be done, But few redux comments that need attention. Also Need proper typings.
toggleTerminal, | ||
}) => ( | ||
<CloudShellDrawer open={isTerminalExpanded} onClose={() => toggleTerminal()}> | ||
<CloudShellBody /> |
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.
Remove this and use CloudShellTerminal here. This was just a dummy component
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.
updated
); | ||
|
||
const terminalStateToProps = ({ UI }: RootState) => ({ | ||
isTerminalExpanded: !!UI.getIn(['terminal', 'isExpanded']), |
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.
Why double !!
? isExpanded
should be a boolean value or have open, close
state.
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.
updated
const connecttoTerminalIcon = connect((state: RootState) => terminalStateToProps(state), { | ||
toggleTerminal: UIActions.terminalDrawerToggleExpanded, | ||
}); | ||
const ConnectedTerminal = connecttoTerminalIcon(TerminalContent); | ||
|
||
export default ConnectedTerminal; |
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.
const connecttoTerminalIcon = connect((state: RootState) => terminalStateToProps(state), { | |
toggleTerminal: UIActions.terminalDrawerToggleExpanded, | |
}); | |
const ConnectedTerminal = connecttoTerminalIcon(TerminalContent); | |
export default ConnectedTerminal; | |
const terminalPropsToState = { | |
toggleTerminal: UIActions.terminalDrawerToggleExpanded, | |
}; | |
export default connect(terminalStateToProps, terminalPropsToState)(TerminalContent); |
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.
updated
export default (state: State, action: TerminalAction) => { | ||
if (!state) { | ||
return Map({ | ||
terminal: () => {}, |
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.
currently your state looks like this
temrinal: {
terminal: () => {}
}
change
terminal: () => {}, | |
isExpanded: false, |
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.
updated
}); | ||
} | ||
if (action.type === Actions.TerminalDrawerToggleExpanded) | ||
return state.setIn(['terminal', 'isExpanded'], !state.getIn(['terminal', 'isExpanded'])); |
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.
change this according to the above state.
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.
updated
toggleTerminal: any; | ||
}; | ||
|
||
const TerminalContent: React.FC<TerminalContentProps> = ({ |
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.
Rename this to CloudShell
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.
updated
flags: Record<string, any>; | ||
terminalToggle: any; | ||
}; | ||
const TerminalToolicon: React.FC<TerminalTooliconProps> = ({ flags, terminalToggle }) => { |
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.
Rename CloudShellIcon
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.
updated
const ConnectedTerminalToolicon = connectToFlags(FLAG_DEVWORKSPACE)(TerminalToolicon); | ||
|
||
export default ConnectedTerminalToolicon; |
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.
const ConnectedTerminalToolicon = connectToFlags(FLAG_DEVWORKSPACE)(TerminalToolicon); | |
export default ConnectedTerminalToolicon; | |
export default connectToFlags(FLAG_DEVWORKSPACE)(TerminalToolicon); |
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.
updated
5e91d37
to
9881603
Compare
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.
@abhinandan13jan The background should be black even in the loading state and your loading state is different from the one in the UX designs.
); | ||
type CloudshellContentProps = { | ||
isTerminalExpanded: boolean; | ||
toggleTerminal: any; |
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.
remove any
, type should be () => void
type terminalToggle = () => void; | ||
|
||
type TerminalTooliconProps = { | ||
flags: Record<string, any>; |
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.
add proper type in place of any
|
||
type TerminalTooliconProps = { | ||
flags: Record<string, any>; | ||
terminalToggle: terminalToggle; |
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.
terminalToggle is not reusable type so use directly () => void
const TerminalToolicon: React.FC<TerminalTooliconProps> = ({ flags, terminalToggle }) => { | ||
if (!flags[FLAG_DEVWORKSPACE]) return null; | ||
return ( | ||
<ToolbarItem> | ||
<Button variant="plain" aria-label="Terminal" onClick={terminalToggle}> | ||
<TerminalIcon className="co-masthead-icon" /> | ||
</Button> | ||
</ToolbarItem> | ||
); | ||
}; |
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.
can be simplified
const TerminalToolicon: React.FC<TerminalTooliconProps> = ({ flags, terminalToggle }) => { | |
if (!flags[FLAG_DEVWORKSPACE]) return null; | |
return ( | |
<ToolbarItem> | |
<Button variant="plain" aria-label="Terminal" onClick={terminalToggle}> | |
<TerminalIcon className="co-masthead-icon" /> | |
</Button> | |
</ToolbarItem> | |
); | |
}; | |
const TerminalToolicon: React.FC<TerminalTooliconProps> = ({ flags, terminalToggle }) => ( flags[FLAG_DEVWORKSPACE] ? ( | |
<ToolbarItem> | |
<Button variant="plain" aria-label="Terminal" onClick={terminalToggle}> | |
<TerminalIcon className="co-masthead-icon" /> | |
</Button> | |
</ToolbarItem> | |
) : null ); | |
if (!flags[FLAG_DEVWORKSPACE]) return null; | ||
return ( | ||
<ToolbarItem> | ||
<Button variant="plain" aria-label="Terminal" onClick={terminalToggle}> |
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.
aria-label should be Command Line Terminal
and there should be tooltip for this button. Please, check the UX design doc for the content of tooltip.
export default (state: State, action: TerminalAction) => { | ||
if (!state) { | ||
return Map({ | ||
terminal: { isExpanded: false }, |
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.
This should be
terminal: { isExpanded: false }, | |
isExpanded: false, |
because you already have terminal
property in the combineReducer.
}); | ||
} | ||
if (action.type === Actions.TerminalDrawerToggleExpanded) | ||
return state.setIn(['terminal', 'isExpanded'], !state.getIn(['terminal', 'isExpanded'])); |
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.
we are using cloud-shell
name everywhere. We should look to rename terminal
to cloudShell
here as well.
value: string; | ||
name: string; | ||
}; | ||
type Component = { |
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.
Component
is very generic name. It would be good idea to rename this to something else like DevFileComponents
.
isTerminalExpanded, | ||
toggleTerminal, | ||
}) => ( | ||
<CloudShellDrawer open={isTerminalExpanded} onClose={() => toggleTerminal()}> |
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.
terminalToggle: terminalToggle; | ||
}; | ||
|
||
const TerminalToolicon: React.FC<TerminalTooliconProps> = ({ flags, terminalToggle }) => { |
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.
rename this to CloudShellIcon
30fb59a
to
d97e613
Compare
|
||
const dispatchToProps = (dispatch: Dispatch): DispatchProps => ({ | ||
onClose: () => | ||
confirmModal({ |
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.
This should not be part of redux callbacks, create a sperate callback for modal something like this
const closeCloudShellConfirmationModal = (callback) => {confirmModal({
title: 'Close Terminal?',
message: (
<>
This will close the terminal session. Content in the terminal will not be resolved in the
next seesion.
</>
),
btnText: 'Yes',
submitDanger: true,
cancelText: 'No',
executeFn: callback,
})};
you can use the same in CloudShellMastheadButton as well.
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.
updated this
<CloudShellBody /> | ||
</CloudShellDrawer> | ||
</> | ||
<CloudShellDrawer open={open} onClose={onClose}> |
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.
<CloudShellDrawer open={open} onClose={onClose}> | |
<CloudShellDrawer open={open} onClose={() => closeTerminalConfirmationModal(onClose)}> |
export type CloudShellDrawerProps = { | ||
open: boolean; | ||
type CloudShellDrawerProps = { | ||
open?: boolean; |
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.
Not sure, why this is optional. We don't provide a default value for open also if this is omitted from the props then we would have no way to render the drawer component.
|
||
const toggleTerminal = () => { | ||
if (open) { | ||
return confirmModal({ |
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.
use a common utility for this, same as above closeCloudShellConfirmationModal
} | ||
|
||
return ( | ||
<Tooltip content={open ? 'Close Terminal' : 'Open Terminal'}> |
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.
Tooltip content Open command line terminal
. Check design doc.
Also, the tooltip should be on the button instead of ToolbarItem
.
frontend/public/components/app.jsx
Outdated
@@ -2,10 +2,12 @@ import * as _ from 'lodash-es'; | |||
import * as React from 'react'; | |||
import { render } from 'react-dom'; | |||
import { Helmet } from 'react-helmet'; | |||
|
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.
remove this extra line
d97e613
to
6c06050
Compare
@abhinandan13jan From the GIF i see that the 'Close' modal message is not correct and there is a typo in the 2nd line for the word 'session'...Please refer the design doc for the proposed message in the modal-https://docs.google.com/document/d/1UsyTYm67FXtcprku6F3L0WD48FjwTlgpDnC5Dj9kUGg/edit?ts=5df25614#heading=h.yy8m94syjcx2 |
6c06050
to
a9c1e0f
Compare
@parvathyvr I've updated the message to this
|
a9c1e0f
to
a5aabb8
Compare
frontend/packages/console-app/src/components/cloud-shell/CloudShell.tsx
Outdated
Show resolved
Hide resolved
message: ( | ||
<> | ||
This will close the terminal session. Content in the terminal will not be restored on next | ||
session. | ||
</> | ||
), |
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.
message: ( | |
<> | |
This will close the terminal session. Content in the terminal will not be restored on next | |
session. | |
</> | |
), | |
message: 'This will close the terminal session. Content in the terminal will not be restored on next session.', |
With this change, remove the React
import and rename file to use .ts
suffix.
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.
updated
@@ -40,7 +40,7 @@ describe('CloudShellDrawerComponent', () => { | |||
.find(Drawer) | |||
.shallow() | |||
.find(Button); | |||
expect(buttons.at(1).props()['aria-label']).toEqual('Close Terminal'); | |||
expect(buttons.at(1).props()['aria-label']).toEqual('Close terminal'); |
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.
This is where having a data-test-id
would be beneficial.
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.
using data-test-id
@@ -572,6 +573,7 @@ class MastheadToolbarContents_ extends React.Component { | |||
<PlusCircleIcon className="co-masthead-icon" /> | |||
</Button> | |||
</ToolbarItem> | |||
<CloudShellMastheadButton /> |
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.
Let's comment this out before merging because we need to fix the workspace namespace and resource name before it can be used.
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.
commented out
}); | ||
}; | ||
|
||
export default cloudshellConfirmationModal; |
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.
Rename file to not be uppercase because this does not export a react component.
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.
renamed
cb73eff
to
4f6a624
Compare
/test e2e-gcp-console |
); | ||
}; | ||
|
||
export default CloudShellTerminal; |
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.
This file is incorrectly named CloudshellTerminal.tsx
where it should be named CloudShellTerminal.tsx
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.
renamed
4f6a624
to
8682b77
Compare
8682b77
to
14e0cd4
Compare
/test e2e-gcp-console |
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.
@abhinandan13jan cloud shell is not minimizing properly
I wasnt able to see them, when I last tested....Let's take these as bugs related to CSS... as we have lot of Pending work in the epic... |
/lgtm
Please raise a Jira ticket for this |
https://issues.redhat.com/browse/ODC-3495 Added this for CSS refinement |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abhinandan13jan, christianvogt, sahil143 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
Feature:
https://issues.redhat.com/browse/ODC-3055
Analysis / Root cause:
Create Cloudshell Terminal Component, Icon & Feature Flag it
Solution Description:
Creates a set of components in console/app to create and launch a Terminal component integrated to Workspace component to start a cloudshell session.
Also, feature flags the whole setup to the presence of DevWorkspace CRD
Current Namespace Setting
Currently implementation creates and reads Workspace resource from dedicated namespace
che-controller-operator
, which needs to be updated as per final discussion.ScreenShots
( might take time to load )...
Unit tests:
Browser conformance:
Chrome 73
How to Review:
After pulling the code changes to local follow instructions at
https://github.com/che-incubator/che-workspace-operator
**Step 2: Add Icon **
TerminalIcon is commented out in masthead-toolbar... Bring the icon in by removing the comments