Enable to update the name servers used for delegation.
This commit is contained in:
parent
c13cc441bc
commit
bd20767989
4 changed files with 30 additions and 7 deletions
|
|
@ -41,7 +41,7 @@ import CSSClasses as C
|
|||
import App.Text.Explanations as Explanations
|
||||
|
||||
import App.Type.ResourceRecord as RR
|
||||
import App.Type.Delegation (mkEmptyDelegationForm, update, Form, Field) as Delegation
|
||||
import App.Type.Delegation (mkUpdateDelegationForm, mkEmptyDelegationForm, update, Form, Field) as Delegation
|
||||
import App.Type.RRModal (RRModal(..))
|
||||
import App.Type.ResourceRecord.DKIM as DKIM
|
||||
import App.Type.ResourceRecord.DMARC as DMARC
|
||||
|
|
@ -106,6 +106,9 @@ data Action
|
|||
-- | Delegation modal.
|
||||
| CreateDelegationModal
|
||||
|
||||
-- | Update Delegation modal.
|
||||
| UpdateDelegationModal Delegation
|
||||
|
||||
-- | Create modal (a form) for a resource record to update.
|
||||
| CreateUpdateRRModal RR.RRId
|
||||
|
||||
|
|
@ -271,7 +274,9 @@ render state
|
|||
, Web.ul [ HH.li_ [ Web.btn_ro [C.is_warning] delegation.nameserver1 ]
|
||||
, HH.li_ [ Web.btn_ro [C.is_warning] delegation.nameserver2 ]
|
||||
]
|
||||
, Web.p "For now the nameservers cannot be updated (but you can delete the domain and start again)."
|
||||
, Web.level [
|
||||
Web.btn "Edit the name servers" (UpdateDelegationModal delegation)
|
||||
] []
|
||||
]
|
||||
render_zone_records _ =
|
||||
[ Table.resource_records (sorted state._resources) CreateUpdateRRModal DeleteRRModal NewToken
|
||||
|
|
@ -337,6 +342,10 @@ handleAction = case _ of
|
|||
CreateDelegationModal -> do
|
||||
H.modify_ _ { rr_modal = DelegationModal, _delegation_form = Delegation.mkEmptyDelegationForm }
|
||||
|
||||
-- | Delegation modal presents a simple form with two entries (chosen nameservers).
|
||||
UpdateDelegationModal delegation -> do
|
||||
H.modify_ _ { rr_modal = DelegationModal, _delegation_form = Delegation.mkUpdateDelegationForm delegation }
|
||||
|
||||
-- | Initialize the Zone component: ask for the domain zone to `dnsmanagerd`.
|
||||
Initialize -> do
|
||||
{ _domain } <- H.get
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ delegation_modal selected_domain form action_update_form action_validate action_
|
|||
modal_title = "Delegation for " <> selected_domain
|
||||
modal_content :: Array (HH.HTML w i)
|
||||
modal_content =
|
||||
[ HH.div [HP.classes [C.notification, C.is_warning]]
|
||||
[ Web.p "⚠️ You are about to delegate your domain to another server, you won't be able to manage entries from netlibre."
|
||||
]
|
||||
[ if form.new then HH.div [HP.classes [C.notification, C.is_warning]]
|
||||
[ Web.p "⚠️ You are about to delegate your domain to another server, you won't be able to manage entries from netlibre." ]
|
||||
else HH.div [] []
|
||||
, render_errors
|
||||
, Web.box_input "nameserver1" "name server 1" "ns0.example.com"
|
||||
(action_update_form <<< Delegation.NameServer1)
|
||||
|
|
@ -71,7 +71,8 @@ delegation_modal selected_domain form action_update_form action_validate action_
|
|||
]
|
||||
modal_foot :: Array (HH.HTML w i)
|
||||
modal_foot =
|
||||
[ Web.info_btn "Delegate the domain" action_validate
|
||||
[ if form.new then Web.info_btn "Delegate the domain" action_validate
|
||||
else Web.info_btn "Update the name servers" action_validate
|
||||
, Web.cancel_button action_cancel_modal
|
||||
]
|
||||
render_errors = if A.length form.errors > 0
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ module App.Type.Delegation
|
|||
, module App.Type.Error.Delegation
|
||||
) where
|
||||
|
||||
import App.Type.Form.Delegation (Form, Field(..), update, mkEmptyDelegationForm)
|
||||
import App.Type.Form.Delegation (Form, Field(..), update, mkEmptyDelegationForm, mkUpdateDelegationForm)
|
||||
import App.Type.Error.Delegation (Error(..))
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ module App.Type.Form.Delegation where
|
|||
|
||||
import App.Type.Error.Delegation (Error)
|
||||
|
||||
type Delegation = { nameserver1 :: String, nameserver2 :: String }
|
||||
|
||||
-- | The required data needed to properly delegate a domain: two name servers.
|
||||
-- | The type also includes potential errors found while validating the data.
|
||||
type Form
|
||||
= { nameserver1 :: String
|
||||
, nameserver2 :: String
|
||||
, errors :: Array Error
|
||||
, new :: Boolean
|
||||
}
|
||||
|
||||
-- | Empty delegation form, with default inputs.
|
||||
|
|
@ -16,6 +19,16 @@ mkEmptyDelegationForm
|
|||
= { nameserver1: "ns0.example.com"
|
||||
, nameserver2: "ns1.example.com"
|
||||
, errors: []
|
||||
, new: true
|
||||
}
|
||||
|
||||
-- | Empty delegation form, with default inputs.
|
||||
mkUpdateDelegationForm :: Delegation -> Form
|
||||
mkUpdateDelegationForm delegation
|
||||
= { nameserver1: delegation.nameserver1
|
||||
, nameserver2: delegation.nameserver2
|
||||
, errors: []
|
||||
, new: false
|
||||
}
|
||||
|
||||
-- | What are the **fields** of our delegation form?
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue