feat: 🎸 create manage projects in org route and view (#2365)

* feat: 🎸 create manage projects in org route and view

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13882

---------

Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
authored and Lisbet Alvarez committed 2024-07-15 17:23:00 -07:00
1 parent e83bb425af
commit 3064e51bc1
20 files changed
+1541 -381

No files matched your search

@@ -0,0 +1,74 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { loading } from 'ember-loading';
import { tracked } from '@glimmer/tracking';
import { debounce } from 'core/decorators/debounce';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeRolesRoleManageScopesManageOrgProjectsController extends Controller {
// =services
@service router;
// =attributes
queryParams = ['search', 'page', 'pageSize'];
@tracked search = '';
@tracked page = 1;
@tracked pageSize = 10;
// =actions
/**
* Handles input on each keystroke and the search queryParam
* @param {object} event
*/
@action
@debounce(250)
handleSearchInput(event) {
const { value } = event.target;
this.search = value;
this.page = 1;
}
/**
* Save grant scope IDs to current role via the API.
* @param {RoleModel} role
* @param {[string]} grantScopeIDs
*/
@action
@loading
@notifyError(({ message }) => message, { catch: true })
@notifySuccess('notifications.add-success')
async setGrantScopes(role, grantScopeIDs) {
await role.setGrantScopes(grantScopeIDs);
if (role.scope.isGlobal) {
this.router.replaceWith(
'scopes.scope.roles.role.manage-scopes.manage-custom-scopes',
);
} else {
this.router.replaceWith('scopes.scope.roles.role.manage-scopes');
}
}
/**
* Redirect to previous as if nothing ever happened.
*/
@action
cancel(role) {
if (role.scope.isGlobal) {
this.router.replaceWith(
'scopes.scope.roles.role.manage-scopes.manage-custom-scopes',
);
} else {
this.router.replaceWith('scopes.scope.roles.role.manage-scopes');
}
}
}