package com.atlassian.bitbucket.repository.sync.web.conditions;

import com.atlassian.bitbucket.repository.sync.RefSyncService;
import com.atlassian.plugin.web.Condition;
import com.atlassian.bitbucket.repository.Repository;

import java.util.Map;

public class IsRefSyncingEnabledCondition implements Condition {

    private final RefSyncService syncService;

    public IsRefSyncingEnabledCondition(RefSyncService syncService) {
        this.syncService = syncService;
    }

    @Override
    public void init(Map<String, String> params) {
    }

    @Override
    public boolean shouldDisplay(Map<String, Object> context) {
        Repository repository = (Repository) context.get("repository");

        return syncService.isEnabled(repository);
    }
}
