2018-11-05 05:06:39 -05:00
|
|
|
/* 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
|
|
|
|
*/
|
2020-05-19 05:02:56 -04:00
|
|
|
import App from '../../base'
|
2021-04-15 10:23:12 -04:00
|
|
|
import getMeta from '../../utils/meta'
|
2023-09-27 05:45:49 -04:00
|
|
|
import { debugConsole } from '@/utils/debugging'
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2023-10-13 05:13:49 -04:00
|
|
|
export default App.controller('TeamInviteController', [
|
|
|
|
'$scope',
|
|
|
|
'$http',
|
|
|
|
function ($scope, $http) {
|
|
|
|
$scope.inflight = false
|
2023-08-01 03:51:44 -04:00
|
|
|
|
2023-10-13 05:13:49 -04:00
|
|
|
const hideJoinSubscription = getMeta('ol-cannot-join-subscription')
|
|
|
|
const hasIndividualRecurlySubscription = getMeta(
|
|
|
|
'ol-hasIndividualRecurlySubscription'
|
|
|
|
)
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2023-11-06 09:27:04 -05:00
|
|
|
const groupSSOActive = getMeta('ol-groupSSOActive', false)
|
|
|
|
|
|
|
|
if (groupSSOActive) {
|
|
|
|
const subscriptionId = getMeta('ol-subscriptionId')
|
|
|
|
$scope.doneLink = `/subscription/${subscriptionId}/sso_enrollment`
|
|
|
|
} else {
|
|
|
|
$scope.doneLink = '/project'
|
|
|
|
}
|
|
|
|
|
2023-10-13 05:13:49 -04:00
|
|
|
if (hideJoinSubscription) {
|
|
|
|
$scope.view = 'restrictedByManagedGroup'
|
|
|
|
} else if (hasIndividualRecurlySubscription) {
|
|
|
|
$scope.view = 'hasIndividualRecurlySubscription'
|
|
|
|
} else {
|
|
|
|
$scope.view = 'teamInvite'
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2023-10-13 05:13:49 -04:00
|
|
|
$scope.keepPersonalSubscription = () => ($scope.view = 'teamInvite')
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2023-10-13 05:13:49 -04:00
|
|
|
$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')
|
|
|
|
})
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2023-10-13 05:13:49 -04:00
|
|
|
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'))
|
2020-05-19 05:02:56 -04:00
|
|
|
})
|
2023-10-13 05:13:49 -04:00
|
|
|
},
|
|
|
|
])
|