-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
preferences: improve category headers and leaf #8512
Conversation
@colin-grant-work would you like to review the pull-request? |
@vince-fugnitto, sure, I'll take a look later today. |
packages/preferences/src/browser/views/preference-editor-widget.tsx
Outdated
Show resolved
Hide resolved
packages/preferences/src/browser/util/preference-tree-generator.ts
Outdated
Show resolved
Hide resolved
packages/preferences/src/browser/util/preference-tree-generator.spec.ts
Outdated
Show resolved
Hide resolved
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.
@colin-grant-work / @vince-fugnitto, Can you please check my changes?
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 logic has not changed
We have two cases
Case 1: rawLeafValue exist:
Case 2: rawLeafValue does not exist:
The preferences behavior in Vs code is different than Theia however I believe that this PR is a step in the right direction. Can we merge this PR and define the new behavior in a new issue?
I agree your changes are an improvement, but I think we're pretty close to achieving the VSCode-type behavior and still may be able to in this PR:
Are there cases that I'm missing where we actually want to include more than the last part as the property name? If not, we can always just use the last segment, and discard the rest. |
We can of course have an iterative approach to fix the headers if it currently adds value. |
Signed-off-by: Lior Frenkel <lior.frenkel@sap.com>
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.
@colin-grant-work, Can you please check my changes?
const propertySpecifier = this.split(property).slice(1); | ||
const name = propertySpecifier.map(word => word.slice(0, 1).toLocaleUpperCase() + word.slice(1)).join(' ').trim(); | ||
const rawLeaf = property.split('.').pop(); | ||
const name = this.formatString(rawLeaf!); |
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.
Looks good to me. @vince-fugnitto, I'm a bit wary of the non-null assertion, but I've seen it elsewhere around the repo, and this seems like a fairly safe instance to me. What are your thoughts?
An option to avoid it would be to have .formatString
return an empty string when passed 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.
We could also do the following @colin-grant-work?
const rawLeaf: string = property.split('.').pop() || property;
const name = this.formatString(rawLeaf);
It would be a safeguard against preferences which do not follow the format of being a.b
but rather a
.
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 think it's functionally equivalent to the current code, but it would make Typescript happier 😄 . If there's no .
, then the split
will just return an array with the whole string at index 0.
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 think it's functionally equivalent to the current code, but it would make Typescript happier . If there's no
.
, then thesplit
will just return an array with the whole string at index 0.
Correct :) if you are wary about uses of it we can think about adding an eslint
rule against it: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-assertion.md. I believe it would benefit the project to be more strict regarding null
-checking.
@liorfr, the latest changes look good to me, and very close to VSCode. 👍 |
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 changes look good to me 👍
Thank you for your contribution and for also adding tests!
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.
@vince-fugnitto, can you please merge?
Sure, I just wanted to give it a couple of days to give others the opportunity to review if they were interested. |
Fixes issue: #7745
Before
After
How to test
Open the preferences
Signed-off-by: Lior Frenkel lior.frenkel@sap.com
Review checklist
Reminder for reviewers