.d-flex.mb-3
    h3(translate) Plugins
    button.btn.btn-secondary.btn-sm.ms-auto((click)='openPluginsFolder()')
        i.fas.fa-folder
        span(translate) Plugins folder

.alert.alert-danger(*ngIf='errorMessage')
    strong(
        translate='Error in {plugin}:',
        [translateParams]='{plugin: erroredPlugin}'
    )
    pre {{errorMessage}}

ul.nav-tabs.mb-2(ngbNav, #nav='ngbNav')
    li(ngbNavItem)
        a(ngbNavLink, translate) Available
        ng-template(ngbNavContent)
            .input-group.mb-3.mt-3
                .input-group-text
                    i.fas.fa-fw.fa-circle-notch.fa-spin(*ngIf='!availablePluginsReady')
                    i.fas.fa-fw.fa-search(*ngIf='availablePluginsReady')
                input.form-control(
                    type='text',
                    [(ngModel)]='availableFilter',
                    (ngModelChange)='searchAvailable(availableFilter)',
                    [placeholder]='"Search plugins"|translate'
                )

            ngb-accordion.mb-4(*ngIf='availablePlugins$', [closeOthers]='true')
                ng-container(*ngFor='let plugin of (availablePlugins$|async)')
                    ngb-panel(*ngIf='!isAlreadyInstalled(plugin)')
                        ng-template(ngbPanelTitle)
                            .text-left
                                strong.d-block {{plugin.name}}
                                small.d-block.text-muted {{plugin.description}}
                        ng-template(ngbPanelContent)
                            .row
                                .col-4
                                    div.d-flex.flex-column.flex-md-row.gap-2
                                        button.btn.btn-primary.btn-block.justify-content-center(
                                            (click)='installPlugin(plugin)',
                                            [disabled]='busy.has(plugin.name)'
                                        )
                                            i.fas.fa-fw.fa-cloud-download(*ngIf='busy.get(plugin.name) != BusyState.Installing')
                                            i.fas.fa-fw.fa-circle-notch.fa-spin(*ngIf='busy.get(plugin.name) == BusyState.Installing')
                                            span.ms-2(translate) Get
    
                                        button.btn.btn-secondary.btn-block.justify-content-center(
                                            *ngIf='plugin.homepage',
                                            (click)='showPluginHomepage(plugin)'
                                        )
                                            i.fas.fa-fw.fa-external-link-alt
                                            span.ms-2(translate) Homepage

                                .col-8
                                    ng-container(*ngTemplateOutlet='pluginInfo; context: { plugin }')

                            .mt-2 {{plugin.description}}

    li(ngbNavItem)
        a(ngbNavLink, translate) Installed
        ng-template(ngbNavContent)
            .input-group.mb-3.mt-3
                .input-group-text
                    i.fas.fa-fw.fa-search
                input.form-control(
                    type='text',
                    [(ngModel)]='installedFilter',
                    (ngModelChange)='searchInstalled(installedFilter)',
                    [placeholder]='"Search plugins"|translate'
                )

            ngb-accordion.mb-4([closeOthers]='true')
                ng-container(*ngFor='let plugin of installedPlugins$')
                    ngb-panel
                        ng-template(ngbPanelTitle)
                            .text-left.me-auto
                                div
                                    strong {{plugin.name}}
                                    small.text-muted.ms-2(*ngIf='plugin.isBuiltin', translate) Built-in
                                    small.text-warning.ms-2(*ngIf='!isPluginEnabled(plugin)', translate) Disabled
                                small.d-block.text-muted {{plugin.description}}

                            button.btn.btn-primary.ms-2(
                                *ngIf='knownUpgrades[plugin.name]',
                                (click)='upgradePlugin(plugin)',
                                [disabled]='busy.has(plugin.name)'
                            )
                                i.fas.fa-fw.fa-arrow-up(*ngIf='busy.get(plugin.name) != BusyState.Installing')
                                i.fas.fa-fw.fa-circle-notch.fa-spin(*ngIf='busy.get(plugin.name) == BusyState.Installing')
                                span(
                                    translate='Upgrade to {version}',
                                    [translateParams]='{version: knownUpgrades[plugin.name]?.version}'
                                )

                        ng-template(ngbPanelContent)
                            .row
                                .col-4
                                    button.btn.btn-warning.btn-block.justify-content-center(
                                        (click)='togglePlugin(plugin)',
                                        *ngIf='isPluginEnabled(plugin)',
                                        [disabled]='!canDisablePlugin(plugin)',
                                        translate
                                    ) Disable

                                    button.btn.btn-success.btn-block.justify-content-center(
                                        (click)='togglePlugin(plugin)',
                                        *ngIf='canDisablePlugin(plugin) && !isPluginEnabled(plugin)',
                                        translate
                                    ) Enable

                                    button.btn.btn-danger.btn-block.justify-content-center(
                                        (click)='uninstallPlugin(plugin)',
                                        *ngIf='!plugin.isBuiltin',
                                        [disabled]='busy.has(plugin.name)'
                                    )
                                        i.fas.fa-fw.fa-trash(*ngIf='busy.get(plugin.name) != BusyState.Uninstalling')
                                        i.fas.fa-fw.fa-circle-notch.fa-spin(*ngIf='busy.get(plugin.name) == BusyState.Uninstalling')
                                        span(translate) Uninstall
                                .col-8
                                    ng-container(*ngTemplateOutlet='pluginInfo; context: { plugin }')

                            .mt-2 {{plugin.description}}

ng-template(#pluginInfo, let-plugin='plugin')
    .row.align-items-center
        .col-4
            strong(translate) Version
        .col-8
            span {{plugin.version}}
    .row.align-items-center
        .col-4
            strong(translate) Author
        .col-8
            .badge.text-bg-success(*ngIf='plugin.isOfficial')
                i.fas.fa-check
                span.ms-1(translate) Official
            a.btn.btn-link.px-0.w-auto((click)='showPluginInfo(plugin)', *ngIf='!plugin.isOfficial')
                span {{plugin.author}}
                i.fas.fa-fw.fa-external-link-alt.ms-2

.mb-4([ngbNavOutlet]='nav')
