Render batch execution description as markdown

This commit is contained in:
Lance Edgar 2021-02-09 14:21:07 -06:00
parent cc2308c399
commit 5969515f25
2 changed files with 16 additions and 4 deletions

View file

@ -69,6 +69,10 @@
white-space: nowrap; white-space: nowrap;
} }
.markdown p {
margin-bottom: 1.5rem;
}
</style> </style>
% else: % else:
<style type="text/css"> <style type="text/css">
@ -203,6 +207,7 @@
${execute_title} ${execute_title}
</b-button> </b-button>
% if execute_enabled:
<b-modal has-modal-card <b-modal has-modal-card
:active.sync="showExecutionDialog"> :active.sync="showExecutionDialog">
<div class="modal-card"> <div class="modal-card">
@ -215,10 +220,11 @@
<p class="block has-text-weight-bold"> <p class="block has-text-weight-bold">
What will happen when this batch is executed? What will happen when this batch is executed?
</p> </p>
<p class="block"> <div class="markdown">
${handler.describe_execution(batch) or "TODO: handler does not provide a description for this batch"} ${execution_described|n}
</p> </div>
<${execute_form.component} ref="executeBatchForm"></${execute_form.component}> <${execute_form.component} ref="executeBatchForm">
</${execute_form.component}>
</section> </section>
<footer class="modal-card-foot"> <footer class="modal-card-foot">
@ -234,6 +240,7 @@
</div> </div>
</b-modal> </b-modal>
% endif
% else: % else:
## no buefy, do legacy thing ## no buefy, do legacy thing

View file

@ -38,6 +38,7 @@ from six import StringIO
import json import json
import six import six
import markdown
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
@ -175,6 +176,10 @@ class BatchMasterView(MasterView):
if kwargs['execute_enabled']: if kwargs['execute_enabled']:
url = self.get_action_url('execute', batch) url = self.get_action_url('execute', batch)
kwargs['execute_form'] = self.make_execute_form(batch, action_url=url) kwargs['execute_form'] = self.make_execute_form(batch, action_url=url)
description = (self.handler.describe_execution(batch)
or "TODO: handler does not provide a description for this batch")
kwargs['execution_described'] = markdown.markdown(
description, extensions=['fenced_code', 'codehilite'])
else: else:
kwargs['why_not_execute'] = self.handler.why_not_execute(batch) kwargs['why_not_execute'] = self.handler.why_not_execute(batch)