Skip to content

Commit

Permalink
Style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
matejak committed Dec 14, 2023
1 parent d8046ea commit 12b30aa
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="container">
<div class="row">
<h1>Red Hat Compliance Plugin</h1>
{{ render_form(plugin_form, action=relative_url_for("rhcompliance.sync")) }}
{{ render_form(plugin_form, action=head_url_for("rhcompliance.sync")) }}
</div>
</div>
{% endblock %}
Expand Down
21 changes: 21 additions & 0 deletions estimage/webapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def get_final_class(self, class_name):
def get_config_option(self, option):
raise NotImplementedError()

def get_plugins_in_context(self):
raise NotImplementedError()

def get_correct_context_endpoint(self, endpoint):
return endpoint


class PluginFriendlySingleheadFlask(PluginFriendlyFlask):
def __init__(self, import_name, ** kwargs):
Expand All @@ -55,8 +61,13 @@ def store_plugins_to_config(self):
def get_config_option(self, option):
return self.config[option]

def get_plugins_in_context(self):
return self.get_config_option("PLUGINS")


class PluginFriendlyMultiheadFlask(PluginFriendlyFlask):
NON_HEAD_BLUEPRINTS = ("login", "neck")

def __init__(self, import_name, ** kwargs):
super().__init__(import_name, ** kwargs)
self._plugin_resolvers = dict()
Expand All @@ -80,6 +91,16 @@ def current_head(self):
def get_config_option(self, option):
return self.config["head"][self.current_head][option]

def get_correct_context_endpoint(self, endpoint):
if (head_name := self.current_head) in self.NON_HEAD_BLUEPRINTS:
return super().get_correct_context_endpoint(endpoint)
return f"{head_name}.{endpoint}"

def get_plugins_in_context(self):
if self.current_head in self.NON_HEAD_BLUEPRINTS:
return dict()
return self.get_config_option("PLUGINS")


def create_app(config_class=config.Config):
app = PluginFriendlySingleheadFlask(__name__)
Expand Down
20 changes: 10 additions & 10 deletions estimage/webapp/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def move_issue_estimate_to_consensus(task_name):
flask.flash("Consensus not updated, request was not serious")

return flask.redirect(
web_utils.url_for("main.view_projective_task", task_name=task_name))
web_utils.head_url_for("main.view_projective_task", task_name=task_name))


@bp.route('/authoritative/<task_name>', methods=['POST'])
Expand All @@ -103,7 +103,7 @@ def move_consensus_estimate_to_authoritative(task_name):
flask.flash("Authoritative estimate not updated, request was not serious")

return flask.redirect(
web_utils.url_for("main.view_projective_task", task_name=task_name))
web_utils.head_url_for("main.view_projective_task", task_name=task_name))


@bp.route('/estimate/<task_name>', methods=['POST'])
Expand All @@ -129,7 +129,7 @@ def estimate(task_name):
msg += ", ".join(form.get_all_errors())
flask.flash(msg)
return flask.redirect(
web_utils.url_for("main.view_projective_task", task_name=task_name))
web_utils.head_url_for("main.view_projective_task", task_name=task_name))


def tell_of_bad_estimation_input(task_name, task_category, message):
Expand Down Expand Up @@ -177,7 +177,7 @@ def view_projective_task(task_name):
authoritative=flask.current_app.get_final_class("AuthoritativeForm")(),
)
breadcrumbs = get_projective_breadcrumbs()
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.url_for("main.view_epic", epic_name=n))
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.head_url_for("main.view_epic", epic_name=n))
return view_task(t, breadcrumbs, request_forms)


Expand All @@ -187,7 +187,7 @@ def view_retro_task(task_name):
t = retro_retrieve_task(task_name)

breadcrumbs = get_retro_breadcrumbs()
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.url_for("main.view_epic_retro", epic_name=n))
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.head_url_for("main.view_epic_retro", epic_name=n))
return view_task(t, breadcrumbs)


Expand Down Expand Up @@ -231,13 +231,13 @@ def view_task(task, breadcrumbs, request_forms=None):

def get_projective_breadcrumbs():
breadcrumbs = collections.OrderedDict()
breadcrumbs["Planning"] = web_utils.url_for("main.tree_view")
breadcrumbs["Planning"] = web_utils.head_url_for("main.tree_view")
return breadcrumbs


