use of org.sonar.api.web.page.Page in project sonarqube by SonarSource.
the class SettingsAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
boolean isSysAdmin = userSession.isSystemAdministrator();
JsonWriter json = response.newJsonWriter().beginObject();
json.prop("showUpdateCenter", isSysAdmin && settings.getBoolean(WebConstants.SONAR_UPDATECENTER_ACTIVATE));
json.name("extensions").beginArray();
if (isSysAdmin) {
for (Page page : pageRepository.getGlobalPages(true)) {
json.beginObject().prop("key", page.getKey()).prop("name", page.getName()).endObject();
}
}
json.endArray();
json.endObject().close();
}
use of org.sonar.api.web.page.Page in project sonarqube by SonarSource.
the class GlobalActionTest method createPages.
private Page[] createPages() {
Page page = Page.builder("my_plugin/page").setName("My Plugin Page").build();
Page anotherPage = Page.builder("another_plugin/page").setName("My Another Page").build();
Page adminPage = Page.builder("my_plugin/admin_page").setName("Admin Page").setAdmin(true).build();
return new Page[] { page, anotherPage, adminPage };
}
use of org.sonar.api.web.page.Page in project sonarqube by SonarSource.
the class GlobalActionTest method init.
private void init(org.sonar.api.web.page.Page[] pages, ResourceTypeTree[] resourceTypeTrees) {
when(dbClient.getDatabase().getDialect()).thenReturn(new H2());
when(server.getVersion()).thenReturn("6.42");
PluginRepository pluginRepository = mock(PluginRepository.class);
when(pluginRepository.hasPlugin(anyString())).thenReturn(true);
PageRepository pageRepository = new PageRepository(pluginRepository, new PageDefinition[] { context -> {
for (Page page : pages) {
context.addPage(page);
}
} });
pageRepository.start();
ws = new WsActionTester(new GlobalAction(pageRepository, settings, new ResourceTypes(resourceTypeTrees), server, dbClient, organizationFlags));
}
use of org.sonar.api.web.page.Page in project sonarqube by SonarSource.
the class PageRepositoryTest method pages_from_different_page_definitions_ordered_by_key.
@Test
public void pages_from_different_page_definitions_ordered_by_key() {
PageDefinition firstPlugin = context -> context.addPage(Page.builder("my_plugin/K1").setName("N1").build()).addPage(Page.builder("my_plugin/K3").setName("N3").build());
PageDefinition secondPlugin = context -> context.addPage(Page.builder("my_plugin/K2").setName("N2").build());
underTest = new PageRepository(pluginRepository, new PageDefinition[] { firstPlugin, secondPlugin });
underTest.start();
List<Page> result = underTest.getAllPages();
assertThat(result).extracting(Page::getKey, Page::getName).containsExactly(tuple("my_plugin/K1", "N1"), tuple("my_plugin/K2", "N2"), tuple("my_plugin/K3", "N3"));
}
use of org.sonar.api.web.page.Page in project sonarqube by SonarSource.
the class PageRepositoryTest method filter_pages_without_qualifier.
@Test
public void filter_pages_without_qualifier() {
PageDefinition plugin = context -> context.addPage(Page.builder("my_plugin/K1").setName("N1").build()).addPage(Page.builder("my_plugin/K2").setName("N2").build()).addPage(Page.builder("my_plugin/K3").setName("N3").build());
underTest = new PageRepository(pluginRepository, new PageDefinition[] { plugin });
underTest.start();
List<Page> result = underTest.getGlobalPages(false);
assertThat(result).extracting(Page::getKey).containsExactly("my_plugin/K1", "my_plugin/K2", "my_plugin/K3");
}
Aggregations