- page_title << @server.name
- page_title << "Credentials"

= render 'servers/sidebar', :active_server => @server
= render 'servers/header', :active_nav => :credentials
.pageContent.pageContent--compact
  - if @credentials.empty?
    .noData.noData--clean
      %h2.noData__title There are no credentials for this server.
      %p.noData__text
        In order to authenticate to your mail server, you use credentials. Once
        you've added a credential, you'll have a unique token which you can use to
        authenticate against our SMTP service or our HTTP API.
      .noData__button= link_to "Add your first credential", [:new, organization, @server, :credential], :class => 'button button--positive'
  - else
    %p.pageContent__intro.u-margin
      In order to authenticate to your mail server, you use credentials. Once
      you've added a credential, you'll have a unique token which you can use to
      authenticate against our SMTP service or our HTTP API.
    %p.u-margin.pageContent__helpLink= link_to "Read more about sending outgoing e-mails", [organization, @server, :help_outgoing]
    %ul.credentialList.u-margin
      - for credential in @credentials
        %li.credentialList__item
          = link_to [:edit, organization, @server, credential], :class => 'credentialList__link' do
            .credentialList__type
              %span.label{:class => "label--credentialType-#{credential.type.underscore}"}= credential.type.split('-').last
            .credentialList__properties
              %p.credentialList__name
                = credential.name
                - if credential.hold?
                  %span.label.label--red Holding
              %p.credentialList__key= credential.key
            .credentialList__usedAt{:class => "credentialList__usedAt--#{credential.usage_type.underscore}"}
              - if credential.last_used_at
                %p.credentialList__usedAtTitle= credential.usage_type
                %p Used #{distance_of_time_in_words_to_now credential.last_used_at} ago
              - else
                %p Not been used yet

    %p.u-center.buttonSet.buttonSet--center
      = link_to "Add another credential", [:new, organization, @server, :credential], :class => 'button button--positive'
