chore: Serialize domain policies on team (#1970)
* domain policies exposed on team, consistency * fix: Remove usage of isAdmin in frontend * test
This commit is contained in:
@@ -173,7 +173,7 @@ function MainSidebar() {
|
||||
exact={false}
|
||||
label={t("Settings")}
|
||||
/>
|
||||
{can.invite && (
|
||||
{can.inviteUser && (
|
||||
<SidebarLink
|
||||
to="/settings/people"
|
||||
onClick={handleInviteModalOpen}
|
||||
@@ -183,7 +183,7 @@ function MainSidebar() {
|
||||
)}
|
||||
</Section>
|
||||
</Scrollable>
|
||||
{can.invite && (
|
||||
{can.inviteUser && (
|
||||
<Modal
|
||||
title={t("Invite people")}
|
||||
onRequestClose={handleInviteModalClose}
|
||||
|
||||
@@ -14,9 +14,10 @@ type Props = {|
|
||||
|};
|
||||
|
||||
function UserMenu({ user }: Props) {
|
||||
const { users } = useStores();
|
||||
const { users, policies } = useStores();
|
||||
const { t } = useTranslation();
|
||||
const menu = useMenuState({ modal: true });
|
||||
const can = policies.abilities(user.id);
|
||||
|
||||
const handlePromote = React.useCallback(
|
||||
(ev: SyntheticEvent<>) => {
|
||||
@@ -98,14 +99,14 @@ function UserMenu({ user }: Props) {
|
||||
userName: user.name,
|
||||
}),
|
||||
onClick: handleDemote,
|
||||
visible: user.isAdmin,
|
||||
visible: can.demote,
|
||||
},
|
||||
{
|
||||
title: t("Make {{ userName }} an admin…", {
|
||||
userName: user.name,
|
||||
}),
|
||||
onClick: handlePromote,
|
||||
visible: !user.isAdmin && !user.isSuspended,
|
||||
visible: can.promote,
|
||||
},
|
||||
{
|
||||
type: "separator",
|
||||
|
||||
@@ -87,7 +87,7 @@ class People extends React.Component<Props> {
|
||||
{team.signinMethods} but haven’t signed in yet.
|
||||
</Trans>
|
||||
</HelpText>
|
||||
{can.invite && (
|
||||
{can.inviteUser && (
|
||||
<Button
|
||||
type="button"
|
||||
data-on="click"
|
||||
@@ -116,7 +116,7 @@ class People extends React.Component<Props> {
|
||||
<Tab to="/settings/people/all" exact>
|
||||
{t("Everyone")} <Bubble count={counts.all - counts.invited} />
|
||||
</Tab>
|
||||
{can.invite && (
|
||||
{can.inviteUser && (
|
||||
<>
|
||||
<Separator />
|
||||
<Tab to="/settings/people/invited" exact>
|
||||
@@ -137,7 +137,7 @@ class People extends React.Component<Props> {
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{can.invite && (
|
||||
{can.inviteUser && (
|
||||
<Modal
|
||||
title={t("Invite people")}
|
||||
onRequestClose={this.handleInviteModalClose}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// @flow
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import AuthStore from "stores/AuthStore";
|
||||
import SharesStore from "stores/SharesStore";
|
||||
|
||||
import CenteredContent from "components/CenteredContent";
|
||||
import Empty from "components/Empty";
|
||||
import HelpText from "components/HelpText";
|
||||
@@ -12,55 +9,50 @@ import List from "components/List";
|
||||
import PageTitle from "components/PageTitle";
|
||||
import Subheading from "components/Subheading";
|
||||
import ShareListItem from "./components/ShareListItem";
|
||||
import useCurrentTeam from "hooks/useCurrentTeam";
|
||||
import useStores from "hooks/useStores";
|
||||
|
||||
type Props = {
|
||||
shares: SharesStore,
|
||||
auth: AuthStore,
|
||||
};
|
||||
function Shares() {
|
||||
const team = useCurrentTeam();
|
||||
const { shares, auth, policies } = useStores();
|
||||
const canShareDocuments = auth.team && auth.team.sharing;
|
||||
const hasSharedDocuments = shares.orderedData.length > 0;
|
||||
const can = policies.abilities(team.id);
|
||||
|
||||
@observer
|
||||
class Shares extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
this.props.shares.fetchPage({ limit: 100 });
|
||||
}
|
||||
React.useEffect(() => {
|
||||
shares.fetchPage({ limit: 100 });
|
||||
}, [shares]);
|
||||
|
||||
render() {
|
||||
const { shares, auth } = this.props;
|
||||
const { user } = auth;
|
||||
const canShareDocuments = auth.team && auth.team.sharing;
|
||||
const hasSharedDocuments = shares.orderedData.length > 0;
|
||||
|
||||
return (
|
||||
<CenteredContent>
|
||||
<PageTitle title="Share Links" />
|
||||
<h1>Share Links</h1>
|
||||
return (
|
||||
<CenteredContent>
|
||||
<PageTitle title="Share Links" />
|
||||
<h1>Share Links</h1>
|
||||
<HelpText>
|
||||
Documents that have been shared are listed below. Anyone that has the
|
||||
public link can access a read-only version of the document until the
|
||||
link has been revoked.
|
||||
</HelpText>
|
||||
{can.manage && (
|
||||
<HelpText>
|
||||
Documents that have been shared are listed below. Anyone that has the
|
||||
public link can access a read-only version of the document until the
|
||||
link has been revoked.
|
||||
{!canShareDocuments && (
|
||||
<strong>Sharing is currently disabled.</strong>
|
||||
)}{" "}
|
||||
You can turn {canShareDocuments ? "off" : "on"} public document
|
||||
sharing in <Link to="/settings/security">security settings</Link>.
|
||||
</HelpText>
|
||||
{user && user.isAdmin && (
|
||||
<HelpText>
|
||||
{!canShareDocuments && (
|
||||
<strong>Sharing is currently disabled.</strong>
|
||||
)}{" "}
|
||||
You can turn {canShareDocuments ? "off" : "on"} public document
|
||||
sharing in <Link to="/settings/security">security settings</Link>.
|
||||
</HelpText>
|
||||
)}
|
||||
<Subheading>Shared Documents</Subheading>
|
||||
{hasSharedDocuments ? (
|
||||
<List>
|
||||
{shares.published.map((share) => (
|
||||
<ShareListItem key={share.id} share={share} />
|
||||
))}
|
||||
</List>
|
||||
) : (
|
||||
<Empty>No share links, yet.</Empty>
|
||||
)}
|
||||
</CenteredContent>
|
||||
);
|
||||
}
|
||||
)}
|
||||
<Subheading>Shared Documents</Subheading>
|
||||
{hasSharedDocuments ? (
|
||||
<List>
|
||||
{shares.published.map((share) => (
|
||||
<ShareListItem key={share.id} share={share} />
|
||||
))}
|
||||
</List>
|
||||
) : (
|
||||
<Empty>No share links, yet.</Empty>
|
||||
)}
|
||||
</CenteredContent>
|
||||
);
|
||||
}
|
||||
|
||||
export default inject("shares", "auth")(Shares);
|
||||
export default observer(Shares);
|
||||
|
||||
Reference in New Issue
Block a user