{{topic-list-loading loading=topicListReloading}}

{{#unless loading}}
  {{#if loaded}}
    <div class='contents'>
      {{#if view.showTable}}

      {{#if canViewRankDetails}}
        <button class='btn' {{action toggleRankDetails}} style='margin-bottom: 10px'>
          <i class='fa fa-flask'></i>
          {{i18n rank_details.toggle}}
        </button>
      {{/if}}

      <table id='topic-list'>
        <thead>
        <tr>
          {{#if currentUser}}
            <th>&nbsp;</th>
          {{/if}}
          {{#sortable-heading sortBy="default" sortOrder=sortOrder}}
            {{i18n topic.title}}
          {{/sortable-heading}}
          {{#unless category}}
            {{#sortable-heading sortBy="category" sortOrder=sortOrder}}
              {{i18n category_title}}
            {{/sortable-heading}}
          {{/unless}}
          {{#sortable-heading sortBy="posters" sortOrder=sortOrder}}
            {{i18n users}}
          {{/sortable-heading}}
          {{#sortable-heading sortBy="posts" number=true sortOrder=sortOrder}}
            {{i18n posts}}
          {{/sortable-heading}}
          {{#sortable-heading sortBy="likes" number=true sortOrder=sortOrder}}
            {{i18n likes}}
          {{/sortable-heading}}
          {{#sortable-heading sortBy="views" number=true sortOrder=sortOrder}}
            {{i18n views}}
          {{/sortable-heading}}
          {{#sortable-heading sortBy="activity" number=true colspan="2" sortOrder=sortOrder}}
            {{i18n activity}}
          {{/sortable-heading}}
        </tr>
        </thead>

        {{#if view.topicTrackingState.hasIncoming}}
          <tbody>
            <tr>
              <td colspan="9">
                <div class='alert alert-info clickable' {{action showInserted}}>
                  {{countI18n new_topics_inserted countBinding="view.topicTrackingState.incomingCount"}}
                  {{i18n show_new_topics}}
                </div>
              </td>
            </tr>
          </tbody>
        {{/if}}

        {{collection contentBinding="topics" tagName="tbody" itemViewClass="Discourse.TopicListItemView"}}

      </table>
      {{/if}}
    </div>

    <footer id='topic-list-bottom'>
      {{#if loadingMore}}
        <div class='topics-loading'>{{i18n topic.loading_more}}</div>
      {{/if}}

      <h3>
        {{footerMessage}}
        {{#if allLoaded}}
          {{#if latest}}
            {{#if canCreateTopic}}
              <a href='#' {{action createTopic}}>{{i18n topic.suggest_create_topic}}</a>
            {{/if}}
          {{else}}
            {{#link-to "list.categories"}}{{i18n topic.browse_all_categories}}{{/link-to}} {{i18n or}} {{#link-to 'list.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}}
          {{/if}}
        {{/if}}
      </h3>
    </footer>
  {{/if}}
{{/unless}}
