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:
1 parent
e83bb425af
commit
3064e51bc1
20 files changed
+1541
-381
No files matched your search
@@ -20,7 +20,7 @@
|
||||
{{on 'input' @handleSearchInput}}
|
||||
/>
|
||||
</Hds::SegmentedGroup>
|
||||
{{#if @model.subScopes}}
|
||||
{{#if @model.orgScopes}}
|
||||
{{#if this.selectedItems.length}}
|
||||
<div class='table-selected-items-text'>
|
||||
<Hds::Text::Body @tag='p' @color='faint'>
|
||||
@@ -38,7 +38,7 @@
|
||||
(hash label=(t 'form.id.label'))
|
||||
(hash label=(t 'resources.role.scope.titles.projects_selected'))
|
||||
}}
|
||||
@model={{@model.subScopes}}
|
||||
@model={{@model.orgScopes}}
|
||||
@isSelectable={{true}}
|
||||
@onSelectionChange={{this.selectionChange}}
|
||||
@valign='middle'
|
||||
@@ -62,12 +62,27 @@
|
||||
/>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
{{! TODO: Add link to projects selected page}}
|
||||
{{#let (get @model.projectTotals B.data.id) as |projectTotals|}}
|
||||
{{#if projectTotals}}
|
||||
<Hds::Link::Standalone
|
||||
@icon='arrow-right'
|
||||
@iconPosition='trailing'
|
||||
@text={{t
|
||||
'resources.role.scope.actions.view-projects'
|
||||
selected=projectTotals.selected
|
||||
total=projectTotals.total
|
||||
}}
|
||||
@route='scopes.scope.roles.role.manage-scopes.manage-org-projects'
|
||||
@model={{B.data.id}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{/let}}
|
||||
</B.Td>
|
||||
</B.Tr>
|
||||
</:body>
|
||||
</Hds::Table>
|
||||
<Rose::Pagination
|
||||
@model={{@model.role.id}}
|
||||
@totalItems={{@model.totalItems}}
|
||||
@currentPage={{@page}}
|
||||
@currentPageSize={{@pageSize}}
|
||||
@@ -78,7 +93,7 @@
|
||||
@cancelText={{t 'actions.cancel'}}
|
||||
/>
|
||||
{{else}}
|
||||
<Hds::ApplicationState data-test-no-scope-results as |A|>
|
||||
<Hds::ApplicationState data-test-no-grant-scope-results as |A|>
|
||||
<A.Header @title={{t 'titles.no-results-found'}} />
|
||||
<A.Body
|
||||
@text={{t
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
{{!
|
||||
Copyright (c) HashiCorp, Inc.
|
||||
SPDX-License-Identifier: BUSL-1.1
|
||||
}}
|
||||
|
||||
{{#if @model.totalItemsCount}}
|
||||
<Rose::Form
|
||||
class='full-width role-manage-custom-scopes-form'
|
||||
@onSubmit={{fn @submit this.allGrantScopes}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.role.isSaving}}
|
||||
as |form|
|
||||
>
|
||||
<Hds::SegmentedGroup as |S|>
|
||||
<S.TextInput
|
||||
@value={{@search}}
|
||||
@type='search'
|
||||
placeholder={{t 'actions.search'}}
|
||||
aria-label={{t 'actions.search'}}
|
||||
{{on 'input' @handleSearchInput}}
|
||||
/>
|
||||
</Hds::SegmentedGroup>
|
||||
{{#if @model.projectScopes}}
|
||||
{{#if this.selectedItems.length}}
|
||||
<div class='table-selected-items-text'>
|
||||
<Hds::Text::Body @tag='p' @color='faint'>
|
||||
{{t
|
||||
'resources.role.scope.titles.selected'
|
||||
items=this.selectedItems.length
|
||||
total=@model.totalItemsCount
|
||||
}}
|
||||
</Hds::Text::Body>
|
||||
</div>
|
||||
{{/if}}
|
||||
<Hds::Table
|
||||
@columns={{array
|
||||
(hash label=(t 'resources.project.title'))
|
||||
(hash label=(t 'form.id.label'))
|
||||
}}
|
||||
@model={{@model.projectScopes}}
|
||||
@isSelectable={{true}}
|
||||
@onSelectionChange={{this.selectionChange}}
|
||||
@valign='middle'
|
||||
>
|
||||
<:body as |B|>
|
||||
<B.Tr
|
||||
@selectionKey={{B.data.id}}
|
||||
@isSelected={{includes B.data.id this.selectedItems}}
|
||||
@selectionAriaLabelSuffix='row {{B.data.id}}'
|
||||
data-test-project-scopes-table-row={{B.data.id}}
|
||||
>
|
||||
<B.Td>
|
||||
<Hds::Text::Body @tag='p'>
|
||||
{{B.data.displayName}}
|
||||
</Hds::Text::Body>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
<Hds::Copy::Snippet
|
||||
@textToCopy={{B.data.id}}
|
||||
@color='secondary'
|
||||
/>
|
||||
</B.Td>
|
||||
</B.Tr>
|
||||
</:body>
|
||||
</Hds::Table>
|
||||
<Rose::Pagination
|
||||
@model={{array @model.role.id @model.orgScope.id}}
|
||||
@totalItems={{@model.totalItems}}
|
||||
@currentPage={{@page}}
|
||||
@currentPageSize={{@pageSize}}
|
||||
/>
|
||||
|
||||
<form.actions
|
||||
@submitText={{t 'actions.save'}}
|
||||
@cancelText={{t 'actions.cancel'}}
|
||||
/>
|
||||
{{else}}
|
||||
<Hds::ApplicationState data-test-no-grant-scope-results as |A|>
|
||||
<A.Header @title={{t 'titles.no-results-found'}} />
|
||||
<A.Body
|
||||
@text={{t
|
||||
'descriptions.no-search-results'
|
||||
query=@search
|
||||
resource=(t 'resources.scope.title_plural')
|
||||
}}
|
||||
/>
|
||||
</Hds::ApplicationState>
|
||||
{{/if}}
|
||||
</Rose::Form>
|
||||
{{else}}
|
||||
<Hds::ApplicationState as |A|>
|
||||
<A.Header
|
||||
@title={{t 'resources.role.scope.messages.no-org-scopes.title'}}
|
||||
/>
|
||||
<A.Body
|
||||
@text={{t 'resources.role.scope.messages.no-org-scopes.description'}}
|
||||
/>
|
||||
<A.Footer as |F|>
|
||||
<F.LinkStandalone
|
||||
@icon='arrow-left'
|
||||
@text={{t 'actions.back'}}
|
||||
@route='scopes.scope.roles.role.manage-scopes'
|
||||
/>
|
||||
</A.Footer>
|
||||
</Hds::ApplicationState>
|
||||
{{/if}}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import { action } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
|
||||
export default class FormRoleManageOrgProjectsIndexComponent extends Component {
|
||||
// =attributes
|
||||
|
||||
@tracked selectedItems = [...this.args.model.selectedProjectIDs];
|
||||
|
||||
get allGrantScopes() {
|
||||
return [
|
||||
...this.args.model.role.grantScopeKeywords,
|
||||
...this.args.model.role.grantScopeOrgIDs,
|
||||
...this.args.model.remainingProjectIDs,
|
||||
...this.selectedItems,
|
||||
];
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Handles the selection changes for the paginated table.
|
||||
* @param {object} selectableRowsStates
|
||||
*/
|
||||
@action
|
||||
selectionChange({ selectableRowsStates }) {
|
||||
selectableRowsStates.forEach((row) => {
|
||||
const { isSelected, selectionKey: key } = row;
|
||||
const includesId = this.selectedItems.includes(key);
|
||||
if (isSelected) {
|
||||
if (!includesId) this.selectedItems = [...this.selectedItems, key];
|
||||
} else {
|
||||
if (includesId)
|
||||
this.selectedItems = this.selectedItems.filter(
|
||||
(item) => item !== key,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -75,8 +75,9 @@
|
||||
@route={{if
|
||||
@model.scope.isGlobal
|
||||
'scopes.scope.roles.role.manage-scopes.manage-custom-scopes'
|
||||
'scopes.scope.roles.role.manage-scopes'
|
||||
'scopes.scope.roles.role.manage-scopes.manage-org-projects'
|
||||
}}
|
||||
@model={{if @model.scope.isOrg @model.scope.id}}
|
||||
/>
|
||||
|
||||
<Hds::Form::HelperText
|
||||
|
||||
Reference in new issue
Block a user