UI: Project: Components: Button for removal
This commit is contained in:
parent
12ea0c021e
commit
9646b72ded
4 changed files with 56 additions and 3 deletions
|
@ -1038,6 +1038,7 @@ instance YesodBreadcrumbs App where
|
||||||
ProjectParentsR j -> ("Parent projects", Just $ ProjectR j)
|
ProjectParentsR j -> ("Parent projects", Just $ ProjectR j)
|
||||||
ProjectParentLiveR j d -> (keyHashidText d, Just $ ProjectParentsR j)
|
ProjectParentLiveR j d -> (keyHashidText d, Just $ ProjectParentsR j)
|
||||||
|
|
||||||
|
ProjectRemoveComponentR _ _ -> ("", Nothing)
|
||||||
ProjectRemoveChildR _ _ -> ("", Nothing)
|
ProjectRemoveChildR _ _ -> ("", Nothing)
|
||||||
ProjectRemoveParentR _ _ -> ("", Nothing)
|
ProjectRemoveParentR _ _ -> ("", Nothing)
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ module Vervis.Handler.Project
|
||||||
, getProjectParentsR
|
, getProjectParentsR
|
||||||
, getProjectParentLiveR
|
, getProjectParentLiveR
|
||||||
|
|
||||||
|
, postProjectRemoveComponentR
|
||||||
, postProjectRemoveChildR
|
, postProjectRemoveChildR
|
||||||
, postProjectRemoveParentR
|
, postProjectRemoveParentR
|
||||||
|
|
||||||
|
@ -519,7 +520,7 @@ getProjectComponentsR projectHash = do
|
||||||
return (inztance, remoteObject, remoteActor)
|
return (inztance, remoteObject, remoteActor)
|
||||||
)
|
)
|
||||||
byKeyOrRaid
|
byKeyOrRaid
|
||||||
return (identView, componentRole c, outboxItemPublished i)
|
return (identView, componentRole c, outboxItemPublished i, cid)
|
||||||
ds <-
|
ds <-
|
||||||
E.select $ E.from $ \ (comp `E.LeftOuterJoin` enable) -> do
|
E.select $ E.from $ \ (comp `E.LeftOuterJoin` enable) -> do
|
||||||
E.on $ E.just (comp E.^. ComponentId) E.==. enable E.?. ComponentEnableComponent
|
E.on $ E.just (comp E.^. ComponentId) E.==. enable E.?. ComponentEnableComponent
|
||||||
|
@ -968,6 +969,53 @@ getProjectParentLiveR projectHash startHash = do
|
||||||
getBy404 $ UniqueDestHolderProject destID
|
getBy404 $ UniqueDestHolderProject destID
|
||||||
unless (j == projectID) notFound
|
unless (j == projectID) notFound
|
||||||
|
|
||||||
|
postProjectRemoveComponentR :: KeyHashid Project -> ComponentId -> Handler Html
|
||||||
|
postProjectRemoveComponentR projectHash componentID = 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
|
||||||
|
Component j _ <- MaybeT $ get componentID
|
||||||
|
guard $ projectID == j
|
||||||
|
_ <- MaybeT $ getBy $ UniqueComponentEnable componentID
|
||||||
|
|
||||||
|
topic <- lift $ bimap snd snd <$> getComponentIdent componentID
|
||||||
|
lift $
|
||||||
|
(projectResource project,) <$>
|
||||||
|
bitraverse
|
||||||
|
pure
|
||||||
|
(getRemoteActorURI <=< getJust)
|
||||||
|
topic
|
||||||
|
(resourceID, pidOrU) <- maybe notFound pure mpidOrU
|
||||||
|
(maybeSummary, audience, remove) <- do
|
||||||
|
uComponent <-
|
||||||
|
case pidOrU of
|
||||||
|
Left c -> encodeRouteHome . renderLocalResource <$> hashLocalResource (componentResource c)
|
||||||
|
Right u -> pure u
|
||||||
|
let uCollection = encodeRouteHome $ ProjectComponentsR projectHash
|
||||||
|
C.remove personID uComponent uCollection
|
||||||
|
cap <- do
|
||||||
|
maybeItem <- lift $ runDB $ getCapability personID (Left resourceID) AP.RoleAdmin
|
||||||
|
fromMaybeE maybeItem "You need to be have Admin access to the Project to remove components"
|
||||||
|
uCap <- lift $ renderActivityURI cap
|
||||||
|
(localRecips, remoteRecips, fwdHosts, action) <-
|
||||||
|
C.makeServerInput (Just uCap) maybeSummary audience $ AP.RemoveActivity remove
|
||||||
|
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 "Remove sent"
|
||||||
|
redirect $ ProjectComponentsR projectHash
|
||||||
|
|
||||||
postProjectRemoveChildR :: KeyHashid Project -> SourceId -> Handler Html
|
postProjectRemoveChildR :: KeyHashid Project -> SourceId -> Handler Html
|
||||||
postProjectRemoveChildR projectHash sourceID = do
|
postProjectRemoveChildR projectHash sourceID = do
|
||||||
projectID <- decodeKeyHashid404 projectHash
|
projectID <- decodeKeyHashid404 projectHash
|
||||||
|
|
|
@ -22,12 +22,15 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
<th>Role
|
<th>Role
|
||||||
<th>Component
|
<th>Component
|
||||||
<th>Since
|
<th>Since
|
||||||
$forall (comp, role, since) <- comps
|
$if haveAdmin
|
||||||
|
<th>Remove
|
||||||
|
$forall (comp, role, since, compID) <- comps
|
||||||
<tr>
|
<tr>
|
||||||
<td>#{show role}
|
<td>#{show role}
|
||||||
<td>^{componentLinkFedW comp}
|
<td>^{componentLinkFedW comp}
|
||||||
<td>#{showDate since}
|
<td>#{showDate since}
|
||||||
$# <td>^{buttonW POST "Remove" (ProjectRemoveR projectHash ctID)}
|
$if haveAdmin
|
||||||
|
<td>^{buttonW POST "Remove" (ProjectRemoveComponentR projectHash compID)}
|
||||||
|
|
||||||
$if haveAdmin
|
$if haveAdmin
|
||||||
<p>Invite a component:
|
<p>Invite a component:
|
||||||
|
|
|
@ -367,6 +367,7 @@
|
||||||
/projects/#ProjectKeyHashid/parents ProjectParentsR GET
|
/projects/#ProjectKeyHashid/parents ProjectParentsR GET
|
||||||
/projects/#ProjectKeyHashid/parents/#DestUsStartKeyHashid/live ProjectParentLiveR GET
|
/projects/#ProjectKeyHashid/parents/#DestUsStartKeyHashid/live ProjectParentLiveR GET
|
||||||
|
|
||||||
|
/projects/#ProjectKeyHashid/component/remove/#ComponentId ProjectRemoveComponentR POST
|
||||||
/projects/#ProjectKeyHashid/child/remove/#SourceId ProjectRemoveChildR POST
|
/projects/#ProjectKeyHashid/child/remove/#SourceId ProjectRemoveChildR POST
|
||||||
/projects/#ProjectKeyHashid/parent/remove/#DestId ProjectRemoveParentR POST
|
/projects/#ProjectKeyHashid/parent/remove/#DestId ProjectRemoveParentR POST
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue