minor code cleaning

dev
Philippe Pittoli 2024-02-29 19:32:25 +01:00
parent 8f75a4e88b
commit bf97e0bc60
1 changed files with 21 additions and 28 deletions

View File

@ -42,7 +42,7 @@ import App.AcceptedRRTypes (AcceptedRRTypes(..))
import App.ResourceRecord (ResourceRecord, emptyRR import App.ResourceRecord (ResourceRecord, emptyRR
, show_qualifier, show_mechanism_type , show_qualifier, show_mechanism_type
, mechanism_types, qualifier_types, modifier_types) , mechanism_types, qualifier_types, modifier_types)
import App.ResourceRecord (Mechanism(..), Modifier(..), Qualifier(..)) as RR import App.ResourceRecord (Mechanism, Modifier, Qualifier) as RR
import App.DisplayErrors (error_to_paragraph) import App.DisplayErrors (error_to_paragraph)
@ -145,10 +145,10 @@ data Action
-- | Ask `dnsmanagerd` for the generated zone file. -- | Ask `dnsmanagerd` for the generated zone file.
| AskZoneFile | AskZoneFile
| SPF_Select_Mechanism_q Int | SPF_Mechanism_q Int
| SPF_Select_Mechanism_t Int | SPF_Mechanism_t Int
| SPF_Select_Modifier Int | SPF_Modifier Int
| SPF_Select_Qualifier Int | SPF_Qualifier Int
data RRModal data RRModal
= NoModal = NoModal
@ -193,10 +193,10 @@ type State =
-- Unique RR form. -- Unique RR form.
, _currentRR :: ResourceRecord , _currentRR :: ResourceRecord
, _currentRR_errors :: Array Validation.Error , _currentRR_errors :: Array Validation.Error
, _current_selected_mechanism_q :: String , spf_mechanism_q :: String
, _current_selected_mechanism_t :: String , spf_mechanism_t :: String
, _current_selected_modifier :: String , spf_modifier :: String
, _current_selected_qualifier :: String , spf_qualifier :: String
, _zonefile :: Maybe String , _zonefile :: Maybe String
} }
@ -240,10 +240,10 @@ initialState domain =
, _currentRR_errors: [] , _currentRR_errors: []
, _zonefile: Nothing , _zonefile: Nothing
, _current_selected_mechanism_q: "pass" , spf_mechanism_q: "pass"
, _current_selected_mechanism_t: "a" , spf_mechanism_t: "a"
, _current_selected_modifier: "redirect" , spf_modifier: "redirect"
, _current_selected_qualifier: "none" , spf_qualifier: "none"
} }
type SortableRecord l = Record (rrtype :: String, rrid :: Int | l) type SortableRecord l = Record (rrtype :: String, rrid :: Int | l)
@ -396,17 +396,17 @@ render state
, maybe (Bulma.p "no mechanism") display_mechanisms state._currentRR.mechanisms , maybe (Bulma.p "no mechanism") display_mechanisms state._currentRR.mechanisms
, Bulma.box , Bulma.box
[ Bulma.h3 "New mechanism" [ Bulma.h3 "New mechanism"
, Bulma.selection SPF_Select_Mechanism_q qualifier_types state._current_selected_mechanism_q , Bulma.selection SPF_Mechanism_q qualifier_types state.spf_mechanism_q
, Bulma.selection SPF_Select_Mechanism_t mechanism_types state._current_selected_mechanism_t , Bulma.selection SPF_Mechanism_t mechanism_types state.spf_mechanism_t
] ]
, Bulma.hr , Bulma.hr
, Bulma.box , Bulma.box
[ Bulma.h3 "New modifier" [ Bulma.h3 "New modifier"
, Bulma.selection SPF_Select_Modifier modifier_types state._current_selected_modifier , Bulma.selection SPF_Modifier modifier_types state.spf_modifier
] ]
, Bulma.box , Bulma.box
[ Bulma.h3 "Default behavior" [ Bulma.h3 "Default behavior"
, Bulma.selection SPF_Select_Qualifier qualifier_types state._current_selected_qualifier , Bulma.selection SPF_Qualifier qualifier_types state.spf_qualifier
] ]
] ]
@ -543,17 +543,10 @@ handleAction = case _ of
$ DNSManager.MkAskGeneratedZoneFile { domain: state._domain } $ DNSManager.MkAskGeneratedZoneFile { domain: state._domain }
H.raise $ MessageToSend message H.raise $ MessageToSend message
SPF_Select_Mechanism_q v -> do SPF_Mechanism_q v -> H.modify_ _ { spf_mechanism_q = maybe "pass" id $ qualifier_types A.!! v }
H.modify_ _ { _current_selected_mechanism_q = maybe "pass" id $ qualifier_types A.!! v } SPF_Mechanism_t v -> H.modify_ _ { spf_mechanism_t = maybe "a" id $ mechanism_types A.!! v }
SPF_Modifier v -> H.modify_ _ { spf_modifier = maybe "redirect" id $ modifier_types A.!! v }
SPF_Select_Mechanism_t v -> do SPF_Qualifier v -> H.modify_ _ { spf_qualifier = maybe "none" id $ qualifier_types A.!! v }
H.modify_ _ { _current_selected_mechanism_t = maybe "a" id $ mechanism_types A.!! v }
SPF_Select_Modifier v -> do
H.modify_ _ { _current_selected_modifier = maybe "redirect" id $ modifier_types A.!! v }
SPF_Select_Qualifier v -> do
H.modify_ _ { _current_selected_qualifier = maybe "none" id $ qualifier_types A.!! v }
handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a) handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a)
handleQuery = case _ of handleQuery = case _ of