package com.atlassian.webdriver.bitbucket.page;

import com.atlassian.pageobjects.elements.ElementBy;
import com.atlassian.pageobjects.elements.PageElement;

public class UserAccountAddSshKeyPage extends BitbucketPage {

    @ElementBy(id = "text")
    private PageElement keyTextTextArea;

    @ElementBy(id = "submit")
    private PageElement addKeyButton;

    @Override
    public String getUrl() {
        return "/plugins/servlet/ssh/account/keys/add";
    }

    public UserAccountAddSshKeyPage setKey(String keyText) {
        keyTextTextArea.clear().type(keyText);
        return this;
    }

    public UserAccountSshSettingsPage clickAddKey() {
        waitForPageLoad(new Runnable() {
            public void run() {
                addKeyButton.click();
            }
        });
        return pageBinder.bind(UserAccountSshSettingsPage.class);
    }
}
