"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatasetGitAccess = void 0;
const react_1 = __importDefault(require("react"));
const Tooltip_1 = require("../tooltip/Tooltip");
const Button_1 = require("../button/Button");
function copyToClipboard(text) {
    navigator.clipboard.writeText(text);
}
const DatasetGitAccess = ({ datasetId, worker, configUrl, gitHash, configGithub, hasEdit, }) => {
    const workerId = worker?.split('-').pop();
    const url = `${configUrl}/git/${workerId}/${datasetId}`;
    const readURL = `https://github.com/${configGithub}/${datasetId}.git`;
    return (react_1.default.createElement("div", { className: "dataset-git-access" },
        react_1.default.createElement("span", null,
            react_1.default.createElement("h4", null, "DataLad/Git URL"),
            react_1.default.createElement("a", { href: "https://docs.openneuro.org/git", target: "_blank" }, "View Documentation")),
        react_1.default.createElement("div", { className: "git-url" },
            workerId && (react_1.default.createElement(Tooltip_1.Tooltip, { tooltip: "Copy URL To Clipboard", flow: "right" },
                react_1.default.createElement(Button_1.Button, { onClick: () => copyToClipboard(readURL), icon: "fas fa-clipboard", size: "small", iconSize: "18px", label: "copy Github url" }))),
            react_1.default.createElement("div", null, readURL)),
        hasEdit && (react_1.default.createElement("div", { className: "git-url" },
            workerId && (react_1.default.createElement(Tooltip_1.Tooltip, { tooltip: "Copy URL To Clipboard", flow: "right" },
                react_1.default.createElement(Button_1.Button, { onClick: () => copyToClipboard(url), icon: "fas fa-clipboard", size: "small", iconSize: "18px", label: "copy OpenNeuro url" }))),
            react_1.default.createElement("div", null, url))),
        react_1.default.createElement("div", { className: "git-hash" },
            react_1.default.createElement(Tooltip_1.Tooltip, { tooltip: "Copy Git Hash to Clipboard", flow: "right" },
                react_1.default.createElement(Button_1.Button, { onClick: () => copyToClipboard(gitHash), icon: "fas fa-clipboard", size: "small", iconSize: "18px", label: "copy git hash" })),
            react_1.default.createElement("div", null,
                "Git Hash: ",
                gitHash.slice(0, 7)))));
};
exports.DatasetGitAccess = DatasetGitAccess;
