forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cb4af6
commit 684997d
Showing
10 changed files
with
121 additions
and
73 deletions.
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
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
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
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,10 @@ | ||
// Group suggestions by 'category' field into map | ||
function groupByKey(array, key) { | ||
return array | ||
.reduce((hash, obj) => { | ||
if (obj[key] === undefined) return hash | ||
return Object.assign(hash, {[obj[key]]: (hash[obj[key]] || []).concat(obj)}) | ||
}, {}) | ||
} | ||
|
||
export default {groupByKey: groupByKey}; |
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,35 @@ | ||
import * as Symbols from "./symbols"; | ||
|
||
class Result { | ||
constructor(icon, label, description, category) { | ||
this.icon = icon; | ||
this.label = label; | ||
this.description = description; | ||
this.category = category; | ||
console.log(this.icon) | ||
} | ||
render() { | ||
return `<button class="jenkins-command-palette__results__item"> | ||
<div class="jenkins-command-palette__results__item__icon">${this.icon}"}</div> | ||
${this.label} | ||
${this.description ? `<span class="jenkins-command-palette__results__item__description">${this.description}</span>` : ``} | ||
${Symbols.CHEVRON_RIGHT} | ||
</button>` | ||
} | ||
} | ||
|
||
export class LinkResult extends Result { | ||
constructor(icon, label, description, category, url, isExternal) { | ||
super(icon, label, description, category); | ||
this.url = url; | ||
this.isExternal = isExternal; | ||
} | ||
render() { | ||
return `<a class="jenkins-command-palette__results__item" href="${this.url}"> | ||
<div class="jenkins-command-palette__results__item__icon">${this.icon ? `${this.icon.svg ? this.icon.svg : `<img src="${this.icon.url}" alt="" />`}` : ``}</div> | ||
${this.label} | ||
${this.description ? `<span class="jenkins-command-palette__results__item__description">${this.description}</span>` : ``} | ||
${this.isExternal ? Symbols.EXTERNAL_LINK : Symbols.CHEVRON_RIGHT} | ||
</a>` | ||
} | ||
} |
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,13 @@ | ||
import CommandPaletteHelpers from "./helpers"; | ||
import {LinkResult} from "./models"; | ||
import Search from "@/api/search"; | ||
|
||
async function getResults(query) { | ||
const response = await Search.search(query); | ||
return await response.json().then(data => { | ||
const results = [...data["suggestions"]].map(e => new LinkResult(e.icon, e.name, e.description, e.category, e.url)); | ||
return CommandPaletteHelpers.groupByKey(results, "category"); | ||
}); | ||
} | ||
|
||
export default {getResults: getResults} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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