package com.atlassian.webdriver.bitbucket.page;

import com.atlassian.pageobjects.elements.ElementBy;
import com.atlassian.pageobjects.elements.PageElement;
import com.atlassian.webdriver.bitbucket.element.FormFragment;

public class GitLfsRepositorySettingsFormFragment extends FormFragment<RepositoryEditSettingsPage> {

    @ElementBy(id = "lfsRepoEnabled")
    private PageElement enabledCheckbox;

    public GitLfsRepositorySettingsFormFragment(RepositoryEditSettingsPage page) {
        super(page);
    }

    /**
     * @return the state of the checkbox widget. When false is returned it indicated the widget is disabled;
     * that is, its state cannot be changed and it is "greyed out".
     */
    public boolean isCheckboxEnabled() {
        return enabledCheckbox.isEnabled();
    }

    /**
     * @return the state of the checkbox, either true if it is ticked or false if unticked
     */
    public boolean isEnabled() {
        return enabledCheckbox.isSelected();
    }

    /**
     * Toggles the state of the checkbox
     */
    public GitLfsRepositorySettingsFormFragment toggleEnabled() {
        enabledCheckbox.toggle();
        return this;
    }
}
