Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mnoe 669] Company deletion #398

Open
wants to merge 6 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
angular.module 'mnoEnterpriseAngular'
.component('dashboardCompanyDeletion', {
restrict: 'EA'
templateUrl: 'app/components/dashboard-company-deletion/dashboard-company-deletion.html',
controllerAs: "DashboardCompanyDeletionCtrl"
controller: ($uibModal, MnoeCurrentUser, MnoeOrganizations, MnoeAppInstances, MnoConfirm) ->
vm = this
vm.isDeletionOpen = false

vm.proceed = (reason, password) ->
MnoeOrganizations.freeze(reason, password)

vm.requestDeletion = () ->
modalInstance = $uibModal.open(
component: "dashboardDeletionConfirm",
size: "lg",
resolve:
actionCb: () -> vm.proceed
)
return
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div uib-accordion class="accordion">
<div uib-accordion-group is-open="DashboardCompanyDeletionCtrl.isDeletionOpen">
<div uib-accordion-heading>
{{ 'mno_enterprise.templates.dashboard.organization.settings.company_deletion' | translate }}<span class="fa pull-right" ng-class="{'fa-caret-down': !DashboardCompanyDeletionCtrl.isDeletionOpen, 'fa-caret-up': DashboardCompanyDeletionCtrl.isDeletionOpen}"></span>
</div>
<div translate="mno_enterprise.templates.dashboard.organization.settings.deletion_info_html"></div>
<button ng-click="DashboardCompanyDeletionCtrl.requestDeletion()" class='btn btn-warning'>
{{ 'mno_enterprise.templates.dashboard.organization.settings.request_deletion' | translate }}
</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ DashboardCompanySelectboxCtrl = ($scope, $state, $stateParams, $uibModal, MnoeCu
# Switch to selected company
MnoeAppInstances.emptyAppInstances()
MnoeAppInstances.clearCache()
MnoeOrganizations.get(organization.id)
MnoeOrganizations.get(organization.id).then((org) ->
$state.go('home.company') unless org.organization.active
)
selectBox.close()

selectOrganization = ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
angular.module 'mnoEnterpriseAngular'
.component('dashboardDeletionConfirm', {
templateUrl: 'app/components/dashboard-deletion-confirm/dashboard-deletion-confirm.html',
bindings: {
resolve: '<'
close: '&'
dismiss: '&'
}
controller: ($log, $state, toastr) ->
ctrl = this
ctrl.password = ""
ctrl.delReasons = ""
ctrl.isLoading = false

ctrl.cancel = () ->
ctrl.dismiss({$value: "cancel"})

ctrl.ok = () ->
ctrl.isLoading = true

# Launch Cb
ctrl.resolve.actionCb(ctrl.delReasons, ctrl.password).then(
(response) ->
toastr.success('Organization successfully frozen')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locale key to add for i18n

# Reload the state to block access to Impac!, marketplace, ...
$state.reload()
ctrl.close(response)
(errors) ->
$log.error(errors)
toastr.error(errors.statusText, "Error")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locale key to add for i18n

).finally(-> ctrl.isLoading = false)
return
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="modal-body">
<div translate="mno_enterprise.templates.dashboard.organization.settings.confirm_deletion_html"></div>
<div class="form-group">
<label for="delCompanyReasons">
{{ 'mno_enterprise.templates.dashboard.organization.settings.deletion_reason' | translate }}
</label>
<textarea type="text" class="form-control" ng-model="$ctrl.delReasons" id="delCompanyReasons"></textarea>
</div>

<div class="form-group">
<label for="delCompanypassword">
{{ 'mno_enterprise.templates.dashboard.organization.settings.confirm_password' | translate }}
</label>
<input type="password" class="form-control" id="delCompanypassword" ng-model="$ctrl.password">
</div>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line to remove

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="$ctrl.cancel()">{{ 'mno_enterprise.templates.dashboard.organization.settings.cancel' | translate }}</button>
<button type="button" class="btn btn-warning" ng-click="$ctrl.ok()" ng-disabled="$ctrl.isLoading || $ctrl.password === ''">
<span ng-show="$ctrl.isLoading"><i class="fa fa-spinner fa-pulse fa-fw"></i></span>
{{ 'mno_enterprise.templates.dashboard.organization.settings.confirm_deletion' | translate }}
</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ angular.module 'mnoEnterpriseAngular'
MnoeCurrentUser.get().then(
(response) ->
selectedOrg = _.find(response.organizations, {id: newValue})
$scope.isCompanyActive = selectedOrg.active
$scope.isAdmin = MnoeOrganizations.role.atLeastAdmin(selectedOrg.current_user_role)
) if newValue?
)
Expand Down
25 changes: 13 additions & 12 deletions src/app/components/dashboard-menu/dashboard-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
<!-- ------------------------- -->
<!-- My account section -->
<!-- ------------------------- -->
<li>
<a ng-if="!isAdmin || !isImpacEnabled" ui-sref="home.apps" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.dashboard' | translate }}</a>

<li ng-if="(!isAdmin && isCompanyActive) || !isImpacEnabled">
<a ng-if="!isAdmin" ui-sref="home.apps" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.dashboard' | translate }}</a>
</li>
<li ng-if="!isDockEnabled">
<li ng-if="!isDockEnabled && isCompanyActive">
<a ng-if="isAdmin" ui-sref="home.apps" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.dashboard' | translate }}</a>
</li>

<li ng-if="!isDockEnabled">
<li ng-if="!isDockEnabled && isCompanyActive">
<a ng-if="isAdmin && isImpacEnabled" ui-sref="home.impac" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.impac' | translate }}</a>
</li>

<li ng-if="isDockEnabled">
<li ng-if="isDockEnabled && isCompanyActive">
<a ng-if="isAdmin && isImpacEnabled" ui-sref="home.impac" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.dashboard' | translate }}</a>
</li>

Expand All @@ -40,11 +41,11 @@
<a ui-sref="home.company" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.company' | translate }}</a>
</li>

<li ng-if="isProvisioningEnabled && isAdmin">
<li ng-if="isProvisioningEnabled && isAdmin && isCompanyActive">
<a ui-sref="home.subscriptions" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.subscriptions' | translate }}</a>
</li>

<li ng-if="isMarketplaceEnabled">
<li ng-if="isMarketplaceEnabled && isCompanyActive">
<a ui-sref="home.marketplace" ui-sref-active="active">{{ 'mno_enterprise.templates.dashboard.menu.marketplace' | translate }}</a>
</li>

Expand All @@ -66,17 +67,17 @@
</a>

<div class="menu-buttons-wrapper">
<a ng-if="(!isDockEnabled && isAdmin) || !isAdmin || !isImpacEnabled" ui-sref="home.apps" class="dashboard-button top-buffer-1" ui-sref-active="active">
<a ng-if="(!isDockEnabled && isAdmin && isCompanyActive) || !isAdmin || !isImpacEnabled" ui-sref="home.apps" class="dashboard-button top-buffer-1" ui-sref-active="active">
<div class='content'>{{ 'mno_enterprise.templates.dashboard.menu.dashboard' | translate }}</div>
<i class="dhb-icon-dashboard"></i>
</a>

<a ng-if="isDockEnabled && isAdmin && isImpacEnabled" ui-sref="home.impac" class="dashboard-button top-buffer-1" ui-sref-active="active">
<a ng-if="isDockEnabled && isAdmin && isCompanyActive && isImpacEnabled" ui-sref="home.impac" class="dashboard-button top-buffer-1" ui-sref-active="active">
<div class='content'>{{ 'mno_enterprise.templates.dashboard.menu.dashboard' | translate }}</div>
<i class="dhb-icon-impac"></i>
</a>

<a ng-if="!isDockEnabled && isAdmin && isImpacEnabled" ui-sref="home.impac" class="dashboard-button top-buffer-1" ui-sref-active="active">
<a ng-if="!isDockEnabled && isAdmin && isCompanyActive && isImpacEnabled" ui-sref="home.impac" class="dashboard-button top-buffer-1" ui-sref-active="active">
<div class='content'>{{ 'mno_enterprise.templates.dashboard.menu.impac' | translate }}</div>
<i class="dhb-icon-impac"></i>
</a>
Expand All @@ -91,12 +92,12 @@
<i class="dhb-icon-company"></i>
</a>

<a ng-if="isProvisioningEnabled && isAdmin" ui-sref="home.subscriptions" class="dashboard-button top-buffer-1" ui-sref-active="active">
<a ng-if="isProvisioningEnabled && isAdmin && isCompanyActive" ui-sref="home.subscriptions" class="dashboard-button top-buffer-1" ui-sref-active="active">
<div class='content'>{{ 'mno_enterprise.templates.dashboard.menu.subscriptions' | translate }}</div>
<i class="dhb-icon-subscriptions"></i>
</a>

<a ng-if="isMarketplaceEnabled" ui-sref="home.marketplace" class="dashboard-button top-buffer-1" ui-sref-active="active">
<a ng-if="isMarketplaceEnabled && isCompanyActive" ui-sref="home.marketplace" class="dashboard-button top-buffer-1" ui-sref-active="active">
<div class='content'>{{ 'mno_enterprise.templates.dashboard.menu.marketplace' | translate }}</div>
<i class="dhb-icon-marketplace"></i>
</a>
Expand Down
17 changes: 17 additions & 0 deletions src/app/components/mnoe-api/organizations.svc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,23 @@ angular.module 'mnoEnterpriseAngular'

return defer.promise

@freeze = (reason, password) ->
MnoeApiSvc.one('organizations', _self.selectedId).doPOST({reason: reason, password: password}, 'freeze').then((response) ->
# Reload the current user with the updated organization
MnoeCurrentUser.refresh().then( ->
# If everything wennt well, update the active flag
_self.selected.organization.active = false
response
)
)

@companyActiveRequired = () ->
if _self.selected
$state.go('home.company') unless _self.selected.organization.active
else
_self.getCurrentOrganisation().then((org) ->
$state.go('home.company') unless org.organization.active
)
#======================================
# User Role
#======================================
Expand Down
11 changes: 11 additions & 0 deletions src/app/index.route.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ angular.module 'mnoEnterpriseAngular'
url: '/apps'
templateUrl: 'app/views/apps/dashboard-apps-list.html'
controller: 'DashboardAppsListCtrl'
resolve:
companyActiveRequired: (MnoeOrganizations) ->
MnoeOrganizations.companyActiveRequired()
.state 'home.impac',
data:
pageTitle:'Impac'
url: '/impac'
templateUrl: 'app/views/impac/impac.html'
controller: 'ImpacController'
controllerAs: 'vm'
resolve:
companyActiveRequired: (MnoeOrganizations) ->
MnoeOrganizations.companyActiveRequired()
.state 'home.account',
data:
pageTitle:'Account'
Expand Down Expand Up @@ -97,6 +103,8 @@ angular.module 'mnoEnterpriseAngular'
resolve:
loginRequired: (MnoeCurrentUser) ->
MnoeCurrentUser.loginRequired()
companyActiveRequired: (MnoeOrganizations) ->
MnoeOrganizations.companyActiveRequired()
.state 'onboarding.step1',
data:
pageTitle:'Welcome'
Expand Down Expand Up @@ -128,6 +136,9 @@ angular.module 'mnoEnterpriseAngular'
templateUrl: 'app/views/marketplace/marketplace.html'
controller: 'DashboardMarketplaceCtrl'
controllerAs: 'vm'
resolve:
companyActiveRequired: (MnoeOrganizations) ->
MnoeOrganizations.companyActiveRequired()
.state 'home.marketplace.app',
data:
pageTitle:'Marketplace'
Expand Down
1 change: 1 addition & 0 deletions src/app/views/company/company.controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ angular.module 'mnoEnterpriseAngular'
#====================================
vm.initialize = ->
vm.isLoading = false
vm.isCompanyActive = MnoeOrganizations.getSelected().organization.active
if vm.isBillingShown()
vm.activeTab = 'billing'
else
Expand Down
13 changes: 7 additions & 6 deletions src/app/views/company/company.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h2 class="section-title">{{ 'mno_enterprise.templates.dashboard.organization.in
<!-------------------------------------->
<!-- Members Section -->
<!-------------------------------------->
<div uib-tab index="'members'">
<div uib-tab index="'members'" ng-if="vm.isCompanyActive">
<div uib-tab-heading>{{ 'mno_enterprise.templates.dashboard.organization.index.members.title' | translate }}</div>

<!-- Directive: DashboardOrganizationMembers -->
Expand All @@ -106,7 +106,7 @@ <h2 class="section-title">{{ 'mno_enterprise.templates.dashboard.organization.in
<!-------------------------------------->
<!-- Team Management Section -->
<!-------------------------------------->
<div uib-tab index="'team'">
<div uib-tab index="'team'" ng-if="vm.isCompanyActive">
<div uib-tab-heading>{{ 'mno_enterprise.templates.dashboard.organization.index.teams.title' | translate }}</div>

<div class="clearfix">
Expand All @@ -127,7 +127,7 @@ <h4>
<!-------------------------------------->
<!-- Audit Log Section -->
<!-------------------------------------->
<div uib-tab index="'audit'" ng-if="vm.isAuditLogShown()">
<div uib-tab index="'audit'" ng-if="vm.isAuditLogShown() && vm.isCompanyActive">
<div uib-tab-heading>{{ 'mno_enterprise.templates.dashboard.organization.index.audit_log.title' | translate }}</div>

<!-- Directive: DashboardOrganizationAuditLog -->
Expand All @@ -143,7 +143,7 @@ <h4>
<!-------------------------------------->
<!-- Company Settings Section -->
<!-------------------------------------->
<div uib-tab index="'settings'" ng-show="vm.isSettingsShown()" >
<div uib-tab index="'settings'" ng-show="vm.isSettingsShown() && vm.isCompanyActive" >
<div uib-tab-heading>{{ 'mno_enterprise.templates.dashboard.organization.index.settings.title' | translate }}</div>

<div class="well clearfix">
Expand All @@ -152,9 +152,10 @@ <h4>
<div dashboard-organization-settings></div>
</div>
</div>

<!-- End: tab settings section -->
<dashboard-company-deletion></dashboard-company-deletion>
</div>
</div>
<!-- End: tab settings section -->

<!-- End: tabset -->
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,13 @@
"mno_enterprise.templates.dashboard.organization.settings.disable": "Off",
"mno_enterprise.templates.dashboard.organization.settings.cancel": "Cancel",
"mno_enterprise.templates.dashboard.organization.settings.save": "Save",
"mno_enterprise.templates.dashboard.organization.settings.company_deletion": "Company deletion",
"mno_enterprise.templates.dashboard.organization.settings.deletion_info_html": "<p>Before confirming the deletion of your organization, please ensure you understand the following:</p><ul><li>You will no longer have access to any 3rd party applications that you have subscribed to via Maestrano. Your data may be deleted immediately by those application providers.</li><li>All data stored on Maestrano, your dashboard will be immediately deleted and cannot be recovered</li><li>Data sharing between your applications will cease to function.</li></ul><p>If you need further clarification about this, please get in touch with our support team.</p>",
"mno_enterprise.templates.dashboard.organization.settings.request_deletion": "Request deletion",
"mno_enterprise.templates.dashboard.organization.settings.confirm_deletion_html": "<p>After confirming the deletion of this organisation:</p><ul><li>All users will lose access to any 3rd party applications that have been subscribed to via the platform.</li><li>All users, excluding yourself, will no longer have access to this organisation.</li><li>You will only have access to the “Billing” section of this organisation.</li><li>A final invoice for your organisation, including 3rd party application charges, will be generated on the 25th of the following month.</li><li>Upon receiving the final payment, the deletion of the organisation will be finalised.</li></ul><p>Please note, individual user accounts will not be deleted. Users will retain the access that they have to any other organisations.</p>",
"mno_enterprise.templates.dashboard.organization.settings.confirm_password": "Your password:",
"mno_enterprise.templates.dashboard.organization.settings.deletion_reason": "Please tell us why you are requesting the deletion of your company",
"mno_enterprise.templates.dashboard.organization.settings.confirm_deletion": "Confirm deletion",
"mno_enterprise.templates.dashboard.provisioning.breadcrumb.order": "Order",
"mno_enterprise.templates.dashboard.provisioning.breadcrumb.additional_details": "Additional details",
"mno_enterprise.templates.dashboard.provisioning.breadcrumb.confirm": "Confirm",
Expand Down