<div class="search-bar">
    <div class="flex-grow_1">
        <form class="search" action="/build/modules">
            <input autocomplete="off" type="text" placeholder="Search modules" name="query"
                   ng-value="params.searchQuery"/>
            <button type="submit"><i class="bi bi-search"></i></button>
        </form>
    </div>
    <div class="flex flex-wrap flex--end" ng-class="{'padding-top': hubKey === null, 'padding-bottom': hubKey === null}" style="max-width: 280px">
        <div class="flex" ng-disabled="hubKey === null" ng-if="data.action">
            <button ng-show="data.action == 'deploy'"
                    class="btn btn-primary deploy-btn"
                    ng-if="project.classic_policy_set === true"
                    ng-disabled="classicPolicySetDeployDisabled"
                    ng-click="deploy(projectID)"
            >Deploy
            </button>
            <button ng-show="data.action == 'pushAndDeploy'"
                    class="btn btn-primary deploy-btn"
                    ng-disabled="pushAndDeployDisabled"
                    ng-click="pushAndDeploy(projectID)"
            >Push and deploy
            </button>
            <button ng-show="data.action == 'push'"
                    class="btn btn-primary deploy-btn"
                    ng-disabled="pushDisabled"
                    ng-click="push(projectID)"
            >Push
            </button>
            <button ng-show="data.action == 'localDeploy'"
                    class="btn btn-primary deploy-btn"
                    ng-disabled="localDeployDisabled"
                    ng-click="localDeploy(projectID)"
            >Deploy locally
            </button>
            <div class="relative">
                <button ng-disabled="pushAndDeployDisabled && pushDisabled && localDeployDisabled && classicPolicySetDeployDisabled"
                        ng-click="data.actionSelector = !data.actionSelector"
                        class="btn btn-primary deploy-btn options">
                    <i class="bi bi-chevron-down"></i>
                </button>
                <div class="actionSelector" ng-show="data.actionSelector" ng-init="data.actionSelectorInited=true">
                    <div ng-click="!classicPolicySetDeployDisabled && setDefaultAction('deploy')"
                         ng-class="{disabled: classicPolicySetDeployDisabled, selected: data.action == 'deploy'}"
                         ng-if="project.classic_policy_set === true"
                    >
                        <button
                                ng-disabled="classicPolicySetDeployDisabled"
                                href="javascript:void(0)"
                                class="btn btn-link"
                        >Deploy
                        </button>
                        <span> Deploy policy set to this hub using git.</span>
                    </div>
                    <div ng-click="!pushAndDeployDisabled && setDefaultAction('pushAndDeploy')"
                         ng-class="{disabled: pushAndDeployDisabled, selected: data.action == 'pushAndDeploy'}"
                    >
                        <button
                                ng-disabled="pushAndDeployDisabled"
                                href="javascript:void(0)"
                                class="btn btn-link"
                        >Push and deploy
                        </button>
                        <span>Push and deploy changes to project repository and this hub.</span>
                    </div>
                    <div ng-click="!pushDisabled && setDefaultAction('push')"
                         ng-class="{disabled: pushDisabled, selected: data.action == 'push'}"
                    >
                        <button
                                ng-disabled="pushDisabled"
                                href="javascript:void(0)"
                                class="btn btn-link">Push
                        </button>
                        <span>Push changes to the project repository (e.g.: GitHub or GitLab).</span>
                    </div>
                    <div ng-click="!localDeployDisabled && setDefaultAction('localDeploy')"
                         ng-class="{disabled: localDeployDisabled, selected: data.action == 'localDeploy'}"
                    >
                        <button
                                ng-disabled="localDeployDisabled"
                                href="javascript:void(0)"
                                class="btn btn-link"
                        >Deploy locally
                        </button>
                        <span>Deploy changes to this hub.</span>
                    </div>
                </div>
            </div>
        </div>

        <div ng-if="!data.action">
            <i class="bi bi-arrow-repeat icon-spin"></i>
        </div>
        <div class="margin-top-small noHubKeyWarning" ng-if="hubKey === null">
            Deployment is not allowed. <br/> The hub hasn't reported yet, please verify or re-bootstrap.
        </div>
    </div>
</div>
<div class="flex flex--end"><?= $this->load->view('/partials/errors') ?></div>
