package com.atlassian.webdriver.bitbucket.element.activity;

import com.atlassian.pageobjects.elements.PageElement;
import org.openqa.selenium.By;

import javax.annotation.Nullable;

public class MergeActivityItem extends StateActivityItem {

    public MergeActivityItem(PageElement activityContainer) {
        super(activityContainer);
    }

    @Nullable
    public String getCommitId() {
        if (hasCommitId()) {
            return activityContainer.find(By.className("commitid")).getAttribute("data-commitid");
        }
        return null;
    }

    public boolean hasCommitId() {
        return activityContainer.find(By.className("commitid")).isPresent();
    }

    public void openMergeCommitPage() {
        activityContainer.find(By.className("commitid")).click();
    }
}