def get_retro_breadcrumbs():
breadcrumbs = collections.OrderedDict()
breadcrumbs["Retrospective"] = web_utils.url_for("main.tree_view_retro")
breadcrumbs["Retrospective"] = web_utils.head_url_for("main.tree_view_retro")
return breadcrumbs


Expand Down Expand Up @@ -273,7 +273,7 @@ def view_epic(epic_name):
refresh_form.next.data = flask.request.path

breadcrumbs = get_projective_breadcrumbs()
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.url_for("main.view_epic", epic_name=n))
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.head_url_for("main.view_epic", epic_name=n))

return web_utils.render_template(
'epic_view.html', title='View epic', epic=t, estimate=estimate, model=model, breadcrumbs=breadcrumbs,
Expand All @@ -291,7 +291,7 @@ def get_similar_tasks(user_id, task_name, all_targets_by_id):

@bp.route('/')
def index():
return flask.redirect(web_utils.url_for("main.overview_retro"))
return flask.redirect(web_utils.head_url_for("main.overview_retro"))


@bp.route('/refresh', methods=["POST"])
Expand Down Expand Up @@ -424,7 +424,7 @@ def view_epic_retro(epic_name):

summary = executive_summary_of_points_and_velocity(t.children)
breadcrumbs = get_retro_breadcrumbs()
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.url_for("main.view_epic_retro", epic_name=n))
append_target_to_breadcrumbs(breadcrumbs, t, lambda n: web_utils.head_url_for("main.view_epic_retro", epic_name=n))

return web_utils.render_template(
'epic_view_retrospective.html', title='View epic', breadcrumbs=breadcrumbs,
Expand Down
4 changes: 2 additions & 2 deletions estimage/webapp/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<div class="navbar-nav mr-auto">
{% block navbar %}
{% block navbar_common %}
{{ render_nav_item(head_prefix ~ 'main.overview_retro', 'Retrospective') }}
{{ render_nav_item(head_prefix ~ 'main.tree_view', 'Planning') }}
{{ render_nav_item(get_head_absolute_endpoint('main.overview_retro'), 'Retrospective') }}
{{ render_nav_item(get_head_absolute_endpoint('main.tree_view'), 'Planning') }}
{% endblock %}
{% block navbar_custom %}
{% for name, entrypoint in custom_items.items() %}
Expand Down
4 changes: 2 additions & 2 deletions estimage/webapp/templates/completion.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h2>Velocity</h2>
</ul>
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_velocity_fit') }}" alt="Overall velocity"/>
<img src="{{ head_url_for('vis.visualize_velocity_fit') }}" alt="Overall velocity"/>
</p>
</div>

Expand All @@ -24,7 +24,7 @@ <h2>Completion</h2>
Estimated time of delivery - between {{ "%.2g" % (summary.completion[0] / 7.0) }} to {{ "%.2g" % (summary.completion[1] / 7.0) }} weeks from now.
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_completion') }}" alt="Completion projection"/>
<img src="{{ head_url_for('vis.visualize_completion') }}" alt="Completion projection"/>
</p>
{% endblock completion %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion estimage/webapp/templates/epic_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h3>Sum of subtasks</h3>
<div class="col">
<p>Remaining point cost: {{ utils.render_estimate(model.remaining_point_estimate_of(epic.name)) }}</p>
<p>Nominal point cost: {{ utils.render_estimate(model.nominal_point_estimate_of(epic.name)) }}</p>
<img src="{{ relative_url_for('vis.visualize_task', task_name=epic.name, nominal_or_remaining='remaining') }}" alt="PERT prob density function for {{ epic.name }} - remaining work"/>
<img src="{{ head_url_for('vis.visualize_task', task_name=epic.name, nominal_or_remaining='remaining') }}" alt="PERT prob density function for {{ epic.name }} - remaining work"/>
</div>
</div>
{%- if similar_sized_epics %}
Expand Down
4 changes: 2 additions & 2 deletions estimage/webapp/templates/epic_view_retrospective.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Burndown</h2>
</ul>
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_epic_burndown', epic_name=epic.name, size="normal") }}" alt="Epic Burndown"/>
<img src="{{ head_url_for('vis.visualize_epic_burndown', epic_name=epic.name, size="normal") }}" alt="Epic Burndown"/>
</p>
</div>
<div class="col">
Expand All @@ -35,7 +35,7 @@ <h2>Velocity</h2>
</ul>
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_velocity', epic_name=epic.name) }}" alt="Epic velocity"/>
<img src="{{ head_url_for('vis.visualize_velocity', epic_name=epic.name) }}" alt="Epic velocity"/>
</p>
{% else -%}
<p>
Expand Down
4 changes: 2 additions & 2 deletions estimage/webapp/templates/general_plan.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "base.html" %}

{% block navbar_secondary_common %}
{{ render_nav_item(head_prefix ~ 'main.tree_view', 'Tree View') }}
{{ render_nav_item(head_prefix ~ 'persons.planning_workload', 'Workloads') }}
{{ render_nav_item(get_head_absolute_endpoint('main.tree_view'), 'Tree View') }}
{{ render_nav_item(get_head_absolute_endpoint('persons.planning_workload'), 'Workloads') }}
{% endblock %}
8 changes: 4 additions & 4 deletions estimage/webapp/templates/general_retro.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "base.html" %}

