All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.api.web.page.PageDefinition Maven / Gradle / Ivy

There is a newer version: 10.5.0.78949
Show newest version
/*
 * SonarQube
 * Copyright (C) 2009-2021 SonarSource SA
 * mailto:info AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.sonar.api.web.page;

import org.sonar.api.ExtensionPoint;
import org.sonar.api.server.ServerSide;

/**
 * Defines the Javascript pages added to SonarQube.
 * 
* This interface replaces the deprecated class {@link org.sonar.api.web.Page}. 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 {
 *  {@literal @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 {
 *     {@literal @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 */ @ServerSide @ExtensionPoint public interface PageDefinition { /** * This method is executed when server is started */ void define(Context context); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy