Merge pull request #18297 from overleaf/jel-remove-angular-group-invite

[web] Remove Angular version of group invite

GitOrigin-RevId: bd31cd2ed3c105c9042ae9c42894cfe960459a46
This commit is contained in:
Jessica Lawshe 2024-05-30 07:36:06 -05:00 committed by Copybot
parent cbe5cefb9a
commit 3a59883e7a
6 changed files with 28 additions and 209 deletions

View file

@ -14,7 +14,6 @@ const EmailHandler = require('../Email/EmailHandler')
const { RateLimiter } = require('../../infrastructure/RateLimiter')
const Modules = require('../../infrastructure/Modules')
const UserAuditLogHandler = require('../User/UserAuditLogHandler')
const SplitTestHandler = require('../SplitTests/SplitTestHandler')
const rateLimiters = {
resendGroupInvite: new RateLimiter('resend-group-invite', {
@ -73,12 +72,6 @@ async function viewInvite(req, res, next) {
return ErrorController.notFound(req, res)
}
const { variant } = await SplitTestHandler.promises.getAssignment(
req,
res,
'team-invite-react'
)
let validationStatus = new Map()
if (userId) {
const personalSubscription =
@ -152,30 +145,16 @@ async function viewInvite(req, res, next) {
logger.error({ err }, 'error getting subscription admin email')
}
if (variant === 'enabled') {
return res.render('subscriptions/team/invite-react', {
inviterName: invite.inviterName,
inviteToken: invite.token,
hasIndividualRecurlySubscription,
expired: req.query.expired,
userRestrictions: Array.from(req.userRestrictions || []),
currentManagedUserAdminEmail,
groupSSOActive,
subscriptionId: subscription._id.toString(),
})
} else {
return res.render('subscriptions/team/invite', {
inviterName: invite.inviterName,
inviteToken: invite.token,
hasIndividualRecurlySubscription,
appName: settings.appName,
expired: req.query.expired,
userRestrictions: Array.from(req.userRestrictions || []),
currentManagedUserAdminEmail,
groupSSOActive,
subscriptionId: subscription._id.toString(),
})
}
return res.render('subscriptions/team/invite', {
inviterName: invite.inviterName,
inviteToken: invite.token,
hasIndividualRecurlySubscription,
expired: req.query.expired,
userRestrictions: Array.from(req.userRestrictions || []),
currentManagedUserAdminEmail,
groupSSOActive,
subscriptionId: subscription._id.toString(),
})
}
} else {
const userByEmail = await UserGetter.promises.getUserByMainEmail(

View file

@ -1,17 +0,0 @@
extends ../../layout-marketing
block entrypointVar
- entrypoint = 'pages/user/subscription/invite'
block append meta
meta(name="ol-hasIndividualRecurlySubscription" data-type="boolean" content=hasIndividualRecurlySubscription)
meta(name="ol-inviterName" date-type="string" content=inviterName)
meta(name="ol-inviteToken" data-type="string" content=inviteToken)
meta(name="ol-currentManagedUserAdminEmail" data-type="string" content=currentManagedUserAdminEmail)
meta(name="ol-expired" data-type="boolean" content=expired)
meta(name="ol-groupSSOActive" data-type="boolean" content=groupSSOActive)
meta(name="ol-subscriptionId" data-type="string" content=subscriptionId)
block content
main.content.content-alt#invite-root

View file

@ -1,48 +1,17 @@
extends ../../layout
extends ../../layout-marketing
block entrypointVar
- entrypoint = 'pages/user/subscription/invite'
block append meta
meta(name="ol-hasIndividualRecurlySubscription" data-type="boolean" content=hasIndividualRecurlySubscription)
meta(name="ol-inviteToken" content=inviteToken)
meta(name="ol-inviterName" date-type="string" content=inviterName)
meta(name="ol-inviteToken" data-type="string" content=inviteToken)
meta(name="ol-currentManagedUserAdminEmail" data-type="string" content=currentManagedUserAdminEmail)
meta(name="ol-expired" data-type="boolean" content=expired)
meta(name="ol-groupSSOActive" data-type="boolean" content=groupSSOActive)
meta(name="ol-subscriptionId" data-type="string" content=subscriptionId)
block content
main.content.content-alt.team-invite#main-content
.container
.row
.col-md-8.col-md-offset-2
if (expired)
.alert.alert-warning #{translate("email_link_expired")}
.row.row-spaced
.col-md-8.col-md-offset-2.text-center(ng-cloak)
.card(ng-controller="TeamInviteController")
.page-header
h1.text-centered(ng-non-bindable) !{translate("invited_to_group", {inviterName: inviterName, appName: appName}, [{name: 'span', attrs: {class: 'team-invite-name'}}])}
div(ng-show="view =='restrictedByManagedGroup'")
.alert.alert-info
strong #{translate("you_cant_join_this_group_subscription")}
p !{translate("your_account_is_managed_by_admin_cant_join_additional_group", {admin: currentManagedUserAdminEmail}, [{name: 'a', attrs: {href: '/learn/how-to/Understanding_Managed_Overleaf_Accounts'}}])}
div(ng-show="view =='hasIndividualRecurlySubscription'")
p #{translate("cancel_personal_subscription_first")}
.alert.alert-danger(ng-show="cancel_error" ng-cloak) #{translate("something_went_wrong_canceling_your_subscription")}
p
a.btn.btn.btn-secondary(ng-click="keepPersonalSubscription()", ng-disabled="inflight") #{translate("not_now")}
|  
a.btn.btn.btn-primary(ng-click="cancelPersonalSubscription()", ng-disabled="inflight") #{translate("cancel_your_subscription")}
div(ng-show="view =='teamInvite'")
p #{translate("join_team_explanation", {appName: appName})}
if (!expired)
p
a.btn.btn-secondary(href="/project") #{translate("not_now")}
|  
a.btn.btn.btn-primary(ng-click="joinTeam()", ng-disabled="inflight") #{translate("accept_invitation")}
div(ng-show="view =='inviteAccepted'")
- var doneLink = groupSSOActive ? `/subscription/${subscriptionId}/sso_enrollment` : '/project'
p(ng-non-bindable) #{translate("joined_team", {inviterName: inviterName})}
p
a.btn.btn.btn-primary(href=doneLink) #{translate("done")}
main.content.content-alt#invite-root

View file

@ -11,7 +11,6 @@
import './main/token-access' // used in project/token/access
import './main/event' // used in various controllers
import './main/system-messages' // used in project/editor
import './main/subscription/team-invite-controller' // used in subscriptions/team/invite
import './directives/eventTracking' // used in lots of places
import './features/cookie-banner'
import '../../modules/modules-main'

View file

@ -1,71 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../base'
import getMeta from '../../utils/meta'
import { debugConsole } from '@/utils/debugging'
export default App.controller('TeamInviteController', [
'$scope',
'$http',
function ($scope, $http) {
$scope.inflight = false
const hideJoinSubscription = getMeta('ol-cannot-join-subscription')
const hasIndividualRecurlySubscription = getMeta(
'ol-hasIndividualRecurlySubscription'
)
if (hideJoinSubscription) {
$scope.view = 'restrictedByManagedGroup'
} else if (hasIndividualRecurlySubscription) {
$scope.view = 'hasIndividualRecurlySubscription'
} else {
$scope.view = 'teamInvite'
}
$scope.keepPersonalSubscription = () => ($scope.view = 'teamInvite')
$scope.cancelPersonalSubscription = function () {
$scope.inflight = true
const request = $http.post('/user/subscription/cancel', {
_csrf: window.csrfToken,
})
request.then(function () {
$scope.inflight = false
return ($scope.view = 'teamInvite')
})
return request.catch(() => {
$scope.inflight = false
$scope.cancel_error = true
debugConsole.error('the request failed')
})
}
return ($scope.joinTeam = function () {
$scope.inflight = true
const inviteToken = getMeta('ol-inviteToken')
const request = $http.put(`/subscription/invites/${inviteToken}/`, {
_csrf: window.csrfToken,
})
request.then(function (response) {
const { status } = response
$scope.inflight = false
$scope.view = 'inviteAccepted'
if (status !== 200) {
// assume request worked
return ($scope.requestSent = false)
}
})
return request.catch(() => debugConsole.error('the request failed'))
})
},
])

View file

@ -195,54 +195,14 @@ describe('TeamInvitesController', function () {
})
})
describe('Feature rollout of React migration', function () {
describe('feature rollout is not active', function () {
it('renders old Angular template', function (done) {
const res = {
render: template => {
expect(template).to.equal('subscriptions/team/invite')
done()
},
}
this.Controller.viewInvite(req, res)
})
})
describe('user is on default variant', function () {
beforeEach(function () {
this.SplitTestHandler.promises.getAssignment.resolves({
variant: 'default',
})
})
it('renders old Angular template', function (done) {
const res = {
render: template => {
expect(template).to.equal('subscriptions/team/invite')
done()
},
}
this.Controller.viewInvite(req, res)
})
})
describe('user is on enabled variant', function () {
beforeEach(function () {
this.SplitTestHandler.promises.getAssignment.resolves({
variant: 'enabled',
})
})
it('renders React template', function (done) {
const res = {
render: template => {
expect(template).to.equal('subscriptions/team/invite-react')
done()
},
}
this.Controller.viewInvite(req, res)
})
})
it('renders the view', function (done) {
const res = {
render: template => {
expect(template).to.equal('subscriptions/team/invite')
done()
},
}
this.Controller.viewInvite(req, res)
})
})
})