$(function()
{
    if(type == 'artifacts')
    {
        if($('[data-key=linkStory] a').hasClass('active')) $('[data-key=linkStory] a').removeClass('active');
        if($('#linkStory').hasClass('active')) $('#linkStory').removeClass('active');
        if($('[data-key=bug] a').hasClass('active')) $('[data-key=bug] a').removeClass('active');
        if($('#bug').hasClass('active')) $('#bug').removeClass('active');
    }

    if(typeof artifacts != 'undefined' && artifacts.length > 0 && files.length == 0)
    {
        $('#buildInfo .scmPath').addClass('hidden');
        $('#buildInfo .filePath').addClass('hidden');
    }
});

window.showCommand = function(command, title)
{
    const content = `<div class="input-group">
        <input class="form-control docker-url" readonly type="text" value="${command}"> </input>
        <span class="input-group-addon cursor-pointer" onclick="copyCommand()">
        <i class="icon icon-copy"></i>
        </span>`;
    zui.Modal.open({type:'custom', title: title, content: {html: content}});
};

window.copyCommand = function()
{
    $('.docker-url')[0].select();
    document.execCommand('copy');
    window.getSelection().removeAllRanges();

    zui.Messager.show({type: 'success', content: copyMessage, time: 2000});
};

window.renderArtifactsCell = function(result, {col, row})
{
    if(col.name === 'createDate')
    {
        if(row.data.id.startsWith('file')) result[0] = zui.formatDate(row.data.createDate, 'yyyy-MM-dd');
    }

    return result;
};
