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
feature: Implement Search Settings Ability #416
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fc1ebbd
Initial setup of new pane, testing settings list items
confused-Techie ba9c93f
More realize setup
confused-Techie 0980109
All final aspects to make functional
confused-Techie a6d27ed
Moved things around a bit to make testing easier, adding some tests, …
confused-Techie 61903ae
Resolve failing spec
confused-Techie b1ced99
Custom styling, include package name, pull out `getSettingTitle` fro…
confused-Techie edf8092
Modify bonus' on search
confused-Techie 794247a
Add Icon next to setting namespace
confused-Techie a000fee
Switched which side the package icon appears
confused-Techie f8ed84a
Some settings filters, display search score, configurable meta
confused-Techie 49461e5
Parse search text by normalizing all text data, not just package entries
confused-Techie aa0c192
Hide new feature behind `enableSettingsSearch` toggle
confused-Techie 7c6546f
Enable the feature by default, add warning in panel
confused-Techie 75d051b
Final stylistic choices on warning
confused-Techie 6575748
Final Final stylistic choices for the warning
confused-Techie dbb40bb
Merge branch 'master' into search-settings
confused-Techie File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const _ = require("underscore-plus") | ||
|
||
module.exports = { | ||
getSettingTitle (keyPath, name) { | ||
if (name == null) { | ||
name = '' | ||
} | ||
const schema = atom.config.getSchema(keyPath) | ||
const title = schema != null ? schema.title : null | ||
return title || _.uncamelcase(name).split('.').map(_.capitalize).join(' ') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** @babel */ | ||
/** @jsx etch.dom */ | ||
|
||
import etch from 'etch' | ||
import { shell } from 'electron' | ||
import { Disposable, CompositeDisposable } from 'atom' | ||
import { getSettingTitle } from './rich-title' | ||
|
||
export default class SearchSettingView { | ||
constructor(setting, settingsView) { | ||
this.settingsView = settingsView | ||
this.setting = setting | ||
this.disposables = new CompositeDisposable() | ||
|
||
etch.initialize(this) | ||
|
||
this.handleButtonEvents() | ||
} | ||
|
||
render () { | ||
const title = this.setting.title ?? getSettingTitle(this.setting.path, this.setting.path.split(".")[1]); | ||
const path = atom.config.get("settings-view.searchSettingsMetadata") ? this.setting.path + ": " : ""; | ||
const description = this.setting.description ?? ""; | ||
const packageName = this.setting.path.split(".")[0]; | ||
const icon = this.getIcon(packageName); | ||
const score = atom.config.get("settings-view.searchSettingsMetadata") ? this.setting.rank.totalScore.toFixed(2) + " Search Score" : ""; | ||
|
||
return ( | ||
<div className='search-result col-lg-8'> | ||
<span className='search-package-name pull-right'> | ||
<span className={icon}></span> | ||
{packageName} | ||
</span> | ||
<div className='body'> | ||
<h4 className='card-name'> | ||
<a ref='settingLink'> | ||
<span className='search-name'>{title}</span> | ||
<span className='search-id'>{path}{score}</span> | ||
</a> | ||
</h4> | ||
<span className='search-description'>{description}</span> | ||
|
||
</div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
update () {} | ||
|
||
destroy () { | ||
this.disposables.dispose() | ||
return etch.destroy(this) | ||
} | ||
|
||
getIcon(namespace) { | ||
// Takes a setting namespace and returns the appropriate icon for it. | ||
switch(namespace) { | ||
case "core": | ||
return "icon icon-settings search-result-icon"; | ||
break; | ||
case "editor": | ||
return "icon icon-code search-result-icon"; | ||
break; | ||
default: | ||
return "icon icon-package search-result-icon"; | ||
break; | ||
} | ||
} | ||
|
||
handleButtonEvents () { | ||
const settingsClickHandler = (event) => { | ||
event.stopPropagation() | ||
|
||
// Lets check if the setting we want to open is built in or from a package | ||
const settingLocation = this.setting.path.split(".")[0] | ||
// The above is the location where the setting exists, such as Core, or a packages name | ||
|
||
switch(settingLocation) { | ||
case "core": | ||
// There are some special cases of settings broken off into other panels | ||
let settingName = this.setting.path.split(".")[1] | ||
if (settingName === 'uriHandlerRegistration') { | ||
// the URI handler doesn't have any registered uri to actually reach it | ||
// funnily enough. So we will prompt a notification to go there | ||
atom.notifications.addInfo("Sorry, Pulsar is unable to link to this setting. Please select 'URI Handling' on the sidebar.") | ||
} else { | ||
atom.workspace.open("atom://config/core") | ||
} | ||
break; | ||
case "editor": | ||
atom.workspace.open("atom://config/editor") | ||
break; | ||
default: | ||
// The handling for any packages name | ||
atom.workspace.open(`atom://config/packages/${settingLocation}`) | ||
break; | ||
} | ||
} | ||
|
||
this.refs.settingLink.addEventListener('click', settingsClickHandler) | ||
this.disposables.add(new Disposable(() => { this.refs.settingLink.removeEventListener('click', settingsClickHandler) })) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is there a difference between builtin packages and installed packages that makes installed packages not work?
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.
Surprisingly the URI for the settings page of all packages is exactly the same. Made sure this functioned for either the core packages or community packages.
Only thing not explicitly tested for is Git installed packages, but I'd imagine they should work as well, especially since the
settings-view
showPackage()
function is written identically.But of course anyone with Git installed packages on their system could double check by navigating to this URI format in the browser and letting it open up Pulsar
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've been using the package-settings package for ages in order to jump quickly to a given package's settings, and this is the exact method that package uses. Never observed it not to work, no matter how a package is installed.
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.
Ah I got confused, that's relieving. I think for clarity, the packages caveat means:
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.
Ahh I see how that can be confusing. Yeah just means it's not the search that's available on the "Packages" pane, as in it won't accomplish the same thing.
(Although technically you could search by package name to help bring your package up, but it will only show results for packages that have settings. As the name of the package is considered when doing a search. But this makes the whole thing a little confusing, so though it was easier to say it doesn't search for packages)