mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 17:22:04 -05:00
9997c4874f
* [web] Initialize BS5 in subscription page * [web] Update subscription-dashboard.tsx for BS5 * [web] Update row-link.tsx for BS5 * [web] Update modals * [web] Add `btn` to `btn-inline-link` classes * [web] Update circle change-to-group circle price element * [web] Replace `list-item-with-margin-bottom` with `mb-3` * [web] Update form elements to BS5 * [web] Use `useContactUsModal` * [web] Adjust tables margin/padding, and more * [web] Update change-to-group-modal.tsx * [web] Add gap to subscription buttons * [web] Remove subscription page colspan for md and above * [web] Use Notification component * [web] Update "leave group" buttons * [web] Fix tests: add `ol-user` meta tag * [web] Nest .hover-highlight in #subscription-dashboard-root * [web] Update to OLRow/OLCol * [web] Update to OLButtons * [web] Update to OLFormGroup * [web] Naming: use BSversion prefix * [web] Set CancelSubscriptionButton as ghost directly in component * [web] Set "Plan" font size * [web] Simplify cancel-subscription buttons * [web] Remove `--neutral-10` ModalFooter background * [web] Simplify circle styles * [web] Center discount badge * [web] Update fieldset label * [web] Add `<ul>` around RowLink * [web] Define SCSS for row-link component * [web] Remove some use of utility classes * [web] Revert and update `fieldset` changes (fixes tests) * [web] Fixup some more OLButtons * [web] Fixup use of OLRow/OLCol * [web] Reduce spacing below "legend-as-label" * [web] Use h5 instead of small in OLModalTitle * [web] Revert OLCol removal on lg screens I had removed them by mistake because I wasn't using the proper breakpoints * [web] Add backdrop to nested modal ContactUsModal * [web] Don't prefill project URL in ContactUsModal * [web] Fix lint * [web] Share `className` prop in BS5 and BS3 modals * [web] Set sub-title font sans serif (BS3) * [web] Update remaining Alerts to OLNotification GitOrigin-RevId: 7fd975ae3e992cebfaf71d4e182f8e13ec886d09
132 lines
4.3 KiB
TypeScript
132 lines
4.3 KiB
TypeScript
import GroupSettingsButton from '@/features/subscription/components/dashboard/group-settings-button'
|
|
import getMeta from '@/utils/meta'
|
|
import { Trans, useTranslation } from 'react-i18next'
|
|
import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context'
|
|
import { RowLink } from './row-link'
|
|
import { ManagedGroupSubscription } from '../../../../../../types/subscription/dashboard/subscription'
|
|
|
|
function ManagedGroupAdministrator({
|
|
subscription,
|
|
}: {
|
|
subscription: ManagedGroupSubscription
|
|
}) {
|
|
const usersEmail = getMeta('ol-usersEmail')
|
|
const values = {
|
|
planName: subscription.planLevelName,
|
|
groupName: subscription.teamName || '',
|
|
adminEmail: subscription.admin_id.email,
|
|
}
|
|
|
|
const isAdmin = usersEmail === subscription.admin_id.email
|
|
|
|
if (subscription.userIsGroupMember && !isAdmin) {
|
|
return (
|
|
<Trans
|
|
i18nKey="you_are_a_manager_and_member_of_x_plan_as_member_of_group_subscription_y_administered_by_z"
|
|
components={[
|
|
// eslint-disable-next-line react/jsx-key, jsx-a11y/anchor-has-content
|
|
<a href="/user/subscription/plans" />,
|
|
// eslint-disable-next-line react/jsx-key
|
|
<strong />,
|
|
]}
|
|
values={values}
|
|
shouldUnescape
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
|
/>
|
|
)
|
|
} else if (subscription.userIsGroupMember && isAdmin) {
|
|
return (
|
|
<Trans
|
|
i18nKey="you_are_a_manager_and_member_of_x_plan_as_member_of_group_subscription_y_administered_by_z_you"
|
|
components={[
|
|
// eslint-disable-next-line react/jsx-key, jsx-a11y/anchor-has-content
|
|
<a href="/user/subscription/plans" />,
|
|
// eslint-disable-next-line react/jsx-key
|
|
<strong />,
|
|
]}
|
|
values={values}
|
|
shouldUnescape
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
|
/>
|
|
)
|
|
} else if (isAdmin) {
|
|
return (
|
|
<Trans
|
|
i18nKey="you_are_a_manager_of_x_plan_as_member_of_group_subscription_y_administered_by_z_you"
|
|
components={[
|
|
// eslint-disable-next-line react/jsx-key, jsx-a11y/anchor-has-content
|
|
<a href="/user/subscription/plans" />,
|
|
// eslint-disable-next-line react/jsx-key
|
|
<strong />,
|
|
]}
|
|
values={values}
|
|
shouldUnescape
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
|
/>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Trans
|
|
i18nKey="you_are_a_manager_of_x_plan_as_member_of_group_subscription_y_administered_by_z"
|
|
components={[
|
|
// eslint-disable-next-line react/jsx-key, jsx-a11y/anchor-has-content
|
|
<a href="/user/subscription/plans" />,
|
|
// eslint-disable-next-line react/jsx-key
|
|
<strong />,
|
|
]}
|
|
values={values}
|
|
shouldUnescape
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default function ManagedGroupSubscriptions() {
|
|
const { t } = useTranslation()
|
|
const { managedGroupSubscriptions } = useSubscriptionDashboardContext()
|
|
|
|
if (!managedGroupSubscriptions) {
|
|
return null
|
|
}
|
|
|
|
const groupSettingsEnabledFor = getMeta('ol-groupSettingsEnabledFor') || []
|
|
|
|
return (
|
|
<>
|
|
{managedGroupSubscriptions.map(subscription => {
|
|
return (
|
|
<div key={`managed-group-${subscription._id}`}>
|
|
<p>
|
|
<ManagedGroupAdministrator subscription={subscription} />
|
|
</p>
|
|
<ul className="list-group p-0">
|
|
<RowLink
|
|
href={`/manage/groups/${subscription._id}/members`}
|
|
heading={t('manage_members')}
|
|
subtext={t('manage_group_members_subtext')}
|
|
icon="groups"
|
|
/>
|
|
<RowLink
|
|
href={`/manage/groups/${subscription._id}/managers`}
|
|
heading={t('manage_group_managers')}
|
|
subtext={t('manage_managers_subtext')}
|
|
icon="manage_accounts"
|
|
/>
|
|
{groupSettingsEnabledFor?.includes(subscription._id) && (
|
|
<GroupSettingsButton subscription={subscription} />
|
|
)}
|
|
<RowLink
|
|
href={`/metrics/groups/${subscription._id}`}
|
|
heading={t('view_metrics')}
|
|
subtext={t('view_metrics_group_subtext')}
|
|
icon="insights"
|
|
/>
|
|
</ul>
|
|
<hr />
|
|
</div>
|
|
)
|
|
})}
|
|
</>
|
|
)
|
|
}
|