Merge "Preload edit and drafts REST requests"
This commit is contained in:
@@ -121,8 +121,9 @@ public class IndexHtmlUtil {
|
||||
}
|
||||
|
||||
/** Returns dynamic parameters of {@code index.html}. */
|
||||
public static Map<String, Map<String, SanitizedContent>> dynamicTemplateData(GerritApi gerritApi)
|
||||
public static Map<String, Object> dynamicTemplateData(GerritApi gerritApi)
|
||||
throws RestApiException {
|
||||
ImmutableMap.Builder<String, Object> data = ImmutableMap.builder();
|
||||
Gson gson = OutputFormat.JSON_COMPACT.newGson();
|
||||
Map<String, SanitizedContent> initialData = new HashMap<>();
|
||||
Server serverApi = gerritApi.config().server();
|
||||
@@ -141,14 +142,15 @@ public class IndexHtmlUtil {
|
||||
initialData.put(
|
||||
"\"/accounts/self/preferences.edit\"",
|
||||
serializeObject(gson, accountApi.getEditPreferences()));
|
||||
data.put("userIsAuthenticated", true);
|
||||
} catch (AuthException e) {
|
||||
logger.atFine().withCause(e).log(
|
||||
"Can't inline account-related data because user is unauthenticated");
|
||||
// Don't render data
|
||||
// TODO(hiesel): Tell the client that the user is not authenticated so that it doesn't have to
|
||||
// fetch anyway. This requires more client side modifications.
|
||||
}
|
||||
return ImmutableMap.of("gerritInitialData", initialData);
|
||||
|
||||
data.put("gerritInitialData", initialData);
|
||||
return data.build();
|
||||
}
|
||||
|
||||
/** Returns all static parameters of {@code index.html}. */
|
||||
|
||||
@@ -1661,7 +1661,7 @@
|
||||
endpoint: '/edit/',
|
||||
params,
|
||||
reportEndpointAsIs: true,
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
{@param? defaultDiffDetailHex: ?}
|
||||
{@param? preloadChangePage: ?}
|
||||
{@param? preloadDiffPage: ?}
|
||||
{@param? userIsAuthenticated: ?}
|
||||
<!DOCTYPE html>{\n}
|
||||
<html lang="en">{\n}
|
||||
<meta charset="utf-8">{\n}
|
||||
@@ -84,12 +85,21 @@
|
||||
{if $changeRequestsPath}
|
||||
{if $preloadChangePage and $defaultChangeDetailHex}
|
||||
<link rel="preload" href="{$canonicalPath}/{$changeRequestsPath}/detail?O={$defaultChangeDetailHex}" as="fetch" type="application/json" crossorigin="anonymous"/>{\n}
|
||||
{if $userIsAuthenticated}
|
||||
<link rel="preload" href="{$canonicalPath}/{$changeRequestsPath}/edit/?download-commands=true" as="fetch" type="application/json" crossorigin="anonymous"/>{\n}
|
||||
{/if}
|
||||
{/if}
|
||||
{if $preloadDiffPage and $defaultDiffDetailHex}
|
||||
<link rel="preload" href="{$canonicalPath}/{$changeRequestsPath}/detail?O={$defaultDiffDetailHex}" as="fetch" type="application/json" crossorigin="anonymous"/>{\n}
|
||||
{if $userIsAuthenticated}
|
||||
<link rel="preload" href="{$canonicalPath}/{$changeRequestsPath}/edit/" as="fetch" type="application/json" crossorigin="anonymous"/>{\n}
|
||||
{/if}
|
||||
{/if}
|
||||
<link rel="preload" href="{$canonicalPath}/{$changeRequestsPath}/comments" as="fetch" type="application/json" crossorigin="anonymous"/>{\n}
|
||||
<link rel="preload" href="{$canonicalPath}/{$changeRequestsPath}/robotcomments" as="fetch" type="application/json" crossorigin="anonymous"/>{\n}
|
||||
{if $userIsAuthenticated}
|
||||
<link rel="preload" href="{$canonicalPath}/{$changeRequestsPath}/drafts" as="fetch" type="application/json" crossorigin="anonymous"/>{\n}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
// RobotoMono fonts are used in styles/fonts.css
|
||||
|
||||
Reference in New Issue
Block a user