-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Code] diff page #46714
[Code] diff page #46714
Conversation
Pinging @elastic/code |
💔 Build Failed |
💔 Build Failed
|
💔 Build Failed
|
💔 Build Failed
|
💔 Build Failed
|
💚 Build Succeeded
|
💚 Build Succeeded
|
💚 Build Succeeded
|
💚 Build Succeeded
|
💚 Build Succeeded
|
@mw-ding @daveyholler @rylnd Please take a look |
💚 Build Succeeded
|
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.
Mostly good. A couple of comments below:
-
I know it's intended to rendering diff in monaco editor to be able to scroll horizontally and vertically, but it's a bit weird to behave in this way. Not a blocking issue for this PR, but let's confirm on our next week's design sync.
-
@daveyholler should we have different styles for the commit message area?
I feel like these 2 lines should be differentiated more here.
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.
Besides my inline comments, I've got a few broad style comments, mostly echoing what @mw-ding said:
- text feels a little cramped
- colors are inconsistent, e.g. +++/--- are not the same hues as the line highlights and so aren't strongly correlated
- Do we want/need the minimap here? It feels like noise to me, and I don't think any other monaco instances use it.
- There's a lot of gray and it's sort of distracting. Part of it's the minimap, but even the striped background is a little dark to me.
I'll defer to @daveyholler for the final say on style stuff, of course.
@@ -55,7 +54,7 @@ const revisionLinkLabel = i18n.translate('xpack.code.commits.revisionLinkAriaLab | |||
}); | |||
|
|||
const CommitActions = ({ commitId, repoUri }: ActionProps) => { | |||
const revisionPath = `#/${repoUri}/${PathTypes.tree}/${commitId}`; | |||
const revisionPath = `#/${repoUri}/commit/${commitId}`; |
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 we add a PathType
for this new path, or is that stuff going away? I know we've been alluding to some more robust path-generation helpers, but I'm not sure where we landed.
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.
commit
is not one of the PathTypes
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.
So what is the purpose of PathTypes
? I would have thought that this new diff page would be represented in that enum, unless PathTypes
itself is deprecated.
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.
PathTypes
defines different path types in source view page whose URIs share the same structure as /$repoUri/.../$filePath
, while diff page is a different page.
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.
Got it, 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.
I would suggest to add a frontend flag (e.g. enableDiffPage
) in here with default value false
before we expose this page into the main app.
x-pack/legacy/plugins/code/public/components/commits/commit_link.tsx
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/code/public/components/commits/commit_link.tsx
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/code/public/components/diff_page/diff.scss
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
|
💔 Build Failed
|
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.
@WangQianliang a few more things here:
-
Please try not to alter the commit history during a review; it makes it very hard to determine what has changed since the reviewer last saw things.
-
Header still needs to call out the commit message better; maybe just more font-weight and some bottom margin? (cc @daveyholler)
-
The red/green colors should be consistent. I would find two colors in EUI, and use those with the
lighten
function in our CSS. -
some minor rebase issues
@@ -55,7 +54,7 @@ const revisionLinkLabel = i18n.translate('xpack.code.commits.revisionLinkAriaLab | |||
}); | |||
|
|||
const CommitActions = ({ commitId, repoUri }: ActionProps) => { | |||
const revisionPath = `#/${repoUri}/${PathTypes.tree}/${commitId}`; | |||
const revisionPath = `#/${repoUri}/commit/${commitId}`; |
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.
So what is the purpose of PathTypes
? I would have thought that this new diff page would be represented in that enum, unless PathTypes
itself is deprecated.
@@ -26,6 +26,21 @@ export class MonacoDiffEditor { | |||
enableSplitViewResizing: false, | |||
renderSideBySide: this.renderSideBySide, | |||
scrollBeyondLastLine: false, | |||
readOnly: true, | |||
minimap: { |
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 also had no luck hiding the overview. However, it might be worth adding overviewRulerBorder: false
to cut down slightly on the noise that it adds.
|
||
.monaco-diff-editor .line-insert, | ||
.monaco-diff-editor .char-insert { | ||
background-color: rgba(0, 179, 164, 0.1); |
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.
You should use the lighten
function on an $euiColor variable here, to make its origin and intention more apparent.
Also, the deletion color is much more purple than red (I think you're just using the default EuiBadge
color?), and if we're overriding one to be green we might as well override the other to be red.
} | ||
|
||
.codeBlock__line--highlighted { | ||
background-color: $euiColorLightShade; | ||
} | ||
|
||
.code-monaco-highlight-line { |
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 styles were deleted on master, I don't think you want to re-add them here. Same with .code-mark-line-number
💔 Build Failed
|
💚 Build Succeeded
|
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 opened up a PR against your branch. https://github.com/WangQianliang/kibana/pull/1
I agree with Ryland on the styling in the actual diff panels. We should bring those colors more in line with the colors used on the badges. In addition to the lighten()
SCSS method, there's also a tintOrShade()
that you can use from EUI that could help get there.
Regarding that overview, I was able to hide it, but it leaves empty space in its place which is arguably worse. 🤷♂
@daveyholler How did you do it?! I could not figure out a configuration that did so. |
Override the css to |
💚 Build Succeeded
|
Oh, well, that's cheating 😜 |
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!
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.
Approved to move this PR forward. As I mentioned in the comment, please add a frontend flag with default value false
to control if the commit message will link to this Diff page, mostly because it's still not 100% sure if we would like to release the current diff view component based on Monaco editor.
@@ -318,7 +318,7 @@ export class GitOperations { | |||
const git = await this.openGit(uri); | |||
const commit = await this.getCommitOr404(uri, revision); | |||
if (!revision.includes('..')) { | |||
revision = `${revision}..${revision}~1`; | |||
revision = `${revision}~1..${revision}`; |
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 you double check on 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.
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.
Strictly speaking, doesn’t this just compare the commit to its first parent? If it’s a squashed PR that will be pre-merge master, but I can imagine a lot of cases where that wouldn’t be the case.
If we truly want to compare to master, we should explicitly use that, or do something a little fancier with git merge-base
@@ -55,7 +54,7 @@ const revisionLinkLabel = i18n.translate('xpack.code.commits.revisionLinkAriaLab | |||
}); | |||
|
|||
const CommitActions = ({ commitId, repoUri }: ActionProps) => { | |||
const revisionPath = `#/${repoUri}/${PathTypes.tree}/${commitId}`; | |||
const revisionPath = `#/${repoUri}/commit/${commitId}`; |
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 would suggest to add a frontend flag (e.g. enableDiffPage
) in here with default value false
before we expose this page into the main app.
💔 Build Failed
|
💚 Build Succeeded
|
💚 Build Succeeded |
Summary
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] This was checked for cross-browser compatibility, including a check against IE11- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)- [ ] Documentation was added for features that require explanation or tutorials- [ ] Unit or functional tests were updated or added to match the most common scenarios- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
- [ ] This was checked for breaking API changes and was labeled appropriately- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately