UI: Project: Children: Button for approving the Add
This commit is contained in:
parent
d9d6b9fced
commit
082eae7a51
5 changed files with 114 additions and 2 deletions
|
@ -1042,3 +1042,5 @@ instance YesodBreadcrumbs App where
|
||||||
ProjectRemoveParentR _ _ -> ("", Nothing)
|
ProjectRemoveParentR _ _ -> ("", Nothing)
|
||||||
|
|
||||||
ProjectAddChildR _ -> ("", Nothing)
|
ProjectAddChildR _ -> ("", Nothing)
|
||||||
|
|
||||||
|
ProjectApproveChildR _ _ -> ("", Nothing)
|
||||||
|
|
|
@ -48,6 +48,8 @@ module Vervis.Handler.Project
|
||||||
, postProjectRemoveParentR
|
, postProjectRemoveParentR
|
||||||
|
|
||||||
, postProjectAddChildR
|
, postProjectAddChildR
|
||||||
|
|
||||||
|
, postProjectApproveChildR
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -744,7 +746,7 @@ getProjectChildrenR projectHash = do
|
||||||
Right (actorID, addID) -> do
|
Right (actorID, addID) -> do
|
||||||
RemoteActivity _ _ time <- getJust addID
|
RemoteActivity _ _ time <- getJust addID
|
||||||
(,time) . Right <$> getRemoteActorData actorID
|
(,time) . Right <$> getRemoteActorData actorID
|
||||||
return (inviter, us, child, accept, time, role)
|
return (inviter, us, child, accept, time, role, sourceID)
|
||||||
$(widgetFile "project/children")
|
$(widgetFile "project/children")
|
||||||
where
|
where
|
||||||
getRemoteActorData actorID = do
|
getRemoteActorData actorID = do
|
||||||
|
@ -1079,3 +1081,63 @@ postProjectAddChildR projectHash = do
|
||||||
Right removeID ->
|
Right removeID ->
|
||||||
setMessage "Add sent"
|
setMessage "Add sent"
|
||||||
redirect $ ProjectChildrenR projectHash
|
redirect $ ProjectChildrenR projectHash
|
||||||
|
|
||||||
|
postProjectApproveChildR :: KeyHashid Project -> SourceId -> Handler Html
|
||||||
|
postProjectApproveChildR projectHash sourceID = do
|
||||||
|
projectID <- decodeKeyHashid404 projectHash
|
||||||
|
|
||||||
|
personEntity@(Entity personID person) <- requireAuth
|
||||||
|
personHash <- encodeKeyHashid personID
|
||||||
|
encodeRouteHome <- getEncodeRouteHome
|
||||||
|
|
||||||
|
result <- runExceptT $ do
|
||||||
|
mpidOrU <- lift $ runDB $ runMaybeT $ do
|
||||||
|
project <- MaybeT $ get projectID
|
||||||
|
_ <- MaybeT $ get sourceID
|
||||||
|
SourceHolderProject _ j <-
|
||||||
|
MaybeT $ getValBy $ UniqueSourceHolderProject sourceID
|
||||||
|
guard $ projectID == j
|
||||||
|
|
||||||
|
uAdd <- lift $ do
|
||||||
|
add <- getSourceAdd sourceID
|
||||||
|
renderActivityURI add
|
||||||
|
|
||||||
|
topic <- lift $ do
|
||||||
|
t <- bimap snd snd <$> getSourceTopic sourceID
|
||||||
|
bitraverse
|
||||||
|
(\case
|
||||||
|
Left j' -> pure j'
|
||||||
|
Right _g -> error "I'm a project, I have a Source with topic being Group"
|
||||||
|
)
|
||||||
|
pure
|
||||||
|
t
|
||||||
|
lift $
|
||||||
|
(projectResource project,uAdd,) <$>
|
||||||
|
bitraverse
|
||||||
|
pure
|
||||||
|
(getRemoteActorURI <=< getJust)
|
||||||
|
topic
|
||||||
|
(resourceID, uAdd, pidOrU) <- maybe notFound pure mpidOrU
|
||||||
|
(maybeSummary, audience, accept) <- do
|
||||||
|
uChild <-
|
||||||
|
case pidOrU of
|
||||||
|
Left j -> encodeRouteHome . ProjectR <$> encodeKeyHashid j
|
||||||
|
Right u -> pure u
|
||||||
|
let uParent = encodeRouteHome $ ProjectR projectHash
|
||||||
|
C.acceptParentChild personID uAdd uParent uChild
|
||||||
|
cap <- do
|
||||||
|
maybeItem <- lift $ runDB $ getCapability personID (Left resourceID) AP.RoleAdmin
|
||||||
|
fromMaybeE maybeItem "You need to be have Admin access to the Project to approve children"
|
||||||
|
uCap <- lift $ renderActivityURI cap
|
||||||
|
(localRecips, remoteRecips, fwdHosts, action) <-
|
||||||
|
C.makeServerInput (Just uCap) maybeSummary audience $ AP.AcceptActivity accept
|
||||||
|
let cap' = first (\ (la, i) -> (la, error "lah", i)) cap
|
||||||
|
handleViaActor
|
||||||
|
personID (Just cap') localRecips remoteRecips fwdHosts action
|
||||||
|
|
||||||
|
case result of
|
||||||
|
Left e -> do
|
||||||
|
setMessage $ toHtml e
|
||||||
|
Right removeID ->
|
||||||
|
setMessage "Add sent"
|
||||||
|
redirect $ ProjectChildrenR projectHash
|
||||||
|
|
|
@ -33,6 +33,7 @@ module Vervis.Persist.Collab
|
||||||
|
|
||||||
, getComponentIdent
|
, getComponentIdent
|
||||||
, getSourceTopic
|
, getSourceTopic
|
||||||
|
, getSourceAdd
|
||||||
, getDestTopic
|
, getDestTopic
|
||||||
, getDestHolder
|
, getDestHolder
|
||||||
|
|
||||||
|
@ -461,6 +462,47 @@ getSourceTopic sourceID = do
|
||||||
(\ (Entity k v) -> pure (k, sourceTopicRemoteTopic v))
|
(\ (Entity k v) -> pure (k, sourceTopicRemoteTopic v))
|
||||||
ident
|
ident
|
||||||
|
|
||||||
|
getSourceAdd
|
||||||
|
:: MonadIO m
|
||||||
|
=> SourceId
|
||||||
|
-> ReaderT SqlBackend m
|
||||||
|
(Either
|
||||||
|
(LocalActorBy Key, OutboxItemId)
|
||||||
|
FedURI
|
||||||
|
)
|
||||||
|
getSourceAdd sourceID = do
|
||||||
|
usOrThem <-
|
||||||
|
requireEitherAlt
|
||||||
|
(getKeyBy $ UniqueSourceOriginUs sourceID)
|
||||||
|
(getKeyBy $ UniqueSourceOriginThem sourceID)
|
||||||
|
"Neither us nor them"
|
||||||
|
"Both us and them"
|
||||||
|
add <-
|
||||||
|
case usOrThem of
|
||||||
|
Left usID ->
|
||||||
|
requireEitherAlt
|
||||||
|
(fmap sourceUsGestureLocalAdd <$> getValBy (UniqueSourceUsGestureLocal usID))
|
||||||
|
(fmap sourceUsGestureRemoteAdd <$> getValBy (UniqueSourceUsGestureRemote usID))
|
||||||
|
"Neither local not remote"
|
||||||
|
"Both local and remote"
|
||||||
|
Right themID ->
|
||||||
|
requireEitherAlt
|
||||||
|
(fmap sourceThemGestureLocalAdd <$> getValBy (UniqueSourceThemGestureLocal themID))
|
||||||
|
(fmap sourceThemGestureRemoteAdd <$> getValBy (UniqueSourceThemGestureRemote themID))
|
||||||
|
"Neither local not remote"
|
||||||
|
"Both local and remote"
|
||||||
|
bitraverse
|
||||||
|
(\ addID -> do
|
||||||
|
OutboxItem outboxID _ time <- getJust addID
|
||||||
|
Entity actorID actor <- getByJust $ UniqueActorOutbox outboxID
|
||||||
|
(,addID) <$> getLocalActor actorID
|
||||||
|
)
|
||||||
|
(\ addID -> do
|
||||||
|
add <- getJust addID
|
||||||
|
getRemoteActivityURI add
|
||||||
|
)
|
||||||
|
add
|
||||||
|
|
||||||
getDestTopic
|
getDestTopic
|
||||||
:: MonadIO m
|
:: MonadIO m
|
||||||
=> DestId
|
=> DestId
|
||||||
|
|
|
@ -48,7 +48,9 @@ $if haveAdmin
|
||||||
<th>Child accepted?
|
<th>Child accepted?
|
||||||
<th>Role
|
<th>Role
|
||||||
<th>Time
|
<th>Time
|
||||||
$forall (inviter, us, child, accept, time, role) <- invites
|
$if haveAdmin
|
||||||
|
<th>Approve
|
||||||
|
$forall (inviter, us, child, accept, time, role, sourceID) <- invites
|
||||||
<tr>
|
<tr>
|
||||||
<td>^{actorLinkFedW inviter}
|
<td>^{actorLinkFedW inviter}
|
||||||
<td>
|
<td>
|
||||||
|
@ -64,3 +66,5 @@ $if haveAdmin
|
||||||
[_]
|
[_]
|
||||||
<td>#{show role}
|
<td>#{show role}
|
||||||
<td>#{showDate time}
|
<td>#{showDate time}
|
||||||
|
$if haveAdmin && (accept && not us)
|
||||||
|
<td>^{buttonW POST "Approve" (ProjectApproveChildR projectHash sourceID)}
|
||||||
|
|
|
@ -358,3 +358,5 @@
|
||||||
/projects/#ProjectKeyHashid/parent/remove/#DestId ProjectRemoveParentR POST
|
/projects/#ProjectKeyHashid/parent/remove/#DestId ProjectRemoveParentR POST
|
||||||
|
|
||||||
/projects/#ProjectKeyHashid/child/add ProjectAddChildR POST
|
/projects/#ProjectKeyHashid/child/add ProjectAddChildR POST
|
||||||
|
|
||||||
|
/projects/#ProjectKeyHashid/child/approve/#SourceId ProjectApproveChildR POST
|
||||||
|
|
Loading…
Reference in a new issue