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

[Code] diff page #46714

Merged
merged 3 commits into from
Oct 21, 2019
Merged

[Code] diff page #46714

merged 3 commits into from
Oct 21, 2019

Conversation

WangQianliang
Copy link
Contributor

@WangQianliang WangQianliang commented Sep 26, 2019

Summary

image
image

Checklist

Use strikethroughs to 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 accessibility

For 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

@WangQianliang WangQianliang added v8.0.0 Team:Code release_note:skip Skip the PR/issue when compiling release notes v7.5.0 labels Sep 26, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/code

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@WangQianliang WangQianliang marked this pull request as ready for review October 10, 2019 14:04
@WangQianliang WangQianliang requested a review from a team as a code owner October 10, 2019 14:04
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@WangQianliang
Copy link
Contributor Author

@mw-ding @daveyholler @rylnd Please take a look

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@mw-ding mw-ding left a 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:

  • too much blank space for small files
    image

  • 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?

image
I feel like these 2 lines should be differentiated more here.

Copy link
Contributor

@rylnd rylnd left a 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}`;
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks!

Copy link
Contributor

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.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@WangQianliang
Copy link
Contributor Author

image
This red area is a diff overview, sadly I didn't find a way to remove this.

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@rylnd rylnd left a 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}`;
Copy link
Contributor

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: {
Copy link
Contributor

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

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 {
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

💔 Build Failed

@WangQianliang WangQianliang requested a review from rylnd October 17, 2019 13:36
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@daveyholler daveyholler left a 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. 🤷‍♂

@rylnd
Copy link
Contributor

rylnd commented Oct 17, 2019

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.

@WangQianliang
Copy link
Contributor Author

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 display: none would do.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@rylnd
Copy link
Contributor

rylnd commented Oct 18, 2019

Override the css to display: none would do.

Oh, well, that's cheating 😜

Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@mw-ding mw-ding left a 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}`;
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

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}`;
Copy link
Contributor

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@WangQianliang WangQianliang merged commit d5cbb47 into elastic:master Oct 21, 2019
@WangQianliang WangQianliang deleted the code-enable-diff-page branch October 21, 2019 04:55
WangQianliang pushed a commit that referenced this pull request Oct 21, 2019
* fix(code/frontend): enable diff page
WangQianliang pushed a commit that referenced this pull request Oct 21, 2019
* fix(code/frontend): enable diff page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.5.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants