Skip to content

Commit

Permalink
feat(dedicated): hide backup storage when not available (#12665)
Browse files Browse the repository at this point in the history
ref: MANAGER-14805, MANAGER-14698

Signed-off-by: Quentin Pavy <[email protected]>
  • Loading branch information
qpavy authored Sep 20, 2024
1 parent f5fcc44 commit c6a4788
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
export default /* @ngInject */ ($stateProvider, coreConfigProvider) => {
if (!coreConfigProvider.isRegion('US')) {
$stateProvider.state('app.dedicated-server.server.ftpBackup', {
url: '/backup',
views: {
'[email protected]': {
component: 'dedicatedServerFtpBackupStorage',
},
export default /* @ngInject */ ($stateProvider) => {
$stateProvider.state('app.dedicated-server.server.ftpBackup', {
url: '/backup',
views: {
'[email protected]': {
component: 'dedicatedServerFtpBackupStorage',
},
resolve: {
breadcrumb: /* @ngInject */ ($translate) =>
$translate.instant('dedicated_server_ftp_backup'),
goToFtpBackUpStorage: ($state, Alerter) => (
message = false,
type = 'success',
) => {
const promise = $state.go('app.dedicated-server.server.ftpBackup');
if (message) {
promise.then(() => Alerter[type](message));
}
return promise;
},
},
redirectTo: (transition) => {
const injector = transition.injector();
const backupIAvailablePromise = injector.getAsync(
'backupStorageAvailable',
);
const serverNamePromise = injector.getAsync('serverName');

return Promise.all([backupIAvailablePromise, serverNamePromise]).then(
([backupIsAvailable, serverName]) =>
backupIsAvailable
? null
: {
state: 'app.dedicated-server.server.dashboard',
params: { productId: serverName },
},
);
},
resolve: {
breadcrumb: /* @ngInject */ ($translate) =>
$translate.instant('dedicated_server_ftp_backup'),
goToFtpBackUpStorage: ($state, Alerter) => (
message = false,
type = 'success',
) => {
const promise = $state.go('app.dedicated-server.server.ftpBackup');
if (message) {
promise.then(() => Alerter[type](message));
}
return promise;
},
});
}
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export default /* @ngInject */ ($stateProvider) => {
...serviceInfo,
serviceType: SERVICE_TYPE,
})),
backupStorageAvailable: /* @ngInject */ (Server, serverName, features) =>
Server.getFtpBackup(serverName).then(
({ canOrder, activated }) =>
features.isFeatureAvailable('dedicated-server:backup') &&
(canOrder || activated),
),
specifications: /* @ngInject */ (serverName, Server) =>
Server.getBandwidth(serverName),
user: /* @ngInject */ (currentUser) => currentUser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
user: '<',
worldPart: '<',
nutanixCluster: '<',
backupStorageAvailable: '<',
},
controller,
template,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h1 class="oui-header__title" data-ng-bind="server.displayName"></h1>
data-href="{{:: $ctrl.getTabItemUrl('ftpBackup') }}"
active="$ctrl.getTabItemUrl('ftpBackup') === $ctrl.currentActiveLink()"
data-disabled="server.isExpired"
data-ng-if="$ctrl.features.isFeatureAvailable('dedicated-server:backup')"
data-ng-if="$ctrl.backupStorageAvailable"
><span data-translate="server_tab_ftp_backup"></span
></oui-header-tabs-item>
<oui-header-tabs-item
Expand Down

0 comments on commit c6a4788

Please sign in to comment.