Skip to content

Commit

Permalink
fix: update openapi and align app setup (#283)
Browse files Browse the repository at this point in the history
* feat: added delete application component and call it

* fix: various changes, add and remove app deletion

* fix: restore openapi, layout tuning

* fix: app setup, fix translations
  • Loading branch information
HenryT-CG authored Nov 22, 2024
1 parent c76f399 commit 2f5dbe0
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 157 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

npx --no-install commitlint --edit $1
13 changes: 9 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# .husky/pre-commit

echo "[Husky] Running lint check:"
npm run lint
echo "[Husky] Running prettier check:"
npx prettier --cache -c .
bash << EOF

echo "[Husky] Running lint check on changed files:"
ng lint --cache=true
echo "[Husky] Running prettier check on changed files:"
npx prettier -c --cache .

EOF
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumWarning": "1mb",
"maximumError": "3mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kb",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
],
Expand Down
12 changes: 2 additions & 10 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module.exports = function (config) {
config.set({
basePath: '',
basePath: '.',
logLevel: config.LOG_INFO,
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
Expand All @@ -31,19 +31,11 @@ module.exports = function (config) {
jasmine: { random: false },
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
reporters: ['progress', 'kjhtml', 'coverage', 'sonarqubeUnit'],
reporters: ['progress', 'coverage', 'sonarqubeUnit'],
preprocessors: { 'src/**/*.js': ['coverage'] },
jasmineHtmlReporter: {
suppressAll: true // remove duplicated traces
},
sonarqubeReporter: {
basePath: 'src/app', // test files folder
filePattern: '**/*.spec.ts', // test files glob pattern
encoding: 'utf-8', // test files encoding
outputFolder: 'sonar', // report destination
legacyMode: false, // report for Sonarqube < 6.2 (disabled)
reportName: 'sonarqube_report.xml'
},
sonarQubeUnitReporter: {
sonarQubeVersion: 'LATEST',
outputFile: 'reports/sonarqube_report.xml',
Expand Down
33 changes: 20 additions & 13 deletions src/app/permission/app-detail/app-detail.component.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
<ocx-portal-page permission="APP#VIEW" helpArticleId="PAGE_PERMISSION_DETAIL">
<ocx-page-header
[loading]="loading"
[loadingApp]="loadingApp"
[actions]="(actions$ | async) ?? []"
[header]="loading ? '' : ('DIALOG.DETAIL.HEADER_' + currentApp.appType | translate) + currentApp.name"
[subheader]="loading ? '' : ('DIALOG.DETAIL.SUBHEADER_' + currentApp.appType | translate)"
[header]="loadingApp ? '' : ('DIALOG.DETAIL.HEADER_' + currentApp.appType | translate) + currentApp.name"
[subheader]="loadingApp ? '' : ('DIALOG.DETAIL.SUBHEADER_' + currentApp.appType | translate)"
[manualBreadcrumbs]="false"
>
</ocx-page-header>

<ocx-page-content>
<p-message
*ngIf="loadingExceptionKey"
*ngIf="exceptionKey"
id="apm_app_detail_permission_table_data_access_issue"
severity="error"
styleClass="m-3"
[text]="loadingExceptionKey | translate"
[text]="exceptionKey | translate"
></p-message>
<p-message
*ngIf="loadingApp || loadingPermissions"
id="apm_app_detail_permission_table_data_loading"
severity="info"
styleClass="m-3"
[text]="'ACTIONS.LOADING' | translate"
></p-message>

<p-table
*ngIf="!loadingExceptionKey"
*ngIf="!exceptionKey && !loadingApp && !loadingPermissions"
#permissionTable
id="apm_app_detail_permission_table"
styleClass="px-3 p-datatable-striped"
styleClass="pb-2 px-3 p-datatable-striped"
[columns]="rolesFiltered"
[value]="permissionRows"
[globalFilterFields]="filterBy"
Expand Down Expand Up @@ -138,7 +145,7 @@
<th
pFrozenColumn
id="apm_app_detail_permission_table_header_permissions"
[attr.colspan]="(currentApp.appType === 'PRODUCT' ? 2 : 3) + (showPermissionTools ? 2 : 0)"
[attr.colspan]="(currentApp.isProduct ? 2 : 3) + (showPermissionTools ? 2 : 0)"
class="py-2 border-right-primary"
[ngClass]="
myPermissions.includes('PERMISSION#EDIT') || myPermissions.includes('PERMISSION#DELETE') ? 'py-0' : 'py-1'
Expand Down Expand Up @@ -627,8 +634,8 @@
[id]="
'apm_app_detail_permission_table_' + row + '_' + role.name + '_' + rowData.key + '_not_assigned'
"
[ariaLabel]="'PERMISSION.ASSIGNMENTS.ROLE_ASSIGNEMENT_CHANGEABLE' | translate"
[pTooltip]="'PERMISSION.ASSIGNMENTS.ROLE_ASSIGNEMENT_CHANGEABLE' | translate"
[ariaLabel]="('PERMISSION.ASSIGNMENTS.GRANT_ROLE' | translate) + role.name + ' + ' + rowData.key"
[pTooltip]="('PERMISSION.ASSIGNMENTS.GRANT_ROLE' | translate) + role.name + ' + ' + rowData.key"
tooltipPosition="top"
tooltipEvent="hover"
>
Expand All @@ -643,8 +650,8 @@
class="my-0 p-1 p-button-rounded font-medium p-button-text p-button p-component p-button-icon-only"
(click)="onRemovePermission($event, rowData, role)"
[id]="'apm_app_detail_permission_table_' + row + '_' + role.name + '_' + rowData.key + '_assigned'"
[ariaLabel]="'PERMISSION.ASSIGNMENTS.ROLE_ASSIGNEMENT_CHANGEABLE' | translate"
[pTooltip]="'PERMISSION.ASSIGNMENTS.ROLE_ASSIGNEMENT_CHANGEABLE' | translate"
[ariaLabel]="('PERMISSION.ASSIGNMENTS.REVOKE_ROLE' | translate) + role.name + ' + ' + rowData.key"
[pTooltip]="('PERMISSION.ASSIGNMENTS.REVOKE_ROLE' | translate) + role.name + ' + ' + rowData.key"
tooltipPosition="top"
tooltipEvent="hover"
>
Expand Down Expand Up @@ -685,6 +692,6 @@

<app-permission-export
[products]="productNames"
[listedProductsHeader]="listedProductsHeader"
[listedProductsHeaderKey]="listedProductsHeaderKey"
[(displayExportDialog)]="displayPermissionExportDialog"
></app-permission-export>
31 changes: 14 additions & 17 deletions src/app/permission/app-detail/app-detail.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ describe('AppDetailComponent', () => {
})

it('should prepare action buttons on init', () => {
spyOn(component, 'onCreateRole')
spyOn(component, 'onExport')

component.ngOnInit()
Expand All @@ -243,10 +242,8 @@ describe('AppDetailComponent', () => {

actions[0].actionCallback()
actions[1].actionCallback()
actions[2].actionCallback()

expect(locationSpy.back).toHaveBeenCalled()
expect(component.onCreateRole).toHaveBeenCalled()
expect(component.onExport).toHaveBeenCalled()
})

Expand All @@ -271,7 +268,7 @@ describe('AppDetailComponent', () => {
component.onExport()

expect(component.productNames).toEqual(['Product A', 'Product B'])
expect(component.listedProductsHeader).toBe('ACTIONS.EXPORT.WS_APPLICATION_LIST')
expect(component.listedProductsHeaderKey).toBe('ACTIONS.EXPORT.WS_APPLICATION_LIST')
expect(component.displayPermissionExportDialog).toBe(true)
})

Expand All @@ -285,7 +282,7 @@ describe('AppDetailComponent', () => {
component.onExport()

expect(component.productNames).toEqual(['Test Product'])
expect(component.listedProductsHeader).toBe('ACTIONS.EXPORT.OF_APPLICATION')
expect(component.listedProductsHeaderKey).toBe('ACTIONS.EXPORT.OF_APPLICATION')
expect(component.displayPermissionExportDialog).toBe(true)
})
})
Expand All @@ -300,12 +297,12 @@ describe('AppDetailComponent', () => {

const res = (component as any).loadData()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_MISSING_PARAMETER')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_MISSING_PARAMETER')
expect(res).toBeUndefined()
})

it('should loadProductDetails successfully', () => {
const loadedApp: App = { ...app1, appType: 'PRODUCT', isProduct: true }
const loadedApp: App = { ...app1, appType: 'PRODUCT', isProduct: true, apps: ['appId1', 'appId2'] }
loadedApp.name = loadedApp.productName // is a product
component.urlParamAppId = app1.name!
component.urlParamAppType = loadedApp.appType
Expand Down Expand Up @@ -344,7 +341,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.NOT_FOUND.PRODUCT')
expect(component.exceptionKey).toBe('EXCEPTIONS.NOT_FOUND.PRODUCT')
})

it('should catch error if search for applications fails ', () => {
Expand All @@ -357,7 +354,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.APP')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.APP')
})

it('should catch non-HttpErrorResponse error if search for applications fails', () => {
Expand All @@ -366,7 +363,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_0.APP')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_0.APP')
})

it('should loadWorkspaceDetails successfully', () => {
Expand All @@ -389,7 +386,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.WORKSPACE')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.WORKSPACE')
expect(console.error).toHaveBeenCalledWith('getDetailsByWorkspaceName() => unknown response:', err)
})

Expand All @@ -400,7 +397,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_0.WORKSPACE')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_0.WORKSPACE')
})

it('should load roles and permissions', () => {
Expand Down Expand Up @@ -429,7 +426,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.ROLES')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.ROLES')
})

it('should display error when loading permissions fails', () => {
Expand All @@ -439,7 +436,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.PERMISSIONS')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.PERMISSIONS')
})
})

Expand Down Expand Up @@ -518,7 +515,7 @@ describe('AppDetailComponent', () => {

component['searchAssignments'](true, ['appId1'])

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.ASSIGNMENTS')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.ASSIGNMENTS')
})

it('should catch non-HttpErrorResponse error if search for assignments fails', () => {
Expand All @@ -527,7 +524,7 @@ describe('AppDetailComponent', () => {

component.ngOnInit()

expect(component.loadingExceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_0.ASSIGNMENTS')
expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_0.ASSIGNMENTS')
})

/*
Expand Down Expand Up @@ -798,7 +795,7 @@ describe('AppDetailComponent', () => {
})

it('should filter apps from permissions for the selected product', () => {
const loadedApp: App = { ...app1, appType: 'PRODUCT', isProduct: true }
const loadedApp: App = { ...app1, appType: 'PRODUCT', isProduct: true, apps: ['appId1', 'appId2'] }
loadedApp.name = loadedApp.productName // is a product
component.urlParamAppId = app1.name!
component.urlParamAppType = loadedApp.appType
Expand Down
Loading

0 comments on commit 2f5dbe0

Please sign in to comment.