{% block navbar_secondary_common %}
{{ render_nav_item(head_prefix ~ 'main.overview_retro', 'Overview') }}
{{ render_nav_item(head_prefix ~ 'main.tree_view_retro', 'Tree View') }}
{{ render_nav_item(head_prefix ~ 'persons.retrospective_workload', 'Workloads') }}
{{ render_nav_item(head_prefix ~ 'main.completion', 'Completion') }}
{{ render_nav_item(get_head_absolute_endpoint('main.overview_retro'), 'Overview') }}
{{ render_nav_item(get_head_absolute_endpoint('main.tree_view_retro'), 'Tree View') }}
{{ render_nav_item(get_head_absolute_endpoint('persons.retrospective_workload'), 'Workloads') }}
{{ render_nav_item(get_head_absolute_endpoint('main.completion'), 'Completion') }}
{% endblock %}
8 changes: 4 additions & 4 deletions estimage/webapp/templates/issue_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{ utils.accordion_with_stuff(
"Estimation", estimate_exists,
("Modify" if estimate_exists else "Create") ~ " the estimate",
render_form(forms["estimation"], button_map={"submit": "primary", "delete": "danger"}, action=relative_url_for("main.estimate", task_name=task.name))
render_form(forms["estimation"], button_map={"submit": "primary", "delete": "danger"}, action=head_url_for("main.estimate", task_name=task.name))
)
}}
{%- endmacro %}
Expand Down Expand Up @@ -64,7 +64,7 @@ <h2>Estimates</h2>
{%- endif %}
</div>
<div class="col">
<img src="{{ relative_url_for('vis.visualize_task', task_name=task.name, nominal_or_remaining='nominal') }}" alt="PERT prob density function for {{ task.name }}"/>
<img src="{{ head_url_for('vis.visualize_task', task_name=task.name, nominal_or_remaining='nominal') }}" alt="PERT prob density function for {{ task.name }}"/>
</div>
</div>
{% if forms %}
Expand All @@ -74,7 +74,7 @@ <h3>Tracker values</h3>
<p>
{{ task_authoritative() | indent(8) -}}
{% if "authoritative" in forms -%}
{{ render_form(forms["authoritative"], action=relative_url_for("main.move_consensus_estimate_to_authoritative", task_name=task.name)) }}
{{ render_form(forms["authoritative"], action=head_url_for("main.move_consensus_estimate_to_authoritative", task_name=task.name)) }}
{%- endif %}
</p>
</div>
Expand All @@ -84,7 +84,7 @@ <h3>Consensus values</h3>
<p>Point cost: {{ utils.render_estimate(context.global_estimate) }}</p>
{% endif %}
{% if "consensus" in forms %}
{{ render_form(forms["consensus"], button_map={"submit": "primary", "delete": "danger"}, action=relative_url_for("main.move_issue_estimate_to_consensus", task_name=task.name)) }}
{{ render_form(forms["consensus"], button_map={"submit": "primary", "delete": "danger"}, action=head_url_for("main.move_issue_estimate_to_consensus", task_name=task.name)) }}
{% endif %}
</div>
<div class="col">
Expand Down
4 changes: 2 additions & 2 deletions estimage/webapp/templates/retrospective_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>Burndown</h2>
</ul>
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_overall_burndown', tier=0, size="wide") }}" alt="Overall Burndown"/>
<img src="{{ head_url_for('vis.visualize_overall_burndown', tier=0, size="wide") }}" alt="Overall Burndown"/>
</p>
{% endblock %}
</div>
Expand All @@ -35,7 +35,7 @@ <h2>Velocity</h2>
</ul>
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_velocity', epic_name='.') }}" alt="Overall velocity"/>
<img src="{{ head_url_for('vis.visualize_velocity', epic_name='.') }}" alt="Overall velocity"/>
</p>
{% endblock %}
</div>
Expand Down
4 changes: 2 additions & 2 deletions estimage/webapp/templates/tree_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2>Remaining</h2>
Grand total: {{ utils.render_estimate(model.remaining_point_estimate) }}
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_task', task_name='.', nominal_or_remaining='remaining') }}" alt="PERT prob density function for everything"/>
<img src="{{ head_url_for('vis.visualize_task', task_name='.', nominal_or_remaining='remaining') }}" alt="PERT prob density function for everything"/>
</p>
</div>
<div class="col">
Expand All @@ -21,7 +21,7 @@ <h2>Nominal</h2>
Grand total: {{ utils.render_estimate(model.nominal_point_estimate) }}
</p>
<p>
<img src="{{ relative_url_for('vis.visualize_task', task_name='.', nominal_or_remaining='nominal') }}" alt="PERT prob density function for everything"/>
<img src="{{ head_url_for('vis.visualize_task', task_name='.', nominal_or_remaining='nominal') }}" alt="PERT prob density function for everything"/>
</p>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions estimage/webapp/templates/utils.j2
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</div>
{% if model.remaining_point_estimate_of(epic.name).expected > 0 %}
<div class="col">
<img src="{{ relative_url_for('vis.visualize_epic_burndown', epic_name=epic.name, size="small") }}" alt="Epic Burndown"/>
<img src="{{ head_url_for('vis.visualize_epic_burndown', epic_name=epic.name, size="small") }}" alt="Epic Burndown"/>
</div>
{% endif %}
</div>
Expand All @@ -65,7 +65,7 @@
{% endmacro %}

{% macro refresh_whatever(target, mode, next) -%}
<a href="{{ relative_url_for("main.refresh_single", name=target.name, mode=mode, next=next) }}">{{ render_icon("arrow-clockwise") }}</a>
<a href="{{ head_url_for("main.refresh_single", name=target.name, mode=mode, next=next) }}">{{ render_icon("arrow-clockwise") }}</a>
{%- endmacro %}

{% set task_type_to_function = {
Expand All @@ -74,15 +74,15 @@
} %}

{% macro task_link(task, type) -%}
<a href="{{ relative_url_for(task_type_to_function[type], task_name=task.name) }}">{{ task.name }}</a>&nbsp;<a href="{{ task.uri }}" rel="external">{{ render_icon("box-arrow-up-right") }}</a>
<a href="{{ head_url_for(task_type_to_function[type], task_name=task.name) }}">{{ task.name }}</a>&nbsp;<a href="{{ task.uri }}" rel="external">{{ render_icon("box-arrow-up-right") }}</a>
{%- endmacro %}

{% macro epic_external_link(epic) -%}
<a href="{{ epic.uri }}" rel="external">{{ render_icon("box-arrow-up-right") }}</a>
{%- endmacro %}

{% macro epic_link(epic, endpoint="main.view_epic") -%}
<a href="{{ relative_url_for(endpoint, epic_name=epic.name) }}">{{ epic.name }}</a>&nbsp;{{ epic_external_link(epic) }}
<a href="{{ head_url_for(endpoint, epic_name=epic.name) }}">{{ epic.name }}</a>&nbsp;{{ epic_external_link(epic) }}
{%- endmacro %}

{% macro render_state_short(state) -%}
Expand Down Expand Up @@ -212,7 +212,7 @@
{% if refresh_form %}
<div class="col">
{{ caller() }}
{{ render_form(refresh_form, action=relative_url_for("main.refresh")) }}
{{ render_form(refresh_form, action=head_url_for("main.refresh")) }}
</div>
{% endif %}
{%- endmacro %}
Loading

0 comments on commit 12b30aa

Please sign in to comment.