<section class="gh-canvas">
    <GhCanvasHeader class="gh-canvas-header members-header">
        <h2 class="gh-canvas-title" data-test-screen-title>Members</h2>
        <section class="view-actions">
            <GhMembersContentfilter
                @selectedLabel={{this.selectedLabel}}
                @availableLabels={{this.availableLabels}}
                @onLabelChange={{action "changeLabel"}}
                @onLabelAdd={{action "addLabel"}}
                @onLabelEdit={{action "editLabel"}}
            />
            <div class="relative gh-members-header-search">
                {{svg-jar "search" class="gh-input-search-icon"}}
                <GhTextInput
                    placeholder="Search members..."
                    @value={{this.searchText}}
                    @input={{action (mut this.searchText) value="target.value"}}
                    class="gh-members-list-searchfield {{if this.searchText "active"}}" />
            </div>
            <span class="dropdown">
                <GhDropdownButton @dropdownName="members-actions-menu"
                    @classNames="gh-btn gh-btn-white gh-btn-icon only-has-icon gh-actions-cog" @title="Members Actions"
                    @data-test-user-actions="true">
                    <span>
                        {{svg-jar "settings"}}
                        <span class="hidden">Actions</span>
                    </span>
                </GhDropdownButton>
                <GhDropdown @name="members-actions-menu" @tagName="ul"
                    @classNames="gh-member-actions-menu dropdown-menu dropdown-triangle-top-right">
                    <li>
                        <LinkTo @route="members.import" class="mr2" data-test-link="import-csv">
                            <span>Import members</span>
                        </LinkTo>
                    </li>
                    <li>
                        <a href="#" {{action 'exportData'}} class="mr2">
                            <span>Export all members</span>
                        </a>
                    </li>
                </GhDropdown>
            </span>
            <LinkTo @route="member.new" class="gh-btn gh-btn-green" data-test-new-member-button="true"><span>New member</span></LinkTo>
        </section>
    </GhCanvasHeader>

    <section class="view-container">
        {{#if filteredMembers}}
            {{#if this.showingAll}}
                <section>
                    <GhMembersChart @members={{members}} />
                </section>
            {{/if}}
        {{/if}}
        <section class="content-list">
            <ol class="members-list gh-list {{unless this.filteredMembers "no-posts"}}">
                {{#if this.filteredMembers}}
                    <li class="gh-list-row header">
                        <div class="gh-list-header">{{listHeader}}</div>
                        <div class="gh-list-header gh-list-cellwidth-20 nowrap">Location</div>
                        <div class="gh-list-header gh-list-cellwidth-20 nowrap">Created</div>
                        <div class="gh-list-header gh-list-cellwidth-chevron"></div>
                    </li>
                    {{#if this.filteredMembers}}
                        <VerticalCollection @items={{this.filteredMembers}} @key="id" @containerSelector=".gh-main" @estimateHeight=60 @bufferSize=20 as |member|>
                            <GhMembersListItem @member={{member}} @data-test-member-id={{member.id}} />
                        </VerticalCollection>
                    {{/if}}

                {{else}}
                    {{#if this.fetchMembers.isRunning}}
                        <div class="gh-content">
                            <GhLoadingSpinner />
                        </div>
                    {{else}}
                        <li class="no-posts-box">
                            <div class="no-posts">
                                {{svg-jar "members-placeholder" class="gh-members-placeholder"}}
                                {{#if this.showingAll}}
                                    <h3>No members yet</h3>
                                    <GhMembersNoMembers />
                                {{else}}
                                    <h3>No members match the current filter</h3>
                                {{/if}}
                            </div>
                        </li>
                    {{/if}}
                {{/if}}
            </ol>
        </section>
    </section>
</section>

{{outlet}}

{{#if this.showLabelModal}}
    <GhFullscreenModal
        @modal="members-label-form"
        @model={{this.labelModalData}}
        @close={{action "toggleLabelModal"}}
        @modifier="action wide"
    />
{{/if}}