[UI][SETTINGS] User notification settings with configurable transports (through plugins)

This commit is contained in:
Hugo Sales 2020-08-05 23:05:06 +00:00 committed by Hugo Sales
parent 0230dd04df
commit 5a68fd287b
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 42 additions and 3 deletions

View File

@ -130,13 +130,32 @@ class UserPanel extends AbstractController
$val = $type->convertToPHPValue($col->getDefault(), $platform); $val = $type->convertToPHPValue($col->getDefault(), $platform);
$type_str = lcfirst(substr((string) $type, 1)); $type_str = lcfirst(substr((string) $type, 1));
$label = str_replace('_', ' ', ucfirst($name)); $label = str_replace('_', ' ', ucfirst($name));
$labels = [
'target_profile_id' => 'Target Profiles',
'dm' => 'DM',
];
$help = [
'target_profile_id' => 'If specified, these settings apply only to these profiles (comma- or space-separated list)',
'activity_by_followed' => 'Notify me when someone I follow has new activity',
'mention' => 'Notify me when mentions me in a notice',
'reply' => 'Notify me when someone replies to a notice made by me',
'follow' => 'Notify me when someone follows me or asks for permission to do so',
'favorite' => 'Notify me when someone favorites one of my notices',
'nudge' => 'Notify me when someone nudges me',
'dm' => 'Notify me when someone sends me a direct message',
'post_on_status_change' => 'Post a notice when my status in this service changes',
'enable_posting' => 'Enable posting from this service',
];
switch ($type_str) { switch ($type_str) {
case Types::BOOLEAN: case Types::BOOLEAN:
$form_defs['placeholder'][] = [$name, CheckboxType::class, ['data' => $val, 'label' => $label, 'help' => _m($col->getComment())]]; $form_defs['placeholder'][$name] = [$name, CheckboxType::class, ['data' => $val, 'label' => _m($labels[$name] ?? $label), 'help' => _m($help[$name])]];
break; break;
case Types::INTEGER: case Types::INTEGER:
if ($name == 'target_profile_id') { if ($name == 'target_profile_id') {
$form_defs['placeholder'][] = ['target_profiles', TextType::class, ['data' => $val, 'label' => $label, 'help' => _m($col->getComment())], 'transformer' => ProfileArrayTransformer::class]; $form_defs['placeholder'][$name] = ['target_profiles', TextType::class, ['data' => $val, 'label' => _m($labels[$name]), 'help' => _m($help[$name])], 'transformer' => ProfileArrayTransformer::class];
break; break;
} }
// no break // no break
@ -154,6 +173,9 @@ class UserPanel extends AbstractController
} }
$tabbed_forms = F\map($tabbed_forms, function ($f) { return $f->createView(); }); $tabbed_forms = F\map($tabbed_forms, function ($f) { return $f->createView(); });
return ['_template' => 'settings/notifications.html.twig', 'tabbed_forms' => $tabbed_forms]; return [
'_template' => 'settings/notifications.html.twig',
'tabbed_forms' => $tabbed_forms,
];
} }
} }

View File

@ -2,6 +2,23 @@
{% block title %}Notification Settings{% endblock %} {% block title %}Notification Settings{% endblock %}
{% block stylesheets %}
{{ parent() }}
<style>
.form {
display: none;
clip-path: polygon(0 0);
}
{% for transport, form in tabbed_forms %}
#form_toggle_{{ transport }}:checked ~ #form_{{ transport }} {
display: flex;
clip-path: none;
}
{% endfor %}
</style>
{% endblock %}
{% block body %} {% block body %}
<div class='content'> <div class='content'>
{% block primary_nav %} {% block primary_nav %}