package com.atlassian.webdriver.bitbucket.element;

import com.atlassian.pageobjects.elements.WebDriverLocatable;
import com.atlassian.pageobjects.elements.query.TimedCondition;
import com.atlassian.pageobjects.elements.timeout.TimeoutType;
import org.openqa.selenium.By;

public class PullRequestListDialog extends Dialog {

    public PullRequestListDialog(By locator) {
        super(locator);
    }

    public PullRequestListDialog(By locator, TimeoutType timeoutType) {
        super(locator, timeoutType);
    }

    public PullRequestListDialog(WebDriverLocatable locatable, TimeoutType timeoutType) {
        super(locatable, timeoutType);
    }

    public LegacyPullRequestList getPullRequestList() {
        return pageBinder.bind(LegacyPullRequestList.class, By.id("pull-requests-table"), TimeoutType.COMPONENT_LOAD);
    }

    @Override
    public TimedCondition isOpen() {
        return find(By.id("pull-requests-table"), TimeoutType.DIALOG_LOAD).timed().isVisible();
    }
}
