Add email service and settings

This commit is contained in:
2023-12-23 12:26:34 +01:00
parent aab6793b86
commit 958d18d61a
24 changed files with 506 additions and 35 deletions

View File

@@ -0,0 +1,16 @@
<h3>E-Mail</h3>
<ul role="list">
<%= render FormElements::FieldsetToggleComponent.new(
form: f,
attribute: :email_enabled,
enabled: Setting.email_enabled?,
title: "Enable E-Mail service integration",
description: "Enable/configure LDAP attributes for use with a mail server"
) %>
<%# <% if Setting.email_enabled? %>
<%# <%= render FormElements::FieldsetResettableSettingComponent.new(
<%# key: :gitea_public_url,
<%# title: "Public URL"
<%# ) %>
<%# <% end %>
</ul>

View File

@@ -32,6 +32,17 @@
<% end %>
</div>
<% end %>
<% if Setting.email_enabled? &&
Flipper.enabled?(:email, current_user) %>
<div class="border border-gray-300 rounded-md hover:border-gray-400">
<%= link_to services_email_path, class: "block h-full px-6 py-6 rounded-md" do %>
<h3 class="mb-3.5">E-Mail</h3>
<p class="text-gray-600">
A no-bullshit email account
</p>
<% end %>
</div>
<% end %>
<% if Setting.discourse_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400
bg-[length:95%] bg-center bg-no-repeat
@@ -58,6 +69,18 @@
<% end %>
</div>
<% end %>
<% if Setting.remotestorage_enabled? &&
Flipper.enabled?(:remotestorage, current_user) %>
<div class="border border-gray-300 rounded-md hover:border-gray-400">
<%= link_to services_storage_path,
class: "block h-full px-6 py-6 rounded-md" do %>
<h3 class="mb-3.5">Storage</h3>
<p class="text-gray-600">
Sync your data between apps and devices
</p>
<% end %>
</div>
<% end %>
<% if Setting.gitea_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400
bg-cover bg-center bg-no-repeat
@@ -84,18 +107,6 @@
<% end %>
</div>
<% end %>
<% if Setting.remotestorage_enabled? &&
Flipper.enabled?(:remotestorage, current_user) %>
<div class="border border-gray-300 rounded-md hover:border-gray-400">
<%= link_to services_storage_path,
class: "block h-full px-6 py-6 rounded-md" do %>
<h3 class="mb-3.5">Storage</h3>
<p class="text-gray-600">
Sync your data between apps and devices
</p>
<% end %>
</div>
<% end %>
<% if Setting.mediawiki_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400
bg-cover bg-[center_top_-20px] bg-no-repeat

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-mail"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-mail <%= custom_class %>"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 375 B

View File

@@ -0,0 +1,35 @@
<%= render HeaderCompactComponent.new(title: "New E-Mail Password") %>
<%= render MainCompactComponent.new do %>
<section data-controller="modal" data-action="keydown.esc->modal#close">
<p class="font-bold">
Your email password has been updated.
</p>
<p class="mb-8">
Please store the new one in a password manager or write it down somewhere:
</p>
<p data-controller="clipboard" class="flex gap-1 w-full mb-10">
<%= label_tag :new_password, 'New password', class: 'hidden' %>
<%= text_field_tag :new_password, @new_password, disabled: true, class: 'text-xl grow',
data: { "clipboard-target": "source"} %>
<button id="copy-new-password" class="btn-md btn-icon btn-outline shrink-0"
data-clipboard-target="trigger" data-action="clipboard#copy"
title="Copy to clipboard">
<span class="content-initial">
<%= render partial: "icons/copy", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
</span>
<span class="content-active hidden">
<%= render partial: "icons/check", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
</span>
</button>
<button class="btn-md btn-icon btn-outline shrink-0 w-auto"
data-action="click->modal#open" title="Show QR code">
<%= render partial: "icons/qr_code", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
</button>
</p>
<p class="mb-0">
<%= link_to "Done", services_email_path, class: "btn-md btn-blue w-full" %>
</p>
<%= render QrCodeModalComponent.new(qr_content: @new_password) %>
</section>
<% end %>

View File

