Skip to content

Commit

Permalink
feat(iam): add applications tab (#13396)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Fiala <[email protected]>
  • Loading branch information
zZHorizonZz authored and Romain Jamet committed Nov 7, 2024
1 parent ff0d5e0 commit 94ea38b
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export const DELETE_ENTITY_TAG = {
error: TAG.RESOURCE_GROUPS__DELETE_GROUP_CONFIRM_BANNER__ERROR,
success: TAG.RESOURCE_GROUPS__DELETE_GROUP_CONFIRM_BANNER__SUCCESS,
},
[ENTITY.APPLICATION]: {
close: TAG.DELETE_APPLICATION__CANCEL,
delete: TAG.DELETE_APPLICATION__CONFIRM,
error: TAG.APPLICATIONS__DELETE_APPLICATION_CONFIRM_BANNER__ERROR,
success: TAG.APPLICATIONS__DELETE_APPLICATION_CONFIRM_BANNER__SUCCESS,
},
};

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export default class DeleteEntityController {
promise = this.deletePolicy();
} else if (this.entity.type === ENTITY.RESOURCE_GROUP) {
promise = this.deleteResourceGroup();
} else if (this.entity.type === ENTITY.APPLICATION) {
promise = this.deleteApplication();
} else if (this.entity.type === ENTITY.RESOURCE_TYPE) {
promise = this.$q.when(true);
} else {
Expand Down Expand Up @@ -135,6 +137,14 @@ export default class DeleteEntityController {
return this.IAMService.deleteResourceGroup(this.entity.data.id);
}

/**
* Delete the entity using the IAMService
* @returns {Promise}
*/
deleteApplication() {
return this.IAMService.deleteApplication(this.entity.data.applicationId);
}

/**
* Custom trackClick wrapper witch uses the tagPrefix bound property
* @param {'close'|'delete'} tagKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
"iam_delete_entity_resourceGroup_name": "Suppression du groupe de ressources : ",
"iam_delete_entity_resourceGroup_success": "Le groupe de ressources a bien été supprimé",
"iam_delete_entity_resourceGroup_warn": "Êtes-vous sûr.e de confirmer la suppression ?",
"iam_delete_entity_application_error": "An error occurred while deleting the application: {{ message }}",
"iam_delete_entity_application_field": "Please enter the word \"{{ statement }}\" to delete your application",
"iam_delete_entity_application_heading": "Delete an application",
"iam_delete_entity_application_name": "Deleting application: ",
"iam_delete_entity_application_success": "Application deleted",
"iam_delete_entity_application_warn": "Warning: this action will delete the application and it will revoke all credential belonging to this application.",
"iam_delete_entity_resourceType_error": "Une erreur est survenue lors de la suppression du type de produit : {{ message }}",
"iam_delete_entity_resourceType_heading": "Supprimer un type de produit",
"iam_delete_entity_resourceType_name": "Suppression du type de produit : ",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import controller from './applications.controller';
import template from './applications.template.html';

export default {
bindings: {
applications: '<',
alert: '<',
goTo: '<',
trackClick: '<',
},
controller,
template,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { AbstractCursorDatagridController } from '@ovh-ux/manager-ng-apiv2-helper';
import { TAG } from '../../iam.constants';

export default class ApplicationsController extends AbstractCursorDatagridController {
/* @ngInject */
constructor(IAMService) {
super();
this.IAMService = IAMService;
}

/**
* Go to resourceGroup deletion
* @param {string} id The application id
* @returns {Promise}
*/
deleteApplication(id) {
this.trackClick(TAG.APPLICATIONS__DELETE);
this.goTo({
name: 'iam.dashboard.applications.delete',
params: { application: id },
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import angular from 'angular';

import component from './applications.component';
import routing from './applications.routing';
import deleteModule from './delete';

const moduleName = 'ovhManagerIAMDashboardApplications';

angular
.module(moduleName, [deleteModule])
.component('iamApplications', component)
.config(routing)
.run(/* @ngTranslationsInject:json ./translations */);

export default moduleName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TAG } from '../../iam.constants';

export default /* @ngInject */ ($stateProvider) => {
$stateProvider.state('iam.dashboard.applications', {
url: '/applications?cursors',
component: 'iamApplications',
resolve: {
breadcrumb: () => null,
applications: /* @ngInject */ (IAMService) =>
IAMService.getApplications(),
},
atInternet: {
rename: TAG.APPLICATIONS,
},
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<div>
<p data-translate="iam_applications_description"></p>
<oui-datagrid
data-rows="$ctrl.applications"
data-page="{{ 1 }}"
data-page-size="{{ $ctrl.applications.length }}"
>
<!-- <Columns> -->
<oui-datagrid-column
data-title="'iam_applications_datagrid_column_application_id' | translate"
>
<span data-ng-bind="$row.applicationId"></span>
</oui-datagrid-column>
<oui-datagrid-column
data-title="'iam_applications_datagrid_column_application_name' | translate"
>
<span data-ng-bind="$row.name"></span>
</oui-datagrid-column>
<oui-datagrid-column
data-title="'iam_applications_datagrid_column_application_description' | translate"
>
<span data-ng-bind="$row.description"></span>
</oui-datagrid-column>
<oui-datagrid-column
data-title="'iam_applications_datagrid_column_application_status' | translate"
>
<span
class="oui-badge"
data-ng-class="{
'oui-badge_success': $row.status === 'active',
'oui-badge_error': $row.status !== 'active'
}"
data-translate="{{ 'iam_applications_datagrid_column_application_status_' + $row.status | translate }}"
>
</span>
</oui-datagrid-column>
<oui-datagrid-column
data-title="'iam_applications_datagrid_column_application_key' | translate"
>
<span data-ng-bind="$row.applicationKey"></span>
</oui-datagrid-column>
<!-- </Columns> -->

<!-- <Actions> -->
<oui-action-menu data-compact data-placement="end">
<oui-action-menu-item
data-on-click="$ctrl.deleteApplication($row.applicationId)"
>
<span
data-translate="iam_applications_datagrid_action_delete_application"
class="text-danger"
></span>
</oui-action-menu-item>
</oui-action-menu>
<!-- </Actions> -->
</oui-datagrid>
<div data-ui-view></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import angular from 'angular';

import deleteEntity from '../../../components/deleteEntity';
import routing from './delete.routing';

const moduleName = 'ovhManagerIAMDashboardApplicationsDelete';

angular.module(moduleName, [deleteEntity]).config(routing);

export default moduleName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ENTITY, TAG } from '../../../iam.constants';

export default /* @ngInject */ ($stateProvider) => {
$stateProvider.state('iam.dashboard.applications.delete', {
url: '/delete/{application:string}',
component: 'iamDeleteEntity',
resolve: {
breadcrumb: () => null,

/**
* A polymorphic DTO required by the deleteEntity component
* @returns {{
* data: Object,
* type: string
* }|null}
*/
entity: /* @ngInject */ (application) => {
if (application) {
return { data: application, type: ENTITY.APPLICATION };
}
return null;
},

/**
* The application to delete if an id is provided
* @returns {Object|null}
*/
application: /* @ngInject */ ($transition$, IAMService) => {
const { application: id } = $transition$.params();
return id ? IAMService.getApplication(id) : null;
},

/**
* Whether the entity requires a statement
* @returns {boolean}
*/
statement: /* @ngInject */ (entity) => entity.type === ENTITY.APPLICATION,
},
atInternet: {
rename: TAG.DELETE_APPLICATION,
},
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import angular from 'angular';
import uiRouter from '@uirouter/angularjs';
import ocLazyLoad from 'oclazyload';

const moduleName = 'ovhManagerIAMDashboardApplicationsDeleteLazyLoading';

angular.module(moduleName, [uiRouter, ocLazyLoad]).config(
/* @ngInject */ ($stateProvider) => {
$stateProvider.state('iam.dashboard.applications.delete.**', {
url: '/delete/{application:string}',
lazyLoad: (transition) =>
import('./delete.module').then((module) =>
transition
.injector()
.get('$ocLazyLoad')
.inject(module.default),
),
});
},
);

export default moduleName;
22 changes: 22 additions & 0 deletions packages/manager/modules/iam/src/dashboard/applications/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import angular from 'angular';
import uiRouter from '@uirouter/angularjs';
import ocLazyLoad from 'oclazyload';

const moduleName = 'ovhManagerIAMDashboardApplicationsLazyLoading';

angular.module(moduleName, [uiRouter, ocLazyLoad]).config(
/* @ngInject */ ($stateProvider) => {
$stateProvider.state('iam.dashboard.applications.**', {
url: '/applications',
lazyLoad: (transition) =>
import('./applications.module').then((module) =>
transition
.injector()
.get('$ocLazyLoad')
.inject(module.default),
),
});
},
);

export default moduleName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"iam_applications_datagrid_column_application_id": "Application id",
"iam_applications_datagrid_column_application_name": "Application name",
"iam_applications_datagrid_column_application_description": "Description",
"iam_applications_datagrid_column_application_status": "Status",
"iam_applications_datagrid_column_application_status_active": "Active",
"iam_applications_datagrid_column_application_status_inactive": "Inactive",
"iam_applications_datagrid_column_application_key": "Application key",
"iam_applications_datagrid_action_delete_application": "Delete application",
"iam_applications_description": "View and manage your applications. For more information about applications, see the documentation."
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import angular from 'angular';

import policies from './policies';
import resourceGroups from './resourceGroups';
import applications from './applications';
import users from './users/users.module';

import component from './dashboard.component';
Expand All @@ -10,7 +11,7 @@ import routing from './dashboard.routing';
const moduleName = 'ovhManagerIAMDashboard';

angular
.module(moduleName, [policies, resourceGroups, users])
.module(moduleName, [policies, resourceGroups, applications, users])
.component('iamDashboard', component)
.config(routing)
.run(/* @ngTranslationsInject:json ./translations */);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
data-translate="iam_dashboard_header_tabs_item_resource_groups"
></span
></oui-header-tabs-item>
<oui-header-tabs-item data-state="iam.dashboard.applications"
><span
data-translate="iam_dashboard_header_tabs_item_applications"
></span
></oui-header-tabs-item>
</oui-header-tabs>
<!-- </Tabs> -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"iam_dashboard_header_heading": "Gestion des identités et des accès (IAM)",
"iam_dashboard_header_tabs_item_identities": "Identités",
"iam_dashboard_header_tabs_item_policies": "Politiques",
"iam_dashboard_header_tabs_item_resource_groups": "Groupes de ressources"
"iam_dashboard_header_tabs_item_resource_groups": "Groupes de ressources",
"iam_dashboard_header_tabs_item_applications": "Applications"
}
16 changes: 16 additions & 0 deletions packages/manager/modules/iam/src/iam.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ENTITY = {
IDENTITY: 'identity',
RESOURCE_GROUP: 'resourceGroup',
RESOURCE_TYPE: 'resourceType',
APPLICATION: 'application',
};

const ENTITY_NAME_PATTERN = /^[a-zA-Z0-9-/_+]*$/;
Expand Down Expand Up @@ -192,6 +193,11 @@ const TAG = {
'dedicated::account::iam::delete-group-ressources::cancel',
DELETE_RESOURCE_GROUP__CONFIRM:
'dedicated::account::iam::delete-group-ressources::confirm',
DELETE_APPLICATION: 'dedicated::account::iam::delete-application',
DELETE_APPLICATION__CANCEL:
'dedicated::account::iam::delete-application::cancel',
DELETE_APPLICATION__CONFIRM:
'dedicated::account::iam::delete-application::confirm',

// Policy edition
EDIT_POLICY: 'dedicated::account::iam::edit-policy',
Expand Down Expand Up @@ -254,6 +260,16 @@ const TAG = {
RESOURCE_GROUPS__EDIT_GROUP_CONFIRM_BANNER__SUCCESS:
'iam::group-ressources::edit-group-confirm-banner::success',

// List of applications
APPLICATIONS: 'dedicated::account::iam::applications',
APPLICATIONS__DELETE: 'dedicated::account::iam::applications::delete',

// List of applications - banners
APPLICATIONS__DELETE_APPLICATION_CONFIRM_BANNER__ERROR:
'iam::applications::delete-application-confirm-banner::error',
APPLICATIONS__DELETE_APPLICATION_CONFIRM_BANNER__SUCCESS:
'iam::applications::delete-application-confirm-banner::success',

// Commons
ADD_ACTION_MANUALLY_SUCCESS: 'add-manually-success',
ADD_ACTION_MANUALLY: 'add-manually',
Expand Down
Loading

0 comments on commit 94ea38b

Please sign in to comment.