Package org.sonar.api.web.page
Interface PageDefinition
-
@ServerSide @ExtensionPoint public interface PageDefinition
Defines the Javascript pages added to SonarQube.
This interface replaces the deprecated classPage. Moreover, the technology changed from Ruby to Javascript
How to define pages
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()); } }How to test a page definition
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"); }- Since:
- 6.3
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddefine(Context context)This method is executed when server is started
-
-
-
Method Detail
-
define
void define(Context context)
This method is executed when server is started
-
-