Skip to content

Commit

Permalink
MDL-80259 theme_boost: Refactor badge helper classes for Bootstrap 5
Browse files Browse the repository at this point in the history
  • Loading branch information
roland04 committed Jan 23, 2024
1 parent 810554e commit a198884
Show file tree
Hide file tree
Showing 93 changed files with 218 additions and 209 deletions.
2 changes: 1 addition & 1 deletion admin/classes/table/hook_list_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected function get_tags_for_row(stdClass $row): string {
if (is_array($tag)) {
return $this->get_tag(...$tag);
}
return $this->get_tag($tag, 'badge badge-info');
return $this->get_tag($tag, 'badge bg-info text-white');
}, $tags);

return implode("\n", $taglist);
Expand Down
56 changes: 30 additions & 26 deletions admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,11 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar

if ($isstandard = $plugin->is_standard()) {
$row->attributes['class'] .= ' standard';
$sourcelabel = html_writer::span(get_string('sourcestd', 'core_plugin'), 'sourcetext badge badge-secondary');
$sourcelabel = html_writer::span(get_string('sourcestd', 'core_plugin'),
'sourcetext badge bg-secondary text-dark');
} else {
$row->attributes['class'] .= ' extension';
$sourcelabel = html_writer::span(get_string('sourceext', 'core_plugin'), 'sourcetext badge badge-info');
$sourcelabel = html_writer::span(get_string('sourceext', 'core_plugin'), 'sourcetext badge bg-info text-white');
}

$coredependency = $plugin->is_core_dependency_satisfied($version);
Expand All @@ -1128,19 +1129,19 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar
$statusclass = 'statustext badge ';
switch ($statuscode) {
case core_plugin_manager::PLUGIN_STATUS_NEW:
$statusclass .= $dependenciesok ? 'badge-success' : 'badge-warning';
$statusclass .= $dependenciesok ? 'bg-success text-white' : 'bg-warning text-dark';
break;
case core_plugin_manager::PLUGIN_STATUS_UPGRADE:
$statusclass .= $dependenciesok ? 'badge-info' : 'badge-warning';
$statusclass .= $dependenciesok ? 'bg-info text-white' : 'bg-warning text-dark';
break;
case core_plugin_manager::PLUGIN_STATUS_MISSING:
case core_plugin_manager::PLUGIN_STATUS_DOWNGRADE:
case core_plugin_manager::PLUGIN_STATUS_DELETE:
$statusclass .= 'badge-danger';
$statusclass .= 'bg-danger text-white';
break;
case core_plugin_manager::PLUGIN_STATUS_NODB:
case core_plugin_manager::PLUGIN_STATUS_UPTODATE:
$statusclass .= $dependenciesok ? 'badge-light' : 'badge-warning';
$statusclass .= $dependenciesok ? 'bg-light text-dark' : 'bg-warning text-dark';
break;
}
$status = html_writer::span(get_string('status_' . $statuscode, 'core_plugin'), $statusclass);
Expand Down Expand Up @@ -1263,11 +1264,11 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar
}

$out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('showallplugins' => 0)),
get_string('plugincheckattention', 'core_plugin')).' '.html_writer::span($sumattention, 'badge badge-light'),
get_string('plugincheckattention', 'core_plugin')).' '.html_writer::span($sumattention, 'badge bg-light text-dark'),
'btn btn-link mr-1');

$out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('showallplugins' => 1)),
get_string('plugincheckall', 'core_plugin')).' '.html_writer::span($sumtotal, 'badge badge-light'),
get_string('plugincheckall', 'core_plugin')).' '.html_writer::span($sumtotal, 'badge bg-light text-dark'),
'btn btn-link mr-1');

$out .= $this->output->container_end(); // End of .actions container.
Expand Down Expand Up @@ -1420,9 +1421,9 @@ protected function available_missing_dependencies_list(core_plugin_manager $plug
$supportedmoodles = array();
foreach ($plugin->version->supportedmoodles as $moodle) {
if ($CFG->branch == str_replace('.', '', $moodle->release)) {
$supportedmoodles[] = html_writer::span($moodle->release, 'badge badge-success');
$supportedmoodles[] = html_writer::span($moodle->release, 'badge bg-success text-white');
} else {
$supportedmoodles[] = html_writer::span($moodle->release, 'badge badge-light');
$supportedmoodles[] = html_writer::span($moodle->release, 'badge bg-light text-dark');
}
}

Expand Down Expand Up @@ -1528,7 +1529,7 @@ protected function required_column(\core\plugininfo\base $plugin, core_plugin_ma
$label = '';
} else {
$class = 'requires-failed';
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-danger');
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge bg-danger text-white');
}

if ($branch != null && !$plugin->is_core_compatible_satisfied($branch)) {
Expand Down Expand Up @@ -1557,33 +1558,36 @@ protected function required_column(\core\plugininfo\base $plugin, core_plugin_ma

} else if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_MISSING) {
if ($reqinfo->availability == $pluginman::REQUIREMENT_AVAILABLE) {
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'badge badge-warning');
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'badge badge-warning');
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'),
'badge bg-warning text-dark');
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'),
'badge bg-warning text-dark');
$class = 'requires-failed requires-missing requires-available';
$actions[] = html_writer::link(
new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $reqname)),
get_string('misdepinfoplugin', 'core_plugin')
);

} else {
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'badge badge-danger');
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'badge bg-danger text-white');
$label .= ' '.html_writer::span(get_string('dependencyunavailable', 'core_plugin'),
'badge badge-danger');
'badge bg-danger text-white');
$class = 'requires-failed requires-missing requires-unavailable';
}
$displayuploadlink = true;

} else if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OUTDATED) {
if ($reqinfo->availability == $pluginman::REQUIREMENT_AVAILABLE) {
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-warning');
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'badge badge-warning');
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge bg-warning text-dark');
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'),
'badge bg-warning text-dark');
$class = 'requires-failed requires-outdated requires-available';
$displayupdateslink = true;

} else {
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-danger');
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge bg-danger text-white');
$label .= ' '.html_writer::span(get_string('dependencyunavailable', 'core_plugin'),
'badge badge-danger');
'badge bg-danger text-white');
$class = 'requires-failed requires-outdated requires-unavailable';
}
$displayuploadlink = true;
Expand Down Expand Up @@ -1693,7 +1697,7 @@ public function plugins_overview_panel(core_plugin_manager $pluginman, array $op
new moodle_url($this->page->url, array('contribonly' => 0, 'updatesonly' => 1)),
get_string('overviewupdatable', 'core_plugin'),
array('title' => get_string('filterupdatesonly', 'core_plugin'))
).' '.html_writer::span($numupdatable, 'badge badge-info number number-updatable');
).' '.html_writer::span($numupdatable, 'badge bg-info text-white number number-updatable');
} else {
// No updates, or the notifications disabled.
$infoupdatable = '';
Expand Down Expand Up @@ -1868,13 +1872,13 @@ public function plugins_control_panel(core_plugin_manager $pluginman, array $opt
$source = '';
} else {
$row->attributes['class'] .= ' extension';
$source = html_writer::div(get_string('sourceext', 'core_plugin'), 'source badge badge-info');
$source = html_writer::div(get_string('sourceext', 'core_plugin'), 'source badge bg-info text-white');
}

if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
$msg = html_writer::div(get_string('status_missing', 'core_plugin'), 'statusmsg badge badge-danger');
$msg = html_writer::div(get_string('status_missing', 'core_plugin'), 'statusmsg badge bg-danger text-white');
} else if ($status === core_plugin_manager::PLUGIN_STATUS_NEW) {
$msg = html_writer::div(get_string('status_new', 'core_plugin'), 'statusmsg badge badge-success');
$msg = html_writer::div(get_string('status_new', 'core_plugin'), 'statusmsg badge bg-success text-white');
} else {
$msg = '';
}
Expand Down Expand Up @@ -2113,13 +2117,13 @@ public function environment_check_table($result, $environment_results) {
// Format error or warning line
if ($errorline) {
$messagetype = 'error';
$statusclass = 'badge-danger';
$statusclass = 'bg-danger text-white';
} else if ($warningline) {
$messagetype = 'warn';
$statusclass = 'badge-warning';
$statusclass = 'bg-warning text-dark';
} else {
$messagetype = 'ok';
$statusclass = 'badge-success';
$statusclass = 'bg-success text-white';
}
$status = html_writer::span($status, 'badge ' . $statusclass);
// Here we'll store all the feedback found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h1 class="bd-title" id="content">{{ .Title | markdownify }}</h1>
{{ if .Page.Params.tags }}
{{ range .Page.Params.tags }}

<div class="badge badge-info">{{.}}</div>
<div class="badge bg-info text-white">{{.}}</div>

{{ end }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ protected function get_other_values(renderer_base $output) {
switch ($this->persistent->get('status')) {
case api::DATAREQUEST_STATUS_PENDING:
case api::DATAREQUEST_STATUS_PREPROCESSING:
$values['statuslabelclass'] = 'badge-info';
$values['statuslabelclass'] = 'bg-info text-white';
// Request can be manually completed for general enquiry requests.
$values['canmarkcomplete'] = $requesttype == api::DATAREQUEST_TYPE_OTHERS;
break;
case api::DATAREQUEST_STATUS_AWAITING_APPROVAL:
$values['statuslabelclass'] = 'badge-info';
$values['statuslabelclass'] = 'bg-info text-white';
// DPO can review the request once it's ready.
$values['canreview'] = true;
// Whether the DPO can approve or deny the request.
Expand All @@ -180,24 +180,24 @@ protected function get_other_values(renderer_base $output) {
}
break;
case api::DATAREQUEST_STATUS_APPROVED:
$values['statuslabelclass'] = 'badge-info';
$values['statuslabelclass'] = 'bg-info text-white';
break;
case api::DATAREQUEST_STATUS_PROCESSING:
$values['statuslabelclass'] = 'badge-info';
$values['statuslabelclass'] = 'bg-info text-white';
break;
case api::DATAREQUEST_STATUS_COMPLETE:
case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
case api::DATAREQUEST_STATUS_DELETED:
$values['statuslabelclass'] = 'badge-success';
$values['statuslabelclass'] = 'bg-success text-white';
break;
case api::DATAREQUEST_STATUS_CANCELLED:
$values['statuslabelclass'] = 'badge-warning';
$values['statuslabelclass'] = 'bg-warning text-dark';
break;
case api::DATAREQUEST_STATUS_REJECTED:
$values['statuslabelclass'] = 'badge-danger';
$values['statuslabelclass'] = 'bg-danger text-white';
break;
case api::DATAREQUEST_STATUS_EXPIRED:
$values['statuslabelclass'] = 'badge-secondary';
$values['statuslabelclass'] = 'bg-secondary text-dark';
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public function export_for_template(renderer_base $output) {
$cancancel = true;
switch ($status) {
case api::DATAREQUEST_STATUS_COMPLETE:
$item->statuslabelclass = 'badge-success';
$item->statuslabelclass = 'bg-success text-white';
$item->statuslabel = get_string('statuscomplete', 'tool_dataprivacy');
$cancancel = false;
break;
case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
$item->statuslabelclass = 'badge-success';
$item->statuslabelclass = 'bg-success text-white';
$item->statuslabel = get_string('statusready', 'tool_dataprivacy');
$cancancel = false;
$candownload = true;
Expand All @@ -122,12 +122,12 @@ public function export_for_template(renderer_base $output) {
}
break;
case api::DATAREQUEST_STATUS_DELETED:
$item->statuslabelclass = 'badge-success';
$item->statuslabelclass = 'bg-success text-white';
$item->statuslabel = get_string('statusdeleted', 'tool_dataprivacy');
$cancancel = false;
break;
case api::DATAREQUEST_STATUS_EXPIRED:
$item->statuslabelclass = 'badge-secondary';
$item->statuslabelclass = 'bg-secondary text-dark';
$item->statuslabel = get_string('statusexpired', 'tool_dataprivacy');
$item->statuslabeltitle = get_string('downloadexpireduser', 'tool_dataprivacy');
$cancancel = false;
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/dataprivacy/templates/component_status.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
<span>{{#pix}}i/risk_xss, moodle, {{#str}}requiresattention, tool_dataprivacy{{/str}}{{/pix}}</span>
{{/compliant}}
{{#external}}
<span class="badge badge-pill badge-notice">{{#str}}external, tool_dataprivacy{{/str}}</span>
<span class="badge rounded-pill bg-info text-white">{{#str}}external, tool_dataprivacy{{/str}}</span>
{{/external}}
{{#deprecated}}
<span class="badge badge-pill badge-warning">{{#str}}deprecated, tool_dataprivacy{{/str}}</span>
<span class="badge rounded-pill bg-warning text-dark">{{#str}}deprecated, tool_dataprivacy{{/str}}</span>
{{/deprecated}}
{{#userlistnoncompliance}}
<span class="badge badge-pill badge-warning">{{#str}}userlistnoncompliant, tool_dataprivacy{{/str}}</span>
<span class="badge rounded-pill bg-warning text-dark">{{#str}}userlistnoncompliant, tool_dataprivacy{{/str}}</span>
{{/userlistnoncompliance}}
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
<dl>
<dt>{{#pix}}i/risk_xss, moodle, {{#str}}requiresattention, tool_dataprivacy{{/str}}{{/pix}}</dt>
<dd>{{#str}}requiresattentionexplanation, tool_dataprivacy{{/str}}</dd>
<dt><span class="badge badge-pill badge-notice">{{#str}}external, tool_dataprivacy{{/str}}</span></dt>
<dt><span class="badge rounded-pill bg-info text-white">{{#str}}external, tool_dataprivacy{{/str}}</span></dt>
<dd>{{#str}}externalexplanation, tool_dataprivacy{{/str}}</dd>
<dt><span class="badge badge-pill badge-warning">{{#str}}deprecated, tool_dataprivacy{{/str}}</span></dt>
<dt><span class="badge rounded-pill bg-warning text-dark">{{#str}}deprecated, tool_dataprivacy{{/str}}</span></dt>
<dd>{{#str}}deprecatedexplanation, tool_dataprivacy{{/str}}</dd>
<dt><span class="badge badge-pill badge-warning">{{#str}}userlistnoncompliant, tool_dataprivacy{{/str}}</span></dt>
<dt><span class="badge rounded-pill bg-warning text-dark">{{#str}}userlistnoncompliant, tool_dataprivacy{{/str}}</span></dt>
<dd>{{#str}}userlistexplanation, tool_dataprivacy{{/str}}</dd>
</dl>
<hr />
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/dataprivacy/templates/my_data_requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"id": 1,
"typename" : "Data export",
"comments": "I would like to download all of my daughter's personal data",
"statuslabelclass": "badge-secondary",
"statuslabelclass": "bg-secondary text-dark",
"statuslabel": "Pending",
"timecreated" : 1517902087,
"requestedbyuser" : {
Expand All @@ -47,7 +47,7 @@
"id": 2,
"typename" : "Data export",
"comments": "Give me all of the information you have about me, or else...",
"statuslabelclass": "badge-warning",
"statuslabelclass": "bg-warning text-dark",
"statuslabel": "Awaiting completion",
"timecreated" : 1517902087,
"requestedbyuser" : {
Expand All @@ -59,7 +59,7 @@
"id": 3,
"typename" : "Data deletion",
"comments": "Please delete all of my son's personal data.",
"statuslabelclass": "badge-success",
"statuslabelclass": "bg-success text-white",
"statuslabel": "Deleted",
"timecreated" : 1517902087,
"requestedbyuser" : {
Expand All @@ -83,7 +83,7 @@
"id": 5,
"typename" : "Data export",
"comments": "Please let me download my data",
"statuslabelclass": "badge-info",
"statuslabelclass": "bg-info text-white",
"statuslabel": "Processing",
"timecreated" : 1517902087,
"requestedbyuser" : {
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/dataprivacy/templates/request_details.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"profileurl": "#"
},
"statuslabel": "Pending",
"statuslabelclass": "badge-secondary",
"statuslabelclass": "bg-secondary text-dark",
"messagehtml": "<p>Hello,</p><p>I would like to download all of my personal data.</p><p>Thanks!</p>"
}
}}
Expand Down
Loading

0 comments on commit a198884

Please sign in to comment.