Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1769284 - Show phabricator links in user_profile
- Loading branch information
Showing
4 changed files
with
144 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* This Source Code Form is "Incompatible With Secondary Licenses", as | ||
* defined by the Mozilla Public License, v. 2.0. | ||
*/ | ||
|
||
var PhabUser = {}; | ||
|
||
PhabUser.getUser = async () => { | ||
var userCell = document.getElementById("phab_user"); | ||
var revisionsCell = document.getElementById("phab_revisions"); | ||
if (!userCell || !revisionsCell) { | ||
return; | ||
} | ||
|
||
var user_id = userCell.getAttribute("data-target-user-id"); | ||
|
||
userCell.textContent = "Loading..."; | ||
revisionsCell.textContent = "Loading..."; | ||
|
||
function displayLoadError(errStr) { | ||
userCell.textContent = errStr; | ||
revisionsCell.textContent = ""; | ||
} | ||
|
||
try { | ||
var { user } = await Bugzilla.API.get(`phabbugz/user/${user_id}`); | ||
if (!user) { | ||
userCell.textContent = "Not Found"; | ||
revisionsCell.textContent = "Not Found"; | ||
return; | ||
} | ||
|
||
var userLink = document.createElement("a"); | ||
userLink.setAttribute("href", user.userURL); | ||
userLink.textContent = `${user.userName} (${user.realName})`; | ||
userCell.textContent = ""; | ||
userCell.appendChild(userLink); | ||
|
||
var revisionsLink = document.createElement("a"); | ||
revisionsLink.setAttribute("href", user.revisionsURL); | ||
revisionsLink.textContent = "Open revisions"; | ||
revisionsCell.textContent = ""; | ||
revisionsCell.appendChild(revisionsLink); | ||
} catch ({ message }) { | ||
displayLoadError('Error: ' + message); | ||
} | ||
}; | ||
|
||
document.addEventListener("DOMContentLoaded", function(event) { | ||
PhabUser.getUser(); | ||
}); |
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