UI: Group: Display resources, invites and action buttons
This commit is contained in:
parent
e542c7d531
commit
3e110ca53c
3 changed files with 149 additions and 1 deletions
|
@ -980,7 +980,16 @@ getGroupEffortsR groupHash = do
|
|||
, AP.collectionItems = map (Doc h . makeItem) efforts
|
||||
, AP.collectionContext = Just $ encodeRouteLocal meR
|
||||
}
|
||||
provideHtmlAndAP effortsAP $ redirectToPrettyJSON (GroupEffortsR groupHash)
|
||||
provideHtmlAndAP effortsAP $ getHtml groupID group actor efforts
|
||||
where
|
||||
getHtml groupID group actor efforts = do
|
||||
mp <- maybeAuthId
|
||||
haveAdmin <- fmap isJust $ handlerToWidget $ runDB $ runMaybeT $ do
|
||||
personID <- MaybeT $ pure mp
|
||||
MaybeT $ getCapability personID (Left $ groupResource group) AP.RoleAdmin
|
||||
((_, widgetAE), enctypeAE) <- handlerToWidget $ runFormPost addEffortForm
|
||||
drafts <- handlerToWidget $ runDB $ getTeamResourceDrafts groupID
|
||||
$(widgetFile "group/efforts")
|
||||
|
||||
addEffortForm = renderDivs $ (,)
|
||||
<$> areq fedUriField "Resource actor URI*" Nothing
|
||||
|
|
|
@ -68,6 +68,7 @@ module Vervis.Persist.Collab
|
|||
, getSquadTeam
|
||||
|
||||
, getTeamResources
|
||||
, getTeamResourceDrafts
|
||||
|
||||
, getEffortAdd
|
||||
, getEffortTopic
|
||||
|
@ -1764,6 +1765,74 @@ getTeamResources groupID =
|
|||
, effort E.^. EffortId
|
||||
)
|
||||
|
||||
getTeamResourceDrafts
|
||||
:: MonadIO m
|
||||
=> GroupId
|
||||
-> ReaderT SqlBackend m
|
||||
[ ( Either (LocalActorBy Key, Actor) (Instance, RemoteObject, RemoteActor)
|
||||
, Bool
|
||||
, Either (LocalActorBy Key, Actor) (Instance, RemoteObject, RemoteActor)
|
||||
, Bool
|
||||
, UTCTime
|
||||
, AP.Role
|
||||
, EffortId
|
||||
)
|
||||
]
|
||||
getTeamResourceDrafts groupID = do
|
||||
efforts <- E.select $ E.from $ \ (effort `E.LeftOuterJoin` deleg) -> do
|
||||
E.on $ E.just (effort E.^. EffortId) E.==. deleg E.?. EffortUsSendDelegatorEffort
|
||||
E.where_ $
|
||||
effort E.^. EffortHolder E.==. E.val groupID E.&&.
|
||||
E.isNothing (deleg E.?. EffortUsSendDelegatorId)
|
||||
E.orderBy [E.asc $ effort E.^. EffortId]
|
||||
return effort
|
||||
for efforts $ \ (Entity effortID (Effort role _)) -> do
|
||||
(resource, accept) <- do
|
||||
topic <- getEffortTopic effortID
|
||||
accept <-
|
||||
case bimap fst fst topic of
|
||||
Left localID -> isJust <$> getBy (UniqueEffortThemAcceptLocal localID)
|
||||
Right remoteID -> isJust <$> getBy (UniqueEffortThemAcceptRemote remoteID)
|
||||
(,accept) <$> bitraverse
|
||||
(\ (_, resourceID) -> do
|
||||
lr <- getLocalResource resourceID
|
||||
Resource actorID <- getJust resourceID
|
||||
actor <- getJust actorID
|
||||
return (resourceToActor lr, actor)
|
||||
)
|
||||
(\ (_, actorID) -> getRemoteActorData actorID)
|
||||
topic
|
||||
((inviter, time), us) <- do
|
||||
usOrThem <-
|
||||
requireEitherAlt
|
||||
(getKeyBy $ UniqueEffortOriginUs effortID)
|
||||
(getKeyBy $ UniqueEffortOriginThem effortID)
|
||||
"Neither us nor them"
|
||||
"Both us and them"
|
||||
(addOrActor, us) <-
|
||||
case usOrThem of
|
||||
Left usID -> (,True) <$>
|
||||
requireEitherAlt
|
||||
(fmap effortUsGestureLocalAdd <$> getValBy (UniqueEffortUsGestureLocal usID))
|
||||
(fmap (effortUsGestureRemoteActor &&& effortUsGestureRemoteAdd) <$> getValBy (UniqueEffortUsGestureRemote usID))
|
||||
"Neither local not remote"
|
||||
"Both local and remote"
|
||||
Right themID -> (,False) <$>
|
||||
requireEitherAlt
|
||||
(fmap effortThemGestureLocalAdd <$> getValBy (UniqueEffortThemGestureLocal themID))
|
||||
(fmap (effortThemGestureRemoteActor &&& effortThemGestureRemoteAdd) <$> getValBy (UniqueEffortThemGestureRemote themID))
|
||||
"Neither local not remote"
|
||||
"Both local and remote"
|
||||
(,us) <$> case addOrActor of
|
||||
Left addID -> do
|
||||
OutboxItem outboxID _ time <- getJust addID
|
||||
Entity actorID actor <- getByJust $ UniqueActorOutbox outboxID
|
||||
(,time) . Left . (,actor) <$> getLocalActor actorID
|
||||
Right (actorID, addID) -> do
|
||||
RemoteActivity _ _ time <- getJust addID
|
||||
(,time) . Right <$> getRemoteActorData actorID
|
||||
return (inviter, us, resource, accept, time, role, effortID)
|
||||
|
||||
getEffortAdd
|
||||
:: MonadIO m
|
||||
=> EffortId
|
||||
|
|
70
templates/group/efforts.hamlet
Normal file
70
templates/group/efforts.hamlet
Normal file
|
@ -0,0 +1,70 @@
|
|||
$# This file is part of Vervis.
|
||||
$#
|
||||
$# Written in 2016, 2019, 2022, 2023, 2024
|
||||
$# by fr33domlover <fr33domlover@riseup.net>.
|
||||
$#
|
||||
$# ♡ Copying is an act of love. Please copy, reuse and share.
|
||||
$#
|
||||
$# The author(s) have dedicated all copyright and related and neighboring
|
||||
$# rights to this software to the public domain worldwide. This software is
|
||||
$# distributed without any warranty.
|
||||
$#
|
||||
$# You should have received a copy of the CC0 Public Domain Dedication along
|
||||
$# with this software. If not, see
|
||||
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
^{groupNavW (Entity groupID group) actor}
|
||||
|
||||
<h2>Accessible Resources
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Role
|
||||
<th>Since
|
||||
<th>Resource
|
||||
$if haveAdmin
|
||||
<th>Remove
|
||||
$forall (role, since, resource, effortID) <- efforts
|
||||
<tr>
|
||||
<td>#{show role}
|
||||
<td>#{showDate since}
|
||||
<td>^{actorLinkFedW resource}
|
||||
$if haveAdmin
|
||||
<td>^{buttonW POST "Remove" (GroupRemoveEffortR groupHash effortID)}
|
||||
|
||||
$if haveAdmin
|
||||
<p>Request access to a resource:
|
||||
<form method=POST action=@{GroupAddEffortR groupHash} enctype=#{enctypeAE}>
|
||||
^{widgetAE}
|
||||
<input type=submit>
|
||||
|
||||
<h2>Requests In Progress
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Inviter
|
||||
<th>Via
|
||||
<th>Requested resource
|
||||
<th>Resource accepted?
|
||||
<th>Role
|
||||
<th>Time
|
||||
$if haveAdmin
|
||||
<th>Approve
|
||||
$forall (inviter, us, resource, accept, time, role, effortID) <- drafts
|
||||
<tr>
|
||||
<td>^{actorLinkFedW inviter}
|
||||
<td>
|
||||
$if us
|
||||
Us
|
||||
$else
|
||||
Them
|
||||
<td>^{actorLinkFedW resource}
|
||||
<td>
|
||||
$if accept
|
||||
[x]
|
||||
$else
|
||||
[_]
|
||||
<td>#{show role}
|
||||
<td>#{showDate time}
|
||||
$if haveAdmin && (accept && not us)
|
||||
<td>^{buttonW POST "Approve" (GroupApproveEffortR groupHash effortID)}
|
Loading…
Reference in a new issue