Search in sources :

Example 1 with NavigationBar

use of io.sunshower.zephyr.ui.navigation.NavigationBar in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureRegisteringSimpleComponentWorks.

@ViewTest
@DirtiesContext
void ensureRegisteringSimpleComponentWorks(@Autowired UserInterface ui, @Context TestContext $) {
    val extension = new DefaultComponentExtension<>(":management-menu", (NavigationBar parent) -> {
        val button = spy(new Button("Hello"));
        parent.add(button);
    });
    var button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
    assertFalse(button.isPresent());
    val registration = ui.register(Selection.path(":main:navigation"), extension);
    $.flush();
    val menu = ui.selectFirst(Selection.path(":main:navigation:management-menu"));
    assertNotNull(menu);
    button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
    assertTrue(button.isPresent());
    registration.close();
    $.flush(true);
    assertEquals(0, ui.getExtensionRegistry().getExtensionCount());
    button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
    assertFalse(button.isPresent());
}
Also used : lombok.val(lombok.val) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Button(com.vaadin.flow.component.button.Button) DefaultComponentExtension(com.aire.ux.DefaultComponentExtension) DirtiesContext(org.springframework.test.annotation.DirtiesContext) ViewTest(com.aire.ux.test.ViewTest)

Example 2 with NavigationBar

use of io.sunshower.zephyr.ui.navigation.NavigationBar in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureRegistrationWorksWithComponents.

@ViewTest
@DirtiesContext
void ensureRegistrationWorksWithComponents(@Context TestContext $, @Autowired UserInterface userInterface) {
    val registration = userInterface.register(Selection.path(":main-2:navbar"), Extensions.create(":sup", (@NonNull NavigationBar b) -> {
        b.add(new Button("hello"));
    }));
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
    val reg2 = userInterface.register(Mode.Global, MainNavigationComponent.class);
    $.navigate(MainNavigationComponent.class);
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isPresent());
    registration.close();
    $.navigate(MainView.class);
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
    $.navigate(MainNavigationComponent.class);
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
    reg2.remove();
}
Also used : lombok.val(lombok.val) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Button(com.vaadin.flow.component.button.Button) DirtiesContext(org.springframework.test.annotation.DirtiesContext) ViewTest(com.aire.ux.test.ViewTest)

Example 3 with NavigationBar

use of io.sunshower.zephyr.ui.navigation.NavigationBar in project aire-components by aire-ux.

the class ApplicationLayout method createNavigation.

protected HasComponents createNavigation() {
    val navigation = new NavigationBar(Direction.Vertical);
    navigation.setDrawer(new Drawer(Drawer.Direction.Vertical));
    return navigation;
}
Also used : lombok.val(lombok.val) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Drawer(io.sunshower.zephyr.ui.components.Drawer)

Example 4 with NavigationBar

use of io.sunshower.zephyr.ui.navigation.NavigationBar in project aire-components by aire-ux.

the class AbstractModuleView method createNavigationBar.

/**
 * protected members
 */
/**
 * @return the navigation bar for this module view
 */
protected NavigationBar createNavigationBar() {
    val navigationBar = new NavigationBar(NavigationBar.Direction.Vertical);
    navigationBar.setDrawer(drawer);
    return navigationBar;
}
Also used : lombok.val(lombok.val) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar)

Example 5 with NavigationBar

use of io.sunshower.zephyr.ui.navigation.NavigationBar in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureActionManagerCanEnableAndDisableButtons.

@ViewTest
@DirtiesContext
void ensureActionManagerCanEnableAndDisableButtons(@Autowired UserInterface ui, @Context TestContext $) {
    val action = spy(Actions.create("ui.module.stop", (self) -> {
    }));
    ui.register(Selection.path(":main:navigation"), Extensions.create(":management-menu", (NavigationBar p) -> {
        val button = new Button("hello");
        action.addActionEventListener(Type.ActionEnabled, (eventType, event) -> {
            button.setEnabled(true);
        });
        action.addActionEventListener(Type.ActionDisabled, (eventType, event) -> {
            button.setEnabled(true);
        });
        p.add(button);
    }));
    action.enable();
    $.flush();
    assertTrue($.selectFirst("vaadin-button[enabled]", Button.class).isPresent());
    action.dispose();
}
Also used : lombok.val(lombok.val) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ViewTest(com.aire.ux.test.ViewTest) DirtiesContext(org.springframework.test.annotation.DirtiesContext) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Extensions(com.aire.ux.Extensions) UserInterface(com.aire.ux.UserInterface) RouteDefinition(com.aire.ux.RouteDefinition) Select(com.aire.ux.test.Select) Autowired(org.springframework.beans.factory.annotation.Autowired) Mockito.spy(org.mockito.Mockito.spy) Context(com.aire.ux.test.Context) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) TestContext(com.aire.ux.test.TestContext) Actions(com.aire.ux.actions.Actions) Routes(com.aire.ux.test.Routes) AireUITest(io.sunshower.zephyr.AireUITest) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Type(com.aire.ux.actions.ActionEvent.Type) UI(com.vaadin.flow.component.UI) NotFoundException(com.vaadin.flow.router.NotFoundException) Mode(com.aire.ux.RouteDefinition.Mode) NonNull(lombok.NonNull) Assertions.assertInstanceOf(org.junit.jupiter.api.Assertions.assertInstanceOf) lombok.val(lombok.val) Selection(com.aire.ux.Selection) Navigate(com.aire.ux.test.Navigate) DefaultComponentExtension(com.aire.ux.DefaultComponentExtension) Button(com.vaadin.flow.component.button.Button) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) MainNavigationComponent(io.sunshower.zephyr.ui.layout.scenario1.MainNavigationComponent) MainView(io.sunshower.zephyr.MainView) ExtensionRegistry(com.aire.ux.ext.ExtensionRegistry) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Button(com.vaadin.flow.component.button.Button) DirtiesContext(org.springframework.test.annotation.DirtiesContext) ViewTest(com.aire.ux.test.ViewTest)

Aggregations

NavigationBar (io.sunshower.zephyr.ui.navigation.NavigationBar)5 lombok.val (lombok.val)5 ViewTest (com.aire.ux.test.ViewTest)3 Button (com.vaadin.flow.component.button.Button)3 DirtiesContext (org.springframework.test.annotation.DirtiesContext)3 DefaultComponentExtension (com.aire.ux.DefaultComponentExtension)2 Extensions (com.aire.ux.Extensions)1 RouteDefinition (com.aire.ux.RouteDefinition)1 Mode (com.aire.ux.RouteDefinition.Mode)1 Selection (com.aire.ux.Selection)1 UserInterface (com.aire.ux.UserInterface)1 Type (com.aire.ux.actions.ActionEvent.Type)1 Actions (com.aire.ux.actions.Actions)1 ExtensionRegistry (com.aire.ux.ext.ExtensionRegistry)1 Context (com.aire.ux.test.Context)1 Navigate (com.aire.ux.test.Navigate)1 Routes (com.aire.ux.test.Routes)1 Select (com.aire.ux.test.Select)1 TestContext (com.aire.ux.test.TestContext)1 UI (com.vaadin.flow.component.UI)1