use of com.google.gerrit.extensions.client.MenuItem in project gerrit by GerritCodeReview.
the class GeneralPreferencesIT method getAndSetPreferences.
@Test
public void getAndSetPreferences() throws Exception {
GeneralPreferencesInfo o = gApi.accounts().id(user42.id.toString()).getPreferences();
assertPrefs(o, GeneralPreferencesInfo.defaults(), "my", "changeTable");
assertThat(o.my).hasSize(7);
assertThat(o.changeTable).isEmpty();
GeneralPreferencesInfo i = GeneralPreferencesInfo.defaults();
// change all default values
i.changesPerPage *= -1;
i.showSiteHeader ^= true;
i.useFlashClipboard ^= true;
i.downloadCommand = DownloadCommand.REPO_DOWNLOAD;
i.dateFormat = DateFormat.US;
i.timeFormat = TimeFormat.HHMM_24;
i.emailStrategy = EmailStrategy.DISABLED;
i.emailFormat = EmailFormat.PLAINTEXT;
i.defaultBaseForMerges = DefaultBase.AUTO_MERGE;
i.expandInlineDiffs ^= true;
i.highlightAssigneeInChangeTable ^= true;
i.relativeDateInChangeTable ^= true;
i.sizeBarInChangeTable ^= true;
i.legacycidInChangeTable ^= true;
i.muteCommonPathPrefixes ^= true;
i.signedOffBy ^= true;
i.reviewCategoryStrategy = ReviewCategoryStrategy.ABBREV;
i.diffView = DiffView.UNIFIED_DIFF;
i.my = new ArrayList<>();
i.my.add(new MenuItem("name", "url"));
i.changeTable = new ArrayList<>();
i.changeTable.add("Status");
i.urlAliases = new HashMap<>();
i.urlAliases.put("foo", "bar");
o = gApi.accounts().id(user42.getId().toString()).setPreferences(i);
assertPrefs(o, i, "my");
assertThat(o.my).hasSize(1);
assertThat(o.changeTable).hasSize(1);
}
use of com.google.gerrit.extensions.client.MenuItem in project gerrit by GerritCodeReview.
the class SetPreferences method storeMyMenus.
public static void storeMyMenus(VersionedAccountPreferences prefs, List<MenuItem> my) {
Config cfg = prefs.getConfig();
if (my != null) {
unsetSection(cfg, UserConfigSections.MY);
for (MenuItem item : my) {
set(cfg, item.name, KEY_URL, item.url);
set(cfg, item.name, KEY_TARGET, item.target);
set(cfg, item.name, KEY_ID, item.id);
}
}
}
use of com.google.gerrit.extensions.client.MenuItem in project gerrit by GerritCodeReview.
the class GeneralPreferencesLoader method my.
private static List<MenuItem> my(VersionedAccountPreferences v) {
List<MenuItem> my = new ArrayList<>();
Config cfg = v.getConfig();
for (String subsection : cfg.getSubsections(UserConfigSections.MY)) {
String url = my(cfg, subsection, KEY_URL, "#/");
String target = my(cfg, subsection, KEY_TARGET, url.startsWith("#") ? null : "_blank");
my.add(new MenuItem(subsection, url, target, my(cfg, subsection, KEY_ID, null)));
}
return my;
}
use of com.google.gerrit.extensions.client.MenuItem in project gerrit by GerritCodeReview.
the class GeneralPreferencesLoader method loadMyMenusAndUrlAliases.
public GeneralPreferencesInfo loadMyMenusAndUrlAliases(GeneralPreferencesInfo r, VersionedAccountPreferences v, VersionedAccountPreferences d) {
r.my = my(v);
if (r.my.isEmpty() && !v.isDefaults()) {
r.my = my(d);
}
if (r.my.isEmpty()) {
r.my.add(new MenuItem("Changes", "#/dashboard/self", null));
r.my.add(new MenuItem("Drafts", "#/q/owner:self+is:draft", null));
r.my.add(new MenuItem("Draft Comments", "#/q/has:draft", null));
r.my.add(new MenuItem("Edits", "#/q/has:edit", null));
r.my.add(new MenuItem("Watched Changes", "#/q/is:watched+is:open", null));
r.my.add(new MenuItem("Starred Changes", "#/q/is:starred", null));
r.my.add(new MenuItem("Groups", "#/groups/self", null));
}
r.urlAliases = urlAliases(v);
if (r.urlAliases == null && !v.isDefaults()) {
r.urlAliases = urlAliases(d);
}
return r;
}
Aggregations