Skip to content

Commit

Permalink
[hma] Check dev mode functionality on page load (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
levi-cloudflare authored Oct 3, 2024
1 parent 9bf55f1 commit 849ffd2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hasher-matcher-actioner/src/OpenMediaMatch/blueprints/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,19 @@ def home():
UI Landing page
"""

# Check if SEED_BANK_0 and SEED_BANK_1 exist yet
bank_list = curation.banks_index()
contains_seed_bank_0 = any(bank.name == "SEED_BANK_0" for bank in bank_list)
contains_seed_bank_1 = any(bank.name == "SEED_BANK_1" for bank in bank_list)

template_vars = {
"signal": curation.get_all_signal_types(),
"content": curation.get_all_content_types(),
"exchange_apis": _api_cls_info(),
"production": current_app.config.get("PRODUCTION", True),
"index": _index_info(),
"collabs": _collab_info(),
"is_banks_seeded": contains_seed_bank_0 and contains_seed_bank_1,
}
return render_template("bootstrap.html.j2", page="home", **template_vars)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@
<div class="me-2">Running server in development mode!</div>
<div class="hstack gap-2">
<form action="/dev/setup_sample_example" method="post">
{% if 'SEED_SAMPLE' in collabs %}
<button class="btn" disabled>
✅ Sample API created
</button>
{% else %}
<button type="submit" class="btn btn-primary">Setup Sample API</button>
{% endif %}
</form>
<form action="/dev/seed_banks" method="post">
{% if is_banks_seeded %}
<button class="btn" disabled>
✅ Banks seeded
</button>
{% else %}
<button type="submit" class="btn btn-primary">Seed Banks</button>
{% endif %}
</form>
<form action="/dev/setup_tx_example" method="post">
{% if 'TX_EXAMPLE_COLLAB' in collabs %}
<button class="btn" disabled>
✅ Tx API created
</button>
{% else %}
<button type="submit" class="btn btn-primary">Setup Tx API</button>
{% endif %}
</form>
<form action="/dev/factory_reset" method="post">
<button type="submit" class="btn btn-outline-danger">Factory Reset</button>
Expand Down

0 comments on commit 849ffd2

Please sign in to comment.