Skip to content

Commit

Permalink
share-modal: account for system created records
Browse files Browse the repository at this point in the history
  • Loading branch information
fenekku authored and ntarocco committed Aug 23, 2024
1 parent 1b5cf91 commit 880a126
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class AccessUsersGroups extends Component {
</Table.Row>
</Table.Header>
<Table.Body>
{searchType === "user" && (
{searchType === "user" && recOwner && (
<Table.Row>
<Table.Cell width={8}>
<Grid textAlign="left" verticalAlign="middle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,21 @@ export class ShareModal extends Component {
const { handleClose, groupsEnabled } = this.props;
const { linksResults, groupsResults, usersResults } = this.state;

const users = [];
const groups = [];
let numUsers = 0;
let numGroups = 0;
record.parent?.access?.grants?.forEach((grant) => {
if (grant.subject.type === "user") users.push(grant);
if (grant.subject.type === "role") groups.push(grant);
});

const links = [];
record.parent?.access?.links?.forEach((link) => {
if (link.id !== null) links.push(link);
if (grant.subject.type === "user") numUsers++;
if (grant.subject.type === "role") numGroups++;
});
if (record?.expanded?.parent?.access?.owned_by) numUsers++;

const panes = [
{
menuItem: (
<MenuItem key="accessUsers">
<Icon name="user" />
{i18next.t("People")}
<Label size="tiny">{users?.length + 1}</Label>
<Label size="tiny">{numUsers}</Label>
</MenuItem>
),
render: () => (
Expand All @@ -122,13 +118,14 @@ export class ShareModal extends Component {
),
},
];

if (groupsEnabled) {
panes.push({
menuItem: (
<MenuItem key="accessGroups">
<Icon name="users" />
{i18next.t("Groups")}
<Label size="tiny">{groups?.length}</Label>
<Label size="tiny">{numGroups}</Label>
</MenuItem>
),
render: () => (
Expand All @@ -144,13 +141,18 @@ export class ShareModal extends Component {
});
}

let numLinks = 0;
record.parent?.access?.links?.forEach((link) => {
if (link.id !== null) numLinks++;
});

panes.push(
{
menuItem: (
<MenuItem key="accessLinks">
<Icon name="linkify" />
{i18next.t("Links")}
<Label size="tiny">{links?.length}</Label>
<Label size="tiny">{numLinks}</Label>
</MenuItem>
),
render: () => (
Expand Down

0 comments on commit 880a126

Please sign in to comment.