package com.atlassian.bitbucket.internal.importer.web;

import com.atlassian.bitbucket.nav.NavBuilder;
import com.atlassian.bitbucket.project.Project;
import com.atlassian.plugin.PluginParseException;
import com.atlassian.plugin.web.ContextProvider;
import com.google.common.collect.ImmutableMap;

import java.util.Map;

public class ImportRepositoryWelcomeMatContextProvider implements ContextProvider {
        private final NavBuilder navBuilder;

        public ImportRepositoryWelcomeMatContextProvider(NavBuilder navBuilder) {
            this.navBuilder = navBuilder;
        }

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

        @Override
        public Map<String, Object> getContextMap(Map<String, Object> context) {
            Project project = (Project) context.get("project");
            return ImmutableMap.of(
                    "repositoryImportUrl", navBuilder.pluginServlets()
                            .path("import-repository", project.getKey()).buildRelative(),
                    "project", project);
        }
}
