Manage notification channels separately and migrate

It's more convenient to manage notification channels separately, as it
is done with email settings. Notification hook and other forms are
adopted to only select channels. Hooks can now use more than one
channel.
This commit is contained in:
eikek
2022-01-19 21:51:18 +01:00
parent d41490dd88
commit 23cb34a6ff
78 changed files with 2583 additions and 1422 deletions

View File

@@ -16,6 +16,7 @@ import Comp.ChangePasswordForm
import Comp.DueItemsTaskManage
import Comp.EmailSettingsManage
import Comp.ImapSettingsManage
import Comp.NotificationChannelManage
import Comp.NotificationHookManage
import Comp.OtpSetup
import Comp.PeriodicQueryTaskManage
@@ -35,6 +36,7 @@ type alias Model =
, uiSettingsModel : Comp.UiSettingsManage.Model
, otpSetupModel : Comp.OtpSetup.Model
, notificationHookModel : Comp.NotificationHookManage.Model
, channelModel : Comp.NotificationChannelManage.Model
, periodicQueryModel : Comp.PeriodicQueryTaskManage.Model
}
@@ -53,6 +55,9 @@ init flags settings =
( pqm, pqc ) =
Comp.PeriodicQueryTaskManage.init flags
( ncm, ncc ) =
Comp.NotificationChannelManage.init flags
in
( { currentTab = Just UiSettingsTab
, changePassModel = Comp.ChangePasswordForm.emptyModel
@@ -64,12 +69,14 @@ init flags settings =
, otpSetupModel = otpm
, notificationHookModel = nhm
, periodicQueryModel = pqm
, channelModel = ncm
}
, Cmd.batch
[ Cmd.map UiSettingsMsg uc
, Cmd.map OtpSetupMsg otpc
, Cmd.map NotificationHookMsg nhc
, Cmd.map PeriodicQueryMsg pqc
, Cmd.map ChannelMsg ncc
]
)
@@ -85,6 +92,7 @@ type Tab
| ScanMailboxTab
| UiSettingsTab
| OtpTab
| ChannelTab
type Msg
@@ -98,5 +106,6 @@ type Msg
| OtpSetupMsg Comp.OtpSetup.Msg
| NotificationHookMsg Comp.NotificationHookManage.Msg
| PeriodicQueryMsg Comp.PeriodicQueryTaskManage.Msg
| ChannelMsg Comp.NotificationChannelManage.Msg
| UpdateSettings
| ReceiveBrowserSettings StoredUiSettings

View File

@@ -11,6 +11,7 @@ import Comp.ChangePasswordForm
import Comp.DueItemsTaskManage
import Comp.EmailSettingsManage
import Comp.ImapSettingsManage
import Comp.NotificationChannelManage
import Comp.NotificationHookManage
import Comp.OtpSetup
import Comp.PeriodicQueryTaskManage
@@ -71,8 +72,12 @@ update flags settings msg model =
}
NotificationWebhookTab ->
let
( _, nc ) =
Comp.NotificationHookManage.init flags
in
{ model = m
, cmd = Cmd.none
, cmd = Cmd.map NotificationHookMsg nc
, sub = Sub.none
, newSettings = Nothing
}
@@ -107,6 +112,9 @@ update flags settings msg model =
OtpTab ->
UpdateResult m Cmd.none Sub.none Nothing
ChannelTab ->
UpdateResult m Cmd.none Sub.none Nothing
ChangePassMsg m ->
let
( m2, c2 ) =
@@ -195,6 +203,17 @@ update flags settings msg model =
, newSettings = Nothing
}
ChannelMsg lm ->
let
( cm, cc ) =
Comp.NotificationChannelManage.update flags lm model.channelModel
in
{ model = { model | channelModel = cm }
, cmd = Cmd.map ChannelMsg cc
, sub = Sub.none
, newSettings = Nothing
}
UpdateSettings ->
update flags
settings

View File

@@ -11,6 +11,7 @@ import Comp.ChangePasswordForm
import Comp.DueItemsTaskManage
import Comp.EmailSettingsManage
import Comp.ImapSettingsManage
import Comp.NotificationChannelManage
import Comp.NotificationHookManage
import Comp.OtpSetup
import Comp.PeriodicQueryTaskManage
@@ -77,7 +78,7 @@ viewSidebar texts visible _ _ model =
, menuEntryActive model NotificationTab
, class S.sidebarLink
]
[ i [ class "fa fa-bullhorn" ] []
[ i [ class "fa fa-comment font-thin" ] []
, span
[ class "ml-3" ]
[ text texts.notifications ]
@@ -121,6 +122,17 @@ viewSidebar texts visible _ _ model =
]
]
]
, a
[ href "#"
, onClick (SetTab ChannelTab)
, menuEntryActive model ChannelTab
, class S.sidebarLink
]
[ i [ class "fa fa-bullhorn" ] []
, span
[ class "ml-3" ]
[ text texts.channelSettings ]
]
, a
[ href "#"
, onClick (SetTab ScanMailboxTab)
@@ -217,6 +229,9 @@ viewContent texts flags settings model =
Just OtpTab ->
viewOtpSetup texts settings model
Just ChannelTab ->
viewChannels texts settings model
Nothing ->
[]
)
@@ -235,6 +250,26 @@ menuEntryActive model tab =
class ""
viewChannels : Texts -> UiSettings -> Model -> List (Html Msg)
viewChannels texts settings model =
[ h2
[ class S.header1
, class "inline-flex items-center"
]
[ i [ class "fa fa-bell" ] []
, div [ class "ml-3" ]
[ text texts.channels
]
]
, Markdown.toHtml [ class "opacity-80 text-lg mb-3 markdown-preview" ] texts.channelInfoText
, Html.map ChannelMsg
(Comp.NotificationChannelManage.view texts.channelManage
settings
model.channelModel
)
]
viewOtpSetup : Texts -> UiSettings -> Model -> List (Html Msg)
viewOtpSetup texts _ model =
[ h2