-
Notifications
You must be signed in to change notification settings - Fork 358
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(SerialConsole): Introduce SerialConsole component #160
Conversation
7404aaf
to
6c3c50e
Compare
eac0cb4
to
f6985a3
Compare
Storybook and test will be written, so far looking for early comments. Reuse within Cockpit works fine. |
color: #f0f0f0; | ||
background: #000; | ||
} | ||
} |
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 done in less and sass and added to the appropriate directories (we will need to add the converter to this repo soon).
Colors should be from the patternfly palette.
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.
ok, css removed.
package.json
Outdated
"build:scripts": "babel src --out-dir dist/js --ignore test*.js,__mocks__", | ||
"build:less": "mkdir -p dist/less && cp -r less/* dist/less", | ||
"build:sass": "mkdir -p dist/sass && cp -r sass/patternfly-react/* dist/sass && node-sass --output-style compressed --include-path sass $npm_package_sassIncludes_patternfly $npm_package_sassIncludes_bootstrap $npm_package_sassIncludes_fontAwesome -o dist/css sass/patternfly-react.scss", | ||
"build:css": "mkdir -p dist/css && find ./src -name \\*.css -exec cp {} dist/css/ \\;", |
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 shouldn't have css in the components directories. We've standardized on both less and sass so that we can use variables which can then be overridden.
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.
ok, done
componentWillMount() { | ||
const term = new Terminal({ | ||
cols: this.props.cols || 80, | ||
rows: this.props.rows || 25, |
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 could be done using defaultProps
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.
done
textDisconnect = 'Disconnect', | ||
textDisconnected = 'Disconnected from serial console. Click the Reconnect button.', | ||
textLoading = 'Loading ...', | ||
textReconnect = 'Reconnect', |
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.
These need to be override-able by applications using I18N. See https://github.com/patternfly/patternfly-react/pull/162/files#diff-9694875e1ead42ed0c55964e603992b1R6 as an example on how to do this.
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.
That was the point here as well. Anyway, wrapped into the messages
prop to be consistent.
f6985a3
to
cef55cf
Compare
less/patternfly-react.less
Outdated
@@ -1,3 +1,62 @@ | |||
/** | |||
Patternfly React Specific Extensions | |||
*/ | |||
@import '~patternfly/dist/less/variables'; | |||
|
|||
/** Following is used by SerialConsole */ |
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.
What about introducing .less
files local to the component? Means like src/SerialConsole/styles.less
.
They would be listed in less/patternfly-react.less
for import.
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'd be ok with that if that's what we all agree on. Still need the sass version too though.
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.
Could you use a separate file here as well? Add this to serialConsole.less
and import the file here.
b62feef
to
4f28d65
Compare
Sass added |
4f28d65
to
3e30762
Compare
sass/patternfly-react.scss
Outdated
@@ -21,3 +21,61 @@ $icon-font-path: '~patternfly/dist/fonts/'; | |||
*/ | |||
|
|||
@import 'patternfly-react/patternfly-react'; | |||
|
|||
/** Following is used by SerialConsole */ |
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 go in sass/patternfly-react/_serialConsole.sass
and then add @import 'serialConsole'
to sass/patternfly-react/_patternfly-react.scss
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.
done
06a80f6
to
f8177b7
Compare
|
61e1b17
to
46c7821
Compare
Looking at this more closely, I'm not really sure it fits in this repository. There is no Patternfly pattern for this and no existing Patternfly styling for this. Might this be better as its own standalone component? react-serial-console for instance? |
@jeff-phillips-18 - we have discussed that components that are common to many patternfly users - we would like to keep under the patternfly organization, since this is the first one, we also agreed that initially we would keep it in this repo, and over time, extract to separate npm packages, so that users can upgrade as needed. /cc @serenamarie125 |
constructor(props) { | ||
super(props); | ||
|
||
this.focusTerminal = this.focusTerminal.bind(this); |
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 we use:
import { bindMethods } from '../../common/helpers';
instead?
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.
done, nice helper function :-)
this.props.onDisconnect(); | ||
} | ||
|
||
msg(key) { |
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 don't really get it... why not just use defaultProps
and specify the value? Maybe someone can explain this...
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.
Based on a previous review comment, I expect this is a pattern in this project. If not, the former direct use of props
seems to me more straightforward.
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.
done, defaultProps used instead
let terminal; | ||
let disconnectDisabled = 'disabled'; // CSS class name | ||
switch (status) { | ||
case 'connected': |
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.
maybe break out the statuses into a constants.js
or SerialConsoleConstants.js
?
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.
done
less/serialConsole.less
Outdated
SerialConsole styles | ||
*/ | ||
|
||
.console-ct > .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.
What is the -ct
? It should likely be -pf
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.
It's a leftover from original code. The .console-ct
is used for the top-most div
of the component, like a container.
The console-pf
in this case sounds good to me as well.
less/serialConsole.less
Outdated
line-height: normal; | ||
} | ||
|
||
@media (min-width: 568px) { |
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.
Would it still work if we used one of the bootstrap variables @screen-sm
or @screen-xs
or is there a reason for using 568?
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.
@screen-tablet
used instead due to deprecation of the others. Just verified, still works well.
less/serialConsole.less
Outdated
|
||
@media (min-width: 568px) { | ||
.console-ct { | ||
font-size: 12px; |
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.
@font-size-small
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.
done
@mareklibra from a design pattern perspective, what does this feature consist of ? Are the Disconnect/Reconnect buttons a part of the pattern? Since we don't have an existing PatternFly design, I'd like to make sure that I understand the use case and design of the pattern itself. Thanks! |
46c7821
to
873b3fd
Compare
@serenamarie125 , the component is planed to be part of a higher level one - serving all consoles. For better understanding, please have a look at screenshots in later comments of cockpit-project/cockpit#8234 . Regarding the
I would keep the control buttons in the pattern, they server common use cases:
|
Thanks @mareklibra Looks good! Wondering...
|
I just want to reiterate that the cockpit fork of term.js is not meant to be proliferated like that. As soon as xterm.js becomes suitable for Cockpit, we are going to move to that. So putting it as-is into PatternFly seems a bit ambitious to me. @mareklibra : For your purposes of sharing the component between software, wouldn't a new NPM project be more suitable? |
Rebased. |
Since implementation of the "monorepo" will still take some time plus additional will be needed to settle-down, can this PR be unblocked on it? The |
Approvals are received prior a couple of last rebases. |
@jgiardino this still has the cssreview tag on it. Can you take a look please? |
@mareklibra with the merge of #311, we've updated where the consoles code should live. Can you please update your code to be under https://github.com/patternfly/patternfly-react/tree/master/packages/console ? |
8030b56
to
e9597c8
Compare
Rebased and basically verified in Cockpit. Some of the original code was already copied from here to #311 . |
2b975e1
to
4a08e43
Compare
less/patternfly-react.less
Outdated
@@ -1,6 +1,9 @@ | |||
/** | |||
Patternfly React Specific Extensions | |||
*/ | |||
@import "~bootstrap/less/variables"; | |||
@import "~patternfly/dist/less/variables"; | |||
|
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 don't want to do this here. Patternfly is a dependency and we assume that these are already included if the project is building with the less files. If we do this here, it will overwrite any variables the application might have already overridden (which would likely be the reason to include the less files rather than the CSS).
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.
done
packages/console/less/console.less
Outdated
@@ -1,6 +1,9 @@ | |||
/** | |||
+ Styling shared by both VncConsole and SerialConsole. | |||
+*/ | |||
@import "~bootstrap/less/variables"; | |||
@import "~patternfly/dist/less/variables"; |
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.
Same comment as above.
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.
done
4a08e43
to
553ba2d
Compare
Please add the sass counterpart to the less styling. |
@jeff-phillips-18 , sass was one of the parts which was copied from this PR to #311 and committed there, track seems to be lost by this step. But should be up-to-date. Please correct me. Or do you suggest to extend the |
Ok, sorry @mareklibra , I didn't realize it was included with content in #311 |
constructor(props) { | ||
super(props); | ||
|
||
bindMethods(this, ['focusTerminal', 'onResetClick', 'onDisconnectClick']); |
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 have deprecated bindMethods
in favor of class properties.
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.
done
The SerialConsole component wraps the Terminal component [1] to access serial console (PTY) of a server or a virtual machine. Part of the code (like styling) was already committed within #4a69ebd806. [1] https://github.com/xtermjs/xterm.js
553ba2d
to
a4882c6
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.
LGTM, thanks @mareklibra !
Thanks. |
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.
Thanks @mareklibra trying to get another maintainer to review today
this looks great! thanks @mareklibra can #288 be closed now? or are you planning to revisit Vnc console after? |
No, it's follow-up for this adding VncConsole component. FYI., on top of the VncConsole PR, there will be others - for
|
Nice to see this merged :-) |
What: Provide reusable component to access serial console of a server/virtual machine
Link to Storybook: https://mareklibra.github.io/patternfly-react/
Additional issues:
Description:
The SerialConsole component wraps access to the Terminal component [1].
The component can be used to access serial console (PTY) of a server
or a virtual machine.
[1] https://github.com/xtermjs/xterm.js