mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
[web] Fix group audit log link displayed to managers (#28084)
* [web] Fix group audit log link displayed to managers * Fix incorrect query in test GitOrigin-RevId: f5a68ef60f9c19f2e2003b05424b5a88f7a1cad3
This commit is contained in:
@@ -88,6 +88,9 @@ function ManagedGroupAdministrator({
|
|||||||
|
|
||||||
export default function ManagedGroupSubscriptions() {
|
export default function ManagedGroupSubscriptions() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
const usersEmail = getMeta('ol-usersEmail')
|
||||||
|
|
||||||
const { managedGroupSubscriptions } = useSubscriptionDashboardContext()
|
const { managedGroupSubscriptions } = useSubscriptionDashboardContext()
|
||||||
|
|
||||||
if (!managedGroupSubscriptions) {
|
if (!managedGroupSubscriptions) {
|
||||||
@@ -101,6 +104,8 @@ export default function ManagedGroupSubscriptions() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{managedGroupSubscriptions.map(subscription => {
|
{managedGroupSubscriptions.map(subscription => {
|
||||||
|
const isAdmin = usersEmail === subscription.admin_id.email
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={`managed-group-${subscription._id}`}>
|
<div key={`managed-group-${subscription._id}`}>
|
||||||
<h2 className="h3 fw-bold">{t('group_management')}</h2>
|
<h2 className="h3 fw-bold">{t('group_management')}</h2>
|
||||||
@@ -126,17 +131,19 @@ export default function ManagedGroupSubscriptions() {
|
|||||||
{groupSettingsAdvertisedFor?.includes(subscription._id) && (
|
{groupSettingsAdvertisedFor?.includes(subscription._id) && (
|
||||||
<GroupSettingsButtonWithAdBadge subscription={subscription} />
|
<GroupSettingsButtonWithAdBadge subscription={subscription} />
|
||||||
)}
|
)}
|
||||||
<RowLink
|
{isAdmin && (
|
||||||
href={`/manage/groups/${subscription._id}/audit-logs`}
|
<RowLink
|
||||||
heading={t('audit_logs')}
|
href={`/manage/groups/${subscription._id}/audit-logs`}
|
||||||
subtext={t('view_audit_logs_group_subtext')}
|
heading={t('audit_logs')}
|
||||||
icon="list"
|
subtext={t('view_audit_logs_group_subtext')}
|
||||||
onClick={() =>
|
icon="list"
|
||||||
sendMB('group-audit-log-click', {
|
onClick={() =>
|
||||||
subscriptionId: subscription._id,
|
sendMB('group-audit-log-click', {
|
||||||
})
|
subscriptionId: subscription._id,
|
||||||
}
|
})
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<RowLink
|
<RowLink
|
||||||
href={`/metrics/groups/${subscription._id}`}
|
href={`/metrics/groups/${subscription._id}`}
|
||||||
heading={t('usage_metrics')}
|
heading={t('usage_metrics')}
|
||||||
|
|||||||
@@ -124,31 +124,28 @@ describe('<ManagedGroupSubscriptions />', function () {
|
|||||||
expect(links[2].getAttribute('href')).to.equal(
|
expect(links[2].getAttribute('href')).to.equal(
|
||||||
'/manage/groups/bcd567/managers'
|
'/manage/groups/bcd567/managers'
|
||||||
)
|
)
|
||||||
expect(links[3].getAttribute('href')).to.equal(
|
expect(links[3].getAttribute('href')).to.equal('/metrics/groups/bcd567')
|
||||||
'/manage/groups/bcd567/audit-logs'
|
expect(links[5].getAttribute('href')).to.equal(
|
||||||
)
|
|
||||||
expect(links[4].getAttribute('href')).to.equal('/metrics/groups/bcd567')
|
|
||||||
expect(links[6].getAttribute('href')).to.equal(
|
|
||||||
'/manage/groups/def456/members'
|
'/manage/groups/def456/members'
|
||||||
)
|
)
|
||||||
expect(links[7].getAttribute('href')).to.equal(
|
expect(links[6].getAttribute('href')).to.equal(
|
||||||
'/manage/groups/def456/managers'
|
'/manage/groups/def456/managers'
|
||||||
)
|
)
|
||||||
expect(links[9].getAttribute('href')).to.equal('/metrics/groups/def456')
|
expect(links[7].getAttribute('href')).to.equal('/metrics/groups/def456')
|
||||||
expect(links[11].getAttribute('href')).to.equal(
|
expect(links[9].getAttribute('href')).to.equal(
|
||||||
'/manage/groups/group2abc/members'
|
'/manage/groups/group2abc/members'
|
||||||
)
|
)
|
||||||
expect(links[12].getAttribute('href')).to.equal(
|
expect(links[10].getAttribute('href')).to.equal(
|
||||||
'/manage/groups/group2abc/managers'
|
'/manage/groups/group2abc/managers'
|
||||||
)
|
)
|
||||||
expect(links[14].getAttribute('href')).to.equal('/metrics/groups/group2abc')
|
expect(links[12].getAttribute('href')).to.equal('/metrics/groups/group2abc')
|
||||||
expect(links[16].getAttribute('href')).to.equal(
|
expect(links[14].getAttribute('href')).to.equal(
|
||||||
'/manage/groups/group123abc/members'
|
'/manage/groups/group123abc/members'
|
||||||
)
|
)
|
||||||
expect(links[17].getAttribute('href')).to.equal(
|
expect(links[15].getAttribute('href')).to.equal(
|
||||||
'/manage/groups/group123abc/managers'
|
'/manage/groups/group123abc/managers'
|
||||||
)
|
)
|
||||||
expect(links[19].getAttribute('href')).to.equal(
|
expect(links[17].getAttribute('href')).to.equal(
|
||||||
'/metrics/groups/group123abc'
|
'/metrics/groups/group123abc'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -180,6 +177,37 @@ describe('<ManagedGroupSubscriptions />', function () {
|
|||||||
.be.null
|
.be.null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('does not render the Group Audit Log settings row when the user is not the group admin', function () {
|
||||||
|
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
|
||||||
|
metaTags: [
|
||||||
|
{
|
||||||
|
name: 'ol-managedGroupSubscriptions',
|
||||||
|
value: managedGroupSubscriptions2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ol-groupSettingsEnabledFor',
|
||||||
|
value: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(screen.queryByText('Audit logs')).to.be.null
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders the Group Audit Log settings row when the user is the group admin', async function () {
|
||||||
|
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
|
||||||
|
metaTags: [
|
||||||
|
{
|
||||||
|
name: 'ol-managedGroupSubscriptions',
|
||||||
|
value: managedGroupSubscriptions,
|
||||||
|
},
|
||||||
|
{ name: 'ol-usersEmail', value: 'admin@example.com' },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
await screen.findAllByText('Audit logs')
|
||||||
|
})
|
||||||
|
|
||||||
it('renders Managed Group / Group SSO settings row when both features are turned on', async function () {
|
it('renders Managed Group / Group SSO settings row when both features are turned on', async function () {
|
||||||
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
|
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
|
||||||
metaTags: [
|
metaTags: [
|
||||||
|
|||||||
Reference in New Issue
Block a user