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
113aa94
commit d77c2dd
Showing
9 changed files
with
212 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import jenkins from "@/util/jenkins"; | ||
|
||
export function getSymbol(symbol, handler) { | ||
jenkins.get("/symbols?symbol=" + symbol, function(res) { | ||
handler(res.data["symbol"]) | ||
}, {async: false}); | ||
jenkins.get( | ||
"/symbols?symbol=" + symbol, | ||
function (res) { | ||
handler(res.data["symbol"]); | ||
}, | ||
{ async: false } | ||
); | ||
} |
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
51 changes: 37 additions & 14 deletions
51
war/src/main/js/components/command-palette/datasources.js
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 |
---|---|---|
@@ -1,26 +1,49 @@ | ||
import {LinkResult} from "./models"; | ||
import { LinkResult } from "./models"; | ||
import Search from "@/api/search"; | ||
|
||
export const JenkinsSearchSource = { | ||
async execute(query) { | ||
const rootUrl = document.getElementById("page-header").dataset.rootUrl.escapeHTML(); | ||
const rootUrl = document | ||
.getElementById("page-header") | ||
.dataset.rootUrl.escapeHTML(); | ||
const response = await Search.search(query); | ||
return await response.json().then(data => { | ||
return [...data["suggestions"]].map(e => new LinkResult(e.icon, e.name, e.description, e.category, | ||
e.url.startsWith("/") ? `${rootUrl}${e.url}` : `${rootUrl}`)); | ||
return await response.json().then((data) => { | ||
return [...data["suggestions"]].map( | ||
(e) => | ||
new LinkResult( | ||
e.icon, | ||
e.name, | ||
e.description, | ||
e.category, | ||
e.url.startsWith("/") ? `${rootUrl}${e.url}` : `${rootUrl}` | ||
) | ||
); | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
|
||
export const SidebarSource = { | ||
async execute(query) { | ||
const sidebarLinks = document.querySelectorAll(".task-link"); | ||
|
||
return [...sidebarLinks] | ||
.filter(link => link.dataset.post !== "true") | ||
.filter(link => !link.classList.contains("task-link--active")) | ||
.filter(link => link.querySelector(".task-link-text").textContent.toLowerCase().includes(query.toLowerCase())) | ||
.map(link => new LinkResult(undefined, link.querySelector(".task-link-text").textContent, undefined, | ||
"Sidebar", link.href)); | ||
} | ||
} | ||
.filter((link) => link.dataset.post !== "true") | ||
.filter((link) => !link.classList.contains("task-link--active")) | ||
.filter((link) => | ||
link | ||
.querySelector(".task-link-text") | ||
.textContent.toLowerCase() | ||
.includes(query.toLowerCase()) | ||
) | ||
.map( | ||
(link) => | ||
new LinkResult( | ||
undefined, | ||
link.querySelector(".task-link-text").textContent, | ||
undefined, | ||
"Sidebar", | ||
link.href | ||
) | ||
); | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
// Group results by 'category' field into map | ||
function groupResultsByCategory(array) { | ||
return array | ||
.reduce((hash, obj) => { | ||
if (obj.category === undefined) return hash | ||
return Object.assign(hash, {[obj.category]: (hash[obj.category] || []).concat(obj)}) | ||
}, {}) | ||
return array.reduce((hash, obj) => { | ||
if (obj.category === undefined) {return hash;} | ||
return Object.assign(hash, { | ||
[obj.category]: (hash[obj.category] || []).concat(obj), | ||
}); | ||
}, {}); | ||
} | ||
|
||
export default {groupResultsByCategory: groupResultsByCategory}; | ||
export default { groupResultsByCategory: groupResultsByCategory }; |
Oops, something went wrong.