-
Notifications
You must be signed in to change notification settings - Fork 251
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(job/log): add more details on a backup #2245
Conversation
src/xo-app/logs/index.js
Outdated
@@ -41,6 +42,18 @@ const jobKeyToLabel = { | |||
rollingSnapshot: _('rollingSnapshot') | |||
} | |||
|
|||
const formatSize = bytes => |
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.
Already defined in utils
.
src/xo-app/logs/index.js
Outdated
unit: 'B' | ||
}) | ||
|
||
const formatSpeed = (bytes, milliseconds) => |
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.
Move to utils
.
src/xo-app/logs/index.js
Outdated
@@ -70,9 +83,50 @@ class JobReturn extends Component { | |||
} | |||
} | |||
|
|||
class JobTransferredData extends 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.
Simple function.
src/xo-app/logs/index.js
Outdated
} | ||
|
||
class JobCallState extends Component { | ||
_renderInfos = () => this.props.error !== undefined |
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.
Inline.
src/xo-app/logs/index.js
Outdated
} | ||
} | ||
|
||
class JobCallState extends 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.
Simple function.
src/xo-app/logs/index.js
Outdated
} | ||
|
||
class JobCallState extends Component { | ||
_renderInfos = () => this.props.error !== undefined |
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.
Avoid calling it render*
when it doesn't render a component.
src/xo-app/logs/index.js
Outdated
return <div> | ||
<span><strong>{_('jobTransferredDataSize')}</strong>: {formatSize(size)} </span> | ||
<br /> | ||
<span><strong>{_('jobTransferredDataSpeed')}</strong>: {formatSpeed(size, end - start)} </span> |
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.
:
should be internationalized with the label.
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.
Extra spaces before </span>
s.
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.
The whole text should be i18n: use data interpolation
src/xo-app/logs/index.js
Outdated
? {icon: 'halted', tooltip: 'failedJobCall'} | ||
: end !== undefined | ||
? {icon: 'running', tooltip: 'successfulJobCall'} | ||
: {icon: 'busy', tooltip: 'jobCallInProgess'} |
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.
With array destructuring, the code is a bit lighter:
const [ icon, tooltip ] = error !== undefined
? [ 'halted', 'failedJobCalled' ]
: end !== undefined
? [ 'running', 'successfulJobCall' ]
: [ 'busy', tooltip: 'jobCallInProgress' ]
src/xo-app/logs/index.js
Outdated
const getJobTransferredDataInfos = (start, end, size) => <div> | ||
<span><strong>{_('jobTransferredDataSize')}</strong> {formatSize(size)}</span> | ||
<br /> | ||
<span><strong>{_('jobTransferredDataSpeed')}</strong> {formatSpeed(size, end - start)}</span> |
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.
Both the label and the value should be translatable because you have no guarantee that the order will stay the same in every languages.
We'll keep this as is for now but we'll have to fix this later.
src/xo-app/logs/index.js
Outdated
@@ -70,9 +73,33 @@ class JobReturn extends Component { | |||
} | |||
} | |||
|
|||
const getJobCallStateInfos = (end, error) => { |
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.
Functional component.
src/xo-app/logs/index.js
Outdated
</Tooltip> | ||
} | ||
|
||
const getJobTransferredDataInfos = (start, end, size) => <div> |
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.
Functional component.
src/xo-app/logs/index.js
Outdated
@@ -109,9 +109,9 @@ const Log = props => <ul className='list-group'> | |||
} | |||
|
|||
return <li key={call.callKey} className='list-group-item'> | |||
<strong className='text-info'>{call.method}: </strong>{getJobCallStateInfos(end, error)}<br /> | |||
<strong className='text-info'>{call.method}: </strong>{getJobCallStateInfos({ end, error })}<br /> |
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.
getJobCallStateInfos
should be React component, and named and used as such.
src/xo-app/logs/index.js
Outdated
{map(call.params, (value, key) => [ <JobParam id={value} paramKey={key} key={key} />, <br /> ])} | ||
{returnedValue != null && returnedValue.size !== undefined && getJobTransferredDataInfos({ start, end, size: returnedValue.size })} |
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.
Idem for getJobTransferredDataInfos
.
Fixes #2239