2021-03-12 05:23:46 -05:00
|
|
|
import App from '../../../base'
|
|
|
|
import { react2angular } from 'react2angular'
|
|
|
|
|
|
|
|
import ShareProjectModal from '../components/share-project-modal'
|
2021-06-03 09:44:23 -04:00
|
|
|
import { rootContext } from '../../../shared/context/root-context'
|
2021-03-12 05:23:46 -05:00
|
|
|
import { listProjectInvites, listProjectMembers } from '../utils/api'
|
|
|
|
|
2021-03-31 06:44:20 -04:00
|
|
|
App.component(
|
|
|
|
'shareProjectModal',
|
2021-06-03 09:44:23 -04:00
|
|
|
react2angular(
|
|
|
|
rootContext.use(ShareProjectModal),
|
2021-06-16 05:32:38 -04:00
|
|
|
Object.keys(ShareProjectModal.propTypes)
|
2021-06-03 09:44:23 -04:00
|
|
|
)
|
2021-03-31 06:44:20 -04:00
|
|
|
)
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
export default App.controller(
|
|
|
|
'ReactShareProjectModalController',
|
|
|
|
function ($scope, eventTracking, ide) {
|
|
|
|
$scope.isAdmin = false
|
|
|
|
$scope.show = false
|
2021-03-12 05:23:46 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.handleHide = () => {
|
2021-03-31 11:46:23 -04:00
|
|
|
$scope.$applyAsync(() => {
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.show = false
|
2021-03-31 11:46:23 -04:00
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.openShareProjectModal = isAdmin => {
|
|
|
|
eventTracking.sendMBOnce('ide-open-share-modal-once')
|
|
|
|
$scope.$applyAsync(() => {
|
|
|
|
$scope.isAdmin = isAdmin
|
|
|
|
$scope.show = true
|
|
|
|
})
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
/* tokens */
|
|
|
|
|
|
|
|
ide.socket.on('project:tokens:changed', data => {
|
|
|
|
if (data.tokens != null) {
|
|
|
|
$scope.$applyAsync(() => {
|
|
|
|
$scope.project.tokens = data.tokens
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
ide.socket.on('project:membership:changed', data => {
|
|
|
|
if (data.members) {
|
|
|
|
listProjectMembers($scope.project)
|
|
|
|
.then(({ members }) => {
|
|
|
|
if (members) {
|
|
|
|
$scope.$applyAsync(() => {
|
|
|
|
$scope.project.members = members
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
console.error('Error fetching members for project')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.invites) {
|
|
|
|
listProjectInvites($scope.project)
|
|
|
|
.then(({ invites }) => {
|
|
|
|
if (invites) {
|
|
|
|
$scope.$applyAsync(() => {
|
|
|
|
$scope.project.invites = invites
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
console.error('Error fetching invites for project')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|