@ServerSide @ExtensionPoint public interface PageDefinition
Page. Moreover, the technology changed from Ruby to Javascript
import org.sonar.api.web.page.Page.Qualifier;
public class MyPluginPagesDefinition implements PagesDefinition {
@Override
public void define(Context context) {
context
// Global page by default
.addPage(Page.builder("my_plugin/global_page").setName("Global Page").build())
// Global admin page
.addPage(Page.builder("my_plugin/global_admin_page").setName("Admin Global Page").setAdmin(true).build())
// Project page
.addPage(Page.builder("my_plugin/project_page").setName("Project Page").setScope(Scope.COMPONENT).setQualifiers(Qualifier.PROJECT).build())
// Admin project or module page
.addPage(Page.builder("my_plugin/project_admin_page").setName("Admin Page for Project or Module").setAdmin(true)
.setScope(Scope.COMPONENT).setQualifiers(Qualifier.PROJECT, Qualifier.MODULE).build())
// Page on all components (see Qualifier class) supported
.addPage(Page.builder("my_plugin/component_page").setName("Component Page").setScope(Scope.COMPONENT).build());
// Organization page (when organizations are enabled)
.addPage(Page.builder("my_plugin/org_page").setName("Organization Page").setScope(Scope.ORGANIZATION).build());
}
}
public class PageDefinitionTest {
@Test
public void test_page_definition() {
PageDefinition underTest = context -> context.addPage(Page.builder("my_plugin/my_page").setName("My Page").build());
Context context = new Context();
underTest.define(context);
assertThat(context.getPages()).extracting(Page::getKey).contains("my_plugin/my_page");
}
| Modifier and Type | Method and Description |
|---|---|
void |
define(Context context)
This method is executed when server is started
|
Copyright © 2009–2017 SonarSource. All rights reserved.