<% if params.key?("error") %>
  <div class="alert alert-danger"><%= params["error"] %></div>
<% end %>

<div class="card mb-4">
  <div class="card-header">
    <h4 class="m-0">Migrate to Flipper Cloud</h4>
  </div>
  <div class="card-body">
    <p>Flipper Cloud gives you audit history, rollback, finer-grained permissions, and multi-environment sync. We even have a free tier!</p>

    <ul class="mb-3">
      <li>Audit log of every feature change</li>
      <li>Instant rollback to any previous state</li>
      <li>Team permissions and approval workflows</li>
      <li>Sync flags across environments</li>
    </ul>

    <p>You have <strong><%= flipper.features.count %></strong> <%= flipper.features.count == 1 ? 'feature' : 'features' %> ready to migrate.</p>

    <form action="<%= script_name %>/settings/cloud" method="post">
      <%== csrf_input_tag %>
      <input type="submit" value="Migrate to Flipper Cloud" class="btn btn-primary">
    </form>
  </div>
</div>

<div class="card mb-4 ">
  <div class="card-header">
    <h4 class="m-0">Export</h4>
  </div>
  <div class="card-body">
    <form action="<%= script_name %>/settings/export" method="post">
      <%== csrf_input_tag %>
      <p>Download all your feature data in a single file.</p>
      <input type="submit" value="Download" class="btn btn-light">
    </form>
  </div>
</div>

<% if write_allowed? %>
<div class="card">
  <div class="card-header">
    <h4 class="m-0">Import</h4>
  </div>
  <div class="card-body">
    <p>Import a backup file to restore your feature data. This will overwrite any of your existing feature data so be sure you are uploading the correct export.</p>
    <form action="<%= script_name %>/settings/import" method="post" class="row" enctype="multipart/form-data">
      <%== csrf_input_tag %>
      <div class="col-auto"><input type="file" name="file" class="form-control"></div>
      <div class="col-auto"><input type="submit" value="Import" class="btn btn-light"></div>
    </form>
  </div>
</div>
<% end %>
