Merge branch 'stable-2.16' into stable-3.0
* stable-2.16: OutgoingEmail: Use UrlFormatter to get settings URL CommentSender: Use UrlFormatter to get URLs for file and comments Elasticsearch: Base the default number of shards on ES version Disallow change index task duplication AbstractPushForReview: Add tests for pushing with skip-validation option Set version to 2.16.10-SNAPSHOT Set version to 2.16.9 Documentation: Fix the Elasticsearch shards/replicas link ProjectControl: Allow regexes ref strings for uploads ProjectControl: Allow regexes ref strings for tags ProjectControl: Reuse constants for ref strings Add extension point to gr-user-header Change-Id: I6a38b9bfdc2bcbb8c457ce24883767f4579ca656
This commit is contained in:
@@ -47,10 +47,32 @@ public interface UrlFormatter {
|
||||
return getWebUrl().map(url -> url + "c/" + project.get() + "/+/" + id.get());
|
||||
}
|
||||
|
||||
/** Returns the URL for viewing a file in a given patch set of a change. */
|
||||
default Optional<String> getPatchFileView(Change change, int patchsetId, String filename) {
|
||||
return getChangeViewUrl(change.getProject(), change.getId())
|
||||
.map(url -> url + "/" + patchsetId + "/" + filename);
|
||||
}
|
||||
|
||||
/** Returns the URL for viewing a comment in a file in a given patch set of a change. */
|
||||
default Optional<String> getInlineCommentView(
|
||||
Change change, int patchsetId, String filename, short side, int startLine) {
|
||||
return getPatchFileView(change, patchsetId, filename)
|
||||
.map(url -> url + String.format("@%s%d", side == 0 ? "a" : "", startLine));
|
||||
}
|
||||
|
||||
/** Returns a URL pointing to a section of the settings page. */
|
||||
default Optional<String> getSettingsUrl() {
|
||||
return getWebUrl().map(url -> url + "settings");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL pointing to a section of the settings page, or the settings page if {@code
|
||||
* section} is null.
|
||||
*/
|
||||
default Optional<String> getSettingsUrl(@Nullable String section) {
|
||||
return getWebUrl()
|
||||
.map(url -> url + "settings" + (Strings.isNullOrEmpty(section) ? "" : "#" + section));
|
||||
return Strings.isNullOrEmpty(section)
|
||||
? getSettingsUrl()
|
||||
: getSettingsUrl().map(url -> url + "#" + section);
|
||||
}
|
||||
|
||||
/** Returns a URL pointing to a documentation page, at a given named anchor. */
|
||||
|
Reference in New Issue
Block a user