package com.atlassian.webdriver.bitbucket.page.admin;

import com.atlassian.pageobjects.elements.ElementBy;
import com.atlassian.pageobjects.elements.PageElement;
import com.atlassian.webdriver.bitbucket.element.BitbucketHeader;
import com.atlassian.webdriver.bitbucket.page.LicensePage;
import com.atlassian.webdriver.bitbucket.page.BitbucketPage;

public class AdminHomePage extends BitbucketPage implements com.atlassian.pageobjects.page.AdminHomePage<BitbucketHeader> {

    @ElementBy(linkText = "Global permissions")
    private PageElement permissionsLink;
    @ElementBy(linkText = "Authentication")
    private PageElement authenticationLink;
    @ElementBy(linkText = "Server settings")
    private PageElement serverSettingsLink;
    @ElementBy(linkText = "Mail server")
    private PageElement mailServerConfigLink;
    @ElementBy(linkText = "Licensing")
    private PageElement licensingLink;
    @ElementBy(linkText = "Avatars")
    private PageElement avatarsLink;
    @ElementBy(linkText = "User Directories")
    private PageElement userDirectoriesLink;
    @ElementBy(linkText = "Application Navigator")
    private PageElement applicationNavigator;
    @ElementBy(linkText = "Analytics")
    private PageElement analyticsNavigator;

    public static final String URL_SUFFIX = "/admin";

    @Override
    public String getUrl() {
        return URL_SUFFIX;
    }

    public GlobalPermissionsPage gotoGlobalPermissionsPage() {
        permissionsLink.click();
        return pageBinder.bind(GlobalPermissionsPage.class);
    }

    public AuthenticationPage gotoAuthenticationPage() {
        authenticationLink.click();
        return pageBinder.bind(AuthenticationPage.class);
    }

    public ServerSettingsPage gotoServerSettingsPage() {
        serverSettingsLink.click();
        return pageBinder.bind(ServerSettingsPage.class);
    }

    public MailServerConfigPage gotoMailServerConfigPage() {
        mailServerConfigLink.click();
        return pageBinder.bind(MailServerConfigPage.class);
    }

    public LicensePage gotoLicensePage() {
        licensingLink.click();
        return pageBinder.bind(LicensePage.class);
    }

    public AvatarSettingsPage gotoAvatarPage() {
        avatarsLink.click();
        return pageBinder.bind(AvatarSettingsPage.class);
    }

    public UserDirectoriesPage gotoUserDirectoriesPage() {
        userDirectoriesLink.click();
        return pageBinder.bind(UserDirectoriesPage.class);
    }

    public NavLinksPage goToNavLinksPage() {
        applicationNavigator.click();
        return pageBinder.bind(NavLinksPage.class);
    }

    public AnalyticsSettingsPage goToAnalyticsSettingsPage() {
        analyticsNavigator.click();
        return pageBinder.bind(AnalyticsSettingsPage.class);
    }
}
