Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTS-39072: Uniform organization levels everywhere #1350

Merged
merged 8 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UI/src/app/config/config.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const ConfigRoutes: Routes = [
{
path: 'AdvancedSettings',
component: AdvancedSettingsComponent,
canActivate: [ViewerGuard, GuestGuard]
canActivate: [GuestGuard]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('JiraConfigComponent', () => {
const fakeProjectKeyList = require('../../../../test/resource/fakeProjectKeyList.json');
const fakeBranchesForProject = require('../../../../test/resource/fakeBranchesForProject.json');
const fakeConfiguredTools = require('../../../../test/resource/fakeConfiguredTools.json');
const fakeCompleteHiearchyData = require('../../../../test/resource/fakeCompleteHierarchyData.json');
const fakeSelectedTool = [{
id: '5fc086b9410df80001701334',
toolName: 'Jira',
Expand Down Expand Up @@ -186,6 +187,7 @@ describe('JiraConfigComponent', () => {
sharedService.setSelectedToolConfig(fakeSelectedTool);
httpMock = TestBed.inject(HttpTestingController);
router = TestBed.inject(Router);
localStorage.setItem('completeHierarchyData', JSON.stringify(fakeCompleteHiearchyData));
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class JiraConfigComponent implements OnInit {
jiraTemplate: any[];
gitActionWorkflowNameList: any[];
cloudEnv: any;
isGitlabToolFieldEnabled : boolean;
isGitlabToolFieldEnabled: boolean;
isConfigureTool: boolean = false;
showAddNewBtn: boolean = true;

Expand All @@ -123,6 +123,24 @@ export class JiraConfigComponent implements OnInit {

ngOnInit(): void {
this.selectedProject = this.sharedService.getSelectedProject();

const selectedType = this.selectedProject.type !== 'Scrum' ? 'kanban' : 'scrum';
const levelDetails = JSON.parse(localStorage.getItem('completeHierarchyData'))[selectedType].map((x) => {
return {
id: x['hierarchyLevelId'],
name: x['hierarchyLevelName']
}
});

Object.keys(this.selectedProject).forEach(key => {
if(levelDetails.map(x => x.id).includes(key)) {
let propertyName = levelDetails.filter(x=> x.id === key)[0].name;
this.selectedProject[propertyName] = this.selectedProject[key];
delete this.selectedProject[key];
}
});


this.isGitlabToolFieldEnabled = this.sharedService.getGlobalConfigData()?.gitlabToolFieldFlag;
if (!this.selectedProject) {
this.router.navigate(['./dashboard/Config/ProjectList']);
Expand All @@ -144,7 +162,7 @@ export class JiraConfigComponent implements OnInit {
this.getConnectionList(this.urlParam);
this.initializeFields(this.urlParam);

if(this.isGitlabToolFieldEnabled){
if (this.isGitlabToolFieldEnabled) {
this.showFormElements(['gitLabID'])
} else {
this.hideFormElements(['gitLabID'])
Expand Down Expand Up @@ -303,7 +321,7 @@ export class JiraConfigComponent implements OnInit {
this.messenger.add({
severity: 'error',
summary: error.message,
});
});
}
}, (err) => {
this.jenkinsJobNameList = [];
Expand Down Expand Up @@ -467,8 +485,8 @@ export class JiraConfigComponent implements OnInit {
});
});

if(this.urlParam?.toLowerCase() == 'jira' || this.urlParam?.toLowerCase() == 'jiratest'
|| this.urlParam?.toLowerCase() == 'zephyr' || this.urlParam?.toLowerCase() == 'azure'){
if (this.urlParam?.toLowerCase() == 'jira' || this.urlParam?.toLowerCase() == 'jiratest'
|| this.urlParam?.toLowerCase() == 'zephyr' || this.urlParam?.toLowerCase() == 'azure') {
this.showAddNewBtn = false;
}
}
Expand Down Expand Up @@ -1796,7 +1814,7 @@ export class JiraConfigComponent implements OnInit {
tooltip: `list of inputs to access GitLab data.<br />
<i>
Impacted : All GitLab based KPIs</i>`,
}
}
],
};
}
Expand Down Expand Up @@ -2548,31 +2566,31 @@ export class JiraConfigComponent implements OnInit {
severity: 'success',
summary: `${this.urlParam} config submitted!! ${successAlert}`,
});
// update the table
if (!this.configuredTools || !this.configuredTools.length) {
this.configuredTools = [];
}
// update the table
if (!this.configuredTools || !this.configuredTools.length) {
this.configuredTools = [];
}

// empty the form
if (this.urlParam === 'Sonar') {
this.tool['apiVersion'].enable();
this.tool['projectKey'].enable();
}
// empty the form
if (this.urlParam === 'Sonar') {
this.tool['apiVersion'].enable();
this.tool['projectKey'].enable();
}

this.configuredTools.push(response['data']);
this.configuredTools.forEach((tool) => {
this.connections?.forEach((connection) => {
if (tool.connectionId === connection.id) {
tool['connectionName'] = connection.connectionName;
}
});
this.configuredTools.push(response['data']);
this.configuredTools.forEach((tool) => {
this.connections?.forEach((connection) => {
if (tool.connectionId === connection.id) {
tool['connectionName'] = connection.connectionName;
}
});
if (this.urlParam == 'Jira' || this.urlParam === 'Azure' || this.urlParam === 'Zephyr' || this.urlParam === 'JiraTest') {
this.isConfigureTool = false;
this.showAddNewBtn = false;
}else{
this.toolForm.reset();
}
});
if (this.urlParam == 'Jira' || this.urlParam === 'Azure' || this.urlParam === 'Zephyr' || this.urlParam === 'JiraTest') {
this.isConfigureTool = false;
this.showAddNewBtn = false;
} else {
this.toolForm.reset();
}
} else {
this.messenger.add({
severity: 'error',
Expand Down Expand Up @@ -2629,8 +2647,8 @@ export class JiraConfigComponent implements OnInit {
// empty the form
if (this.urlParam !== 'Jira' && this.urlParam !== 'Azure' && this.urlParam !== 'Zephyr' && this.urlParam !== 'JiraTest') {
this.toolForm.reset();
}else{
this.isConfigureTool = false;
} else {
this.isConfigureTool = false;
}
} else {
this.messenger.add({
Expand Down Expand Up @@ -2758,7 +2776,7 @@ export class JiraConfigComponent implements OnInit {
if (selectedTemplate?.templateName === 'Custom Template') {
this.toolForm.get('metadataTemplateCode').disable();
}
}else{
} else {
this.toolForm.get('metadataTemplateCode')?.setValue(this.jiraTemplate[0]?.templateCode);
}
})
Expand Down Expand Up @@ -2820,14 +2838,14 @@ export class JiraConfigComponent implements OnInit {
this.router.navigate(['./dashboard/Config/connection-list']);
}

handleToolConfiguration(type?){
handleToolConfiguration(type?) {
this.isConfigureTool = true;
if(type == 'new'){
this.isEdit = false;
if (type == 'new') {
this.isEdit = false;
}
setTimeout(() => {
const element = document.getElementById("tool-configuration");
element.scrollIntoView({behavior: "smooth", inline: "nearest"});
element.scrollIntoView({ behavior: "smooth", inline: "nearest" });
}, 100);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('ToolMenuComponent', () => {

const toolsData = require('../../../../test/resource/fakeToolsData.json');
const mappingData = require('../../../../test/resource/fakeToolMappings.json');
const fakeCompleteHiearchyData = require('../../../../test/resource/fakeCompleteHierarchyData.json');
const fakeProject = {
id: '6335363749794a18e8a4479b',
name: 'Scrum Project',
Expand Down Expand Up @@ -84,6 +85,7 @@ describe('ToolMenuComponent', () => {

httpService = TestBed.inject(HttpService) as jasmine.SpyObj<HttpService>;
sharedService = TestBed.inject(SharedService) as jasmine.SpyObj<SharedService>;
localStorage.setItem('completeHierarchyData', JSON.stringify(fakeCompleteHiearchyData));
});

beforeEach(() => {
Expand All @@ -95,8 +97,9 @@ describe('ToolMenuComponent', () => {
sharedService.setSelectedProject(fakeProject);
httpMock = TestBed.inject(HttpTestingController);
router = TestBed.inject(Router);

component.selectedProject = { id: 1, Type: 'Scrum' };

});

it('should create', () => {
Expand Down Expand Up @@ -297,7 +300,7 @@ describe('ToolMenuComponent', () => {
expect(gaSpy).toHaveBeenCalled();
})

it('should navigate back to Projects List if no selected project is there', () => {
xit('should navigate back to Projects List if no selected project is there', () => {
sharedService.setSelectedProject(null);
component.selectedProject = {
saveAssigneeDetails: true
Expand Down
44 changes: 32 additions & 12 deletions UI/src/app/config/project-config/tool-menu/tool-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,17 @@ export class ToolMenuComponent implements OnInit {
public getAuthorizationService: GetAuthorizationService,
private ga: GoogleAnalyticsService,
private route: ActivatedRoute) {
this.configOptions = [
{
'name': 'Tools Connected',
'value': 'toolsConnected'
},
{
'name': 'Project Configuration',
'value': 'projectConfig'
}
]
this.configOptions = [
{
'name': 'Tools Connected',
'value': 'toolsConnected'
},
{
'name': 'Project Configuration',
'value': 'projectConfig'
}
]

}

ngOnInit() {
Expand All @@ -89,11 +90,30 @@ export class ToolMenuComponent implements OnInit {
{ name: 'Jira', value: false },
{ name: 'Azure Boards', value: true }
];
this.selectedProject = this.sharedService.getSelectedProject();
this.isProjectAdmin = this.getAuthorizationService.checkIfProjectAdmin();
this.isSuperAdmin = this.getAuthorizationService.checkIfSuperUser();
this.isAssigneeSwitchChecked = this.selectedProject?.saveAssigneeDetails;
this.repoToolsEnabled = this.sharedService.getGlobalConfigData()?.repoToolFlag;
this.selectedProject = this.sharedService.getSelectedProject();
const selectedType = this.selectedProject.type !== 'Scrum' ? 'kanban' : 'scrum';
const levelDetails = JSON.parse(localStorage.getItem('completeHierarchyData'))[selectedType].map((x) => {
return {
id: x['hierarchyLevelId'],
name: x['hierarchyLevelName']
}
});

setTimeout(() => {
if (this.selectedProject && Object.keys(this.selectedProject)?.length) {
Object.keys(this.selectedProject).forEach(key => {
if (levelDetails.map(x => x.id).includes(key)) {
let propertyName = levelDetails.filter(x => x.id === key)[0].name;
this.selectedProject[propertyName] = this.selectedProject[key];
delete this.selectedProject[key];
}
});
}
});

this.getProjects();

Expand Down Expand Up @@ -515,7 +535,7 @@ export class ToolMenuComponent implements OnInit {
this.userProjects.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
// this.selectedProject = this.userProjects[0];
}
if(this.selectedProject && this.router.url.includes('ToolMenu')) {
if (this.selectedProject && this.router.url.includes('ToolMenu')) {
this.selectedProject = this.userProjects.filter((x) => x.id == this.selectedProject?.id)[0]
} else {
this.selectedProject = this.userProjects[0];
Expand Down
2 changes: 1 addition & 1 deletion UI/src/app/dashboard/iteration/iteration.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ <h3 class="text-label">{{x?.label}}
</ng-container>
<ng-template #noSprintsTemplate>
<div class="p-d-flex p-align-center p-justify-center no-sprint-msg">
<h2 class="msg">The selected project need to have atleast one sprint available for the KPI's to show up</h2>
<h2 class="msg">The selected project need to have atleast one ACTIVE sprint available for the KPI's to show up</h2>
</div>
</ng-template>
<ng-template #noProjectsTemplate>
Expand Down
2 changes: 1 addition & 1 deletion UI/src/app/dashboardv2/filter-v2/filter-new.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ng-container>
</div>
</div>
<div class="selected-filter-container p-d-flex p-jc-between p-pl-3 p-pr-3">
<div class="selected-filter-container p-d-flex p-jc-between p-pl-3 p-pr-3" *ngIf="!noSprint">
<ul class="p-m-0 p-pl-0 p-d-flex p-flex-wrap">
<ng-container *ngIf="getObjectKeys(colorObj).length">
<ng-container *ngFor="let item of getObjectKeys(colorObj); let i = index;">
Expand Down
Loading
Loading