Skip to content

Commit

Permalink
feat(nimbus): Add tooltips to new experiment timeline (#11991)
Browse files Browse the repository at this point in the history
  • Loading branch information
RJAK11 authored Jan 8, 2025
1 parent 7b39a9d commit d23284d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
6 changes: 6 additions & 0 deletions experimenter/experimenter/experiments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,30 +876,35 @@ def timeline(self):
"date": self.draft_date,
"is_active": self.is_draft,
"days": self.computed_draft_days,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Draft"],
},
{
"label": self.Status.PREVIEW,
"date": self.preview_date,
"is_active": self.is_preview,
"days": self.computed_preview_days,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Preview"],
},
{
"label": self.PublishStatus.REVIEW,
"date": self.review_date,
"is_active": self.is_review,
"days": self.computed_review_days,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Review"],
},
{
"label": NimbusConstants.ENROLLMENT,
"date": self.start_date,
"is_active": self.is_enrollment,
"days": self.computed_enrollment_days,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Enrollment"],
},
{
"label": self.Status.COMPLETE,
"date": self.computed_end_date,
"is_active": self.is_complete,
"days": self.computed_duration_days,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Complete"],
},
]
if not self.is_rollout:
Expand All @@ -910,6 +915,7 @@ def timeline(self):
"date": self._enrollment_end_date,
"is_active": self.is_observation,
"days": self.computed_observations_days,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Observation"],
},
)

Expand Down
7 changes: 7 additions & 0 deletions experimenter/experimenter/experiments/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,36 +1777,42 @@ def test_timeline_dates_includes_correct_status_dates_and_flags(self):
"date": experiment.draft_date,
"is_active": False,
"days": 1,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Draft"],
},
{
"label": "Preview",
"date": experiment.preview_date,
"is_active": False,
"days": 0,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Preview"],
},
{
"label": "Review",
"date": experiment.review_date,
"is_active": False,
"days": 2,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Review"],
},
{
"label": NimbusConstants.ENROLLMENT,
"date": experiment.start_date,
"is_active": False,
"days": 2,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Enrollment"],
},
{
"label": NimbusConstants.OBSERVATION,
"date": experiment._enrollment_end_date,
"is_active": False,
"days": 2,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Observation"],
},
{
"label": "Complete",
"date": experiment.computed_end_date,
"is_active": True,
"days": 4,
"tooltip": NimbusUIConstants.TIMELINE_TOOLTIPS["Complete"],
},
]

Expand All @@ -1815,6 +1821,7 @@ def test_timeline_dates_includes_correct_status_dates_and_flags(self):
self.assertEqual(timeline[i]["date"], expected["date"])
self.assertEqual(timeline[i]["is_active"], expected["is_active"])
self.assertEqual(timeline[i].get("days"), expected["days"])
self.assertEqual(timeline[i].get("tooltip"), expected["tooltip"])

def test_timeline_dates_complete_is_active_when_status_is_complete(self):
experiment = NimbusExperimentFactory.create_with_lifecycle(
Expand Down
21 changes: 21 additions & 0 deletions experimenter/experimenter/nimbus_ui_new/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,24 @@ class NimbusUIConstants:
proportion has accounted for this:"""

AUDIENCE_OVERLAP_WARNING = "https://experimenter.info/faq/warnings/#audience-overlap"

TIMELINE_TOOLTIPS = {
"Draft": (
"The duration from the initial draft of the experiment to its entry "
"into either the preview or review stage."
),
"Preview": ("The number of days the experiment has spent in the preview stage."),
"Review": ("The number of days the experiment has spent in the review stage."),
"Enrollment": (
"The duration from the start to the end of the participant enrollment "
"period."
),
"Complete": (
"The total number of days from the start of participant enrollment "
"to the end of the experiment."
),
"Observation": (
"The number of days the experiment was observed after the enrollment "
"period ended."
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% block main_content_header %}
<div class="row mb-2">
<div class="col-md-12 col-xl-6">
<div class="col-md-12 col-xl-5">
<h4 class="mb-0">{{ experiment.name }}</h4>
<span class="{{ experiment.qa_status_badge_class }}">
QA Status: {{ experiment.qa_status|default:"Not Set"|title }}
Expand All @@ -22,12 +22,21 @@ <h4 class="mb-0">{{ experiment.name }}</h4>
</p>
{% endif %}
</div>
<div class="col-md-12 col-xl-6">
<div class="col-md-12 col-xl-7">
<ul class="list-group list-group-horizontal justify-content-between mb-3">
{% for status in experiment.timeline %}
<li class="list-group-item flex-fill text-center d-flex flex-column justify-content-center {% if status.is_active %}bg-primary text-white{% endif %}">
<strong>{{ status.label }}</strong>
<small>{{ status.date|default:'---' }}</small>
{% if status.days is not None %}
<div class="d-flex justify-content-center align-items-center">
<small class="mr-2">{{ status.days }} day{{ status.days|pluralize }}</small>
<i class="fa-regular fa-circle-question fa-sm ps-1"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{{ status.tooltip }}"></i>
</div>
{% endif %}
</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit d23284d

Please sign in to comment.