@@ -0,0 +1,128 @@
<%= render HeaderComponent.new(title: "E-Mail") %>
<%= render MainSimpleComponent.new do %>
<section>
<p class="mb-6">
Send and receive electronic mail.
</p>
</section>
<section data-controller="modal" data-action="keydown.esc->modal#close">
<h3>Your E-Mail Address</h3>
<p data-controller="clipboard" class="flex gap-1 sm:w-2/5">
<input type="text" id="user_address" class="grow"
value=<%= current_user.address %> disabled="disabled"
data-clipboard-target="source" />
<button id="copy-user-address" class="btn-md btn-icon btn-outline shrink-0"
data-clipboard-target="trigger" data-action="clipboard#copy"
title="Copy to clipboard">
<span class="content-initial">
<%= render partial: "icons/copy", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
</span>
<span class="content-active hidden">
<%= render partial: "icons/check", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
</span>
</button>
<button class="btn-md btn-icon btn-outline shrink-0 w-auto"
data-action="click->modal#open" title="Show QR code">
<%= render partial: "icons/qr_code", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
</button>
</p>
<%= render QrCodeModalComponent.new(qr_content: "xmpp:"+current_user.address) %>
</section>
<section>
<h3>E-Mail Password</h3>
<p>
Your email password is different from your main account password. You can
reset your email password in the
<%= link_to "email settings", setting_path(:email), class: "ks-text-link" %>.
</p>
</section>
<section>
<h3>Recommended Apps</h3>
<div data-controller="tabs"
data-tabs-active-tab-class="-mb-px border-gray-200 border-l border-t border-r rounded-t text-indigo-600 hover:text-indigo-600"
data-tabs-inactive-tab-class="text-gray-500 hover:text-gray-700"
class="mb-12">
<select data-action="tabs#change" data-tabs-target="select"
class="block w-full mb-8 sm:hidden">
<optgroup label="Mobile">
<option>Android</option>
</optgroup>
<optgroup label="Desktop">
<option>Linux</option>
<option>Windows</option>
<option>macOS</option>
</optgroup>
</select>
<ul class="hidden sm:flex list-reset mb-8 border-gray-200 border-b">
<li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
<a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
Android
</a>
</li>
<li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
<a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
Linux
</a>
</li>
<li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
<a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
Windows
</a>
</li>
<li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
<a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
macOS
</a>
</li>
</ul>
<div id="apps-android" class="hidden grid grid-cols-1 gap-6"
data-tabs-target="panel">
<%= render AppInfoComponent.new(
name: "K-9 Mail",
description: "Soon to become Thunderbird Mobile",
icon_path: "/img/logos/icon_k9-mail.png",
links: [
["Website", "https://k9mail.app"],
["Google Play", "https://play.google.com/store/apps/details?id=com.fsck.k9"],
["F-Droid", "https://f-droid.org/en/packages/com.fsck.k9/"],
]
) %>
</div>
<div id="apps-linux" class="hidden grid grid-cols-1 gap-6"
data-tabs-target="panel">
<%= render AppInfoComponent.new(
name: "Thunderbird",
description: "The most popular open-source email app",
icon_path: "/img/logos/icon_thunderbird.png",
links: [
["Website", "https://www.thunderbird.net"]
]
) %>
</div>
<div id="apps-windows" class="hidden grid grid-cols-1 gap-6"
data-tabs-target="panel">
<%= render AppInfoComponent.new(
name: "Thunderbird",
description: "The most popular open-source email app",
icon_path: "/img/logos/icon_thunderbird.png",
links: [
["Website", "https://www.thunderbird.net"]
]
) %>
</div>
<div id="apps-mac" class="hidden grid grid-cols-1 gap-6"
data-tabs-target="panel">
<%= render AppInfoComponent.new(
name: "Thunderbird",
description: "The most popular open-source email app",
icon_path: "/img/logos/icon_thunderbird.png",
links: [
["Website", "https://www.thunderbird.net"]
]
) %>
</div>
</div>
</section>
<% end %>

View File

@@ -0,0 +1,34 @@
<%= tag.section data: {
controller: "settings--email--password",
"settings--email--password-validation-failed-value": @validation_errors.present?
} do %>
<h3>E-Mail Password</h3>
<%= form_for(@user, url: reset_email_password_settings_path, method: "post") do |f| %>
<%= hidden_field_tag :section, "email" %>
<p class="mb-8">
Use the following button to generate a new email password:
</p>
<p class="hidden initial-visible">
<button type="button" id="edit-email" class="btn-md btn-gray"
data-settings--email--password-target="resetPasswordButton"
data-action="settings--email--password#showPasswordReset">
Reset email password
</button>
</p>
<div class="initial-hidden">
<p class="mt-4 mb-2">
<%= f.label :current_password, 'Current account password', class: 'font-bold' %>
</p>
<p class="sm:w-3/5">
<%= f.password_field :current_password, class: "w-full", required: true,
data: { 'settings--email--password-target': "currentPasswordField" } %>
</p>
<% if @validation_errors.present? && @validation_errors[:current_password].present? %>
<p class="error-msg"><%= @validation_errors[:current_password].first %></p>
<% end %>
<p class="mt-6">
<%= f.submit "Create new email password", class: "btn-md btn-blue w-full md:w-auto" %>
</p>
</div>
<% end %>
<% end %>

View File

@@ -19,6 +19,13 @@
text_icon: Setting.droneci_enabled? ? "◉" : "○",
active: current_page?(admin_settings_services_path(params: { s: "droneci" })),
) %>
<%= render SidenavLinkComponent.new(
level: 2,
name: "E-Mail",
path: admin_settings_services_path(params: { s: "email" }),
text_icon: Setting.email_enabled? ? "◉" : "○",
active: current_page?(admin_settings_services_path(params: { s: "email" })),
) %>
<%= render SidenavLinkComponent.new(
level: 2,
name: "ejabberd",

View File

@@ -12,13 +12,21 @@
active: @settings_section.to_s == "xmpp"
) %>
<% end %>
<% if Setting.email_enabled? &&
Flipper.enabled?(:email, current_user) %>
<%= render SidenavLinkComponent.new(
name: "E-Mail", path: setting_path(:email), icon: "mail",
active: @settings_section.to_s == "email"
) %>
<% end %>
<% if Setting.lndhub_enabled %>
<%= render SidenavLinkComponent.new(
name: "Lightning", path: setting_path(:lightning), icon: "zap",
active: @settings_section.to_s == "lightning"
) %>
<% end %>
<% if Setting.remotestorage_enabled %>
<% if Setting.remotestorage_enabled? &&
Flipper.enabled?(:remotestorage, current_user) %>
<%= render SidenavLinkComponent.new(
name: "Storage", path: setting_path(:remotestorage), icon: "remotestorage",
active: @settings_section.to_s == "remotestorage"