Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix linting errors, have working build

Benjamin Bädorfff448c5cc100
diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rb
index 141bf5baa69..ef5b3ee859d 100644
--- a/config/initializers/permissions.rb
+++ b/config/initializers/permissions.rb
@@ -155,7 +155,7 @@ Rails.application.reloader.to_prepare do
{ 'work_packages/moves': %i[new create] },
require: :loggedin,
dependencies: :view_work_packages,
- contract_actions: { work_packages: %i[move] }
+ contract_actions: { work_packages: %i[move] }
wpt.permission :add_work_package_notes,
{
diff --git a/frontend/src/app/core/current-user/current-user.query.ts b/frontend/src/app/core/current-user/current-user.query.ts
index 036b53608d4..ea6a66d5744 100644
--- a/frontend/src/app/core/current-user/current-user.query.ts
+++ b/frontend/src/app/core/current-user/current-user.query.ts
@@ -1,5 +1,7 @@
import { Injectable } from '@angular/core';
import { filterNilValue, Query } from '@datorama/akita';
+import { Observable } from 'rxjs';
+import { CapabilityResource } from 'core-app/features/hal/resources/capability-resource';
import { CurrentUserState, CurrentUserStore } from './current-user.store';
@Injectable()
@@ -12,5 +14,5 @@ export class CurrentUserQuery extends Query<CurrentUserState> {
user$ = this.select(({ id, name, mail }) => ({ id, name, mail }));
- capabilities$ = this.select('capabilities').pipe(filterNilValue());
+ capabilities$ = this.select('capabilities').pipe(filterNilValue()) as Observable<CapabilityResource[]>;
}
diff --git a/frontend/src/app/features/invite-user-modal/invite-user.component.ts b/frontend/src/app/features/invite-user-modal/invite-user.component.ts
index 8f3b1e6f5aa..be6076e0e9a 100644
--- a/frontend/src/app/features/invite-user-modal/invite-user.component.ts
+++ b/frontend/src/app/features/invite-user-modal/invite-user.component.ts
@@ -76,7 +76,7 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
super(locals, cdRef, elementRef);
}
- ngOnInit() {
+ ngOnInit():void {
super.ngOnInit();
if (this.locals.projectId) {
@@ -93,13 +93,13 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
}
}
- onProjectSelectionSave({ type, project }:{ type:PrincipalType, project:ProjectResource|null }) {
+ onProjectSelectionSave({ type, project }:{ type:PrincipalType, project:ProjectResource|null }):void {
this.type = type;
this.project = project;
this.goTo(Steps.Principal);
}
- onPrincipalSave({ principalData, isAlreadyMember }:{ principalData:PrincipalData, isAlreadyMember:boolean }) {
+ onPrincipalSave({ principalData, isAlreadyMember }:{ principalData:PrincipalData, isAlreadyMember:boolean }):void {
this.principalData = principalData;
if (isAlreadyMember) {
return this.closeWithPrincipal();
@@ -108,7 +108,7 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
this.goTo(Steps.Role);
}
- onRoleSave(role:RoleResource) {
+ onRoleSave(role:RoleResource):void {
this.role = role;
if (this.type === PrincipalType.Placeholder) {
@@ -118,12 +118,12 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
}
}
- onMessageSave({ message }:{ message:string }) {
+ onMessageSave({ message }:{ message:string }):void {
this.message = message;
this.goTo(Steps.Summary);
}
- onSuccessfulSubmission($event:{ principal:HalResource }) {
+ onSuccessfulSubmission($event:{ principal:HalResource }):void {
if (this.principalData.principal !== $event.principal && this.type === PrincipalType.User) {
this.createdNewPrincipal = true;
}
@@ -131,11 +131,11 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
this.goTo(Steps.Success);
}
- goTo(step:Steps) {
+ goTo(step:Steps):void {
this.step = step;
}
- closeWithPrincipal() {
+ closeWithPrincipal():void {
this.data = this.principalData.principal;
this.closeMe();
}
diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
index 8ec98ed9541..c1b273f45a7 100644
--- a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
@@ -107,7 +107,7 @@ export class ProjectSelectionComponent implements OnInit {
});
}
- private setPlaceholderOption() {
+ private setPlaceholderOption():void {
if (this.bannersService.eeShowBanners) {
this.typeOptions.push({
value: PrincipalType.Placeholder,
@@ -130,14 +130,14 @@ export class ProjectSelectionComponent implements OnInit {
}
}
- async onSubmit($e:Event) {
+ async onSubmit($e:Event):Promise<void> {
$e.preventDefault();
if (this.projectAndTypeForm.invalid) {
this.projectAndTypeForm.markAsDirty();
return;
}
- const projectId = idFromLink(this.projectControl?.value.href);
+ const projectId = idFromLink(this.projectControl?.value?.href);
const project = await this.apiV3Service.projects.id(projectId).get().toPromise();
this.save.emit({
@@ -150,7 +150,7 @@ export class ProjectSelectionComponent implements OnInit {
projectFilterFn(projects:IProjectAutocompleteItem[]):IProjectAutocompleteItem[] {
const mapped = projects.map((project) => {
- const disabled = !this.projectInviteCapabilities.find((cap) => parseInt(cap.context.id, 10) === project.id);
+ const disabled = !this.projectInviteCapabilities.find((cap) => parseInt(cap.context?.id, 10) === project.id);
return {
...project,
disabled,
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.html b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.html
index 5c1947b774d..cf9cf7411cc 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.html
+++ b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.html
@@ -12,7 +12,7 @@
<op-project-autocompleter
*ngIf="active"
- (change)="selectProject($event)"
+ (valueChange)="selectProject($event)"
(keydown.escape)="active = false"
[apiFilters]="APIFilters"
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts
index 63e46d8c027..4b399922630 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts
+++ b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts
@@ -6,6 +6,7 @@ import {
Output,
} from '@angular/core';
import { FormArray } from '@angular/forms';
+import { ApiV3ListFilter } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalSourceLink } from 'core-app/features/hal/resources/hal-resource';
import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
@@ -37,7 +38,7 @@ export class NotificationSettingInlineCreateComponent {
already_selected: this.I18n.t('js.notifications.settings.project_specific.already_selected'),
};
- public get APIFilters() {
+ public get APIFilters():ApiV3ListFilter[] {
return [['visible', '=', [this.userId]]];
}
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.html b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.html
index b9d531b6a40..c883aacb135 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.html
+++ b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.html
@@ -8,6 +8,6 @@
[multiple]="true"
[id]="'values-' + filter.id"
class="advanced-filters--ng-select -multi-select"
- (change)="onChange($event)"
+ (valueChange)="onChange($event)"
></op-project-autocompleter>
</div>
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
index 7430b06787a..8a23b0a8424 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
+++ b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
@@ -26,7 +26,7 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { Component, Input, Output } from '@angular/core';
+import { ChangeDetectionStrategy, Component, Input, Output } from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { DebouncedEventEmitter } from 'core-app/shared/helpers/rxjs/debounced-event-emitter';
@@ -35,10 +35,12 @@ import { componentDestroyed } from '@w11k/ngx-componentdestroyed';
import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';
import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
+import { ID } from '@datorama/akita';
@Component({
selector: 'op-filter-project',
templateUrl: './filter-project.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FilterProjectComponent extends UntilDestroyedMixin {
@Input() public shouldFocus = false;
@@ -54,7 +56,7 @@ export class FilterProjectComponent extends UntilDestroyedMixin {
super();
}
- async onChange(val:HalResource[]|IProjectAutocompleteItem[]) {
+ async onChange(val:HalResource[]|IProjectAutocompleteItem[]):Promise<void> {
if (val === this.filter.values || val === undefined) {
return;
}
@@ -69,7 +71,7 @@ export class FilterProjectComponent extends UntilDestroyedMixin {
// Here we change from one to the other
const projects = await this.apiV3Service.projects.list({
filters: [
- [ 'id', '=', val.map((p:any) => p.id)],
+ ['id', '=', val.map((p:HalResource|IProjectAutocompleteItem) => String(p.id) || '')],
],
}).toPromise();
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
index bff244b84e1..70971c84b3f 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
@@ -92,7 +92,7 @@ export class OpAutocompleterComponent extends UntilDestroyedMixin implements OnI
@Input() public addTag?:boolean = false;
- @Input() public id:string = '';
+ @Input() public id = '';
@Input() public accesskey?:number;
diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/flatten-project-tree.ts b/frontend/src/app/shared/components/autocompleter/project-autocompleter/flatten-project-tree.ts
index 4410dad603f..2ea00db30e5 100644
--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/flatten-project-tree.ts
+++ b/frontend/src/app/shared/components/autocompleter/project-autocompleter/flatten-project-tree.ts
@@ -4,19 +4,17 @@ export const flattenProjectTree = (
projectTreeItems:IProjectAutocompleteItemTree[],
depth = 0,
):IProjectAutocompleteItem[] => projectTreeItems.reduce(
- (fullList, projectTreeItem) => {
- return [
- ...fullList,
- {
- ...projectTreeItem,
- numberOfAncestors: depth,
- // The actual list of ancestors does not matter anymore from this point forward,
- // but to keep typing straightforward for consumers of this component that use mapResultsFn,
- // it is marked as required in the interface.
- ancestors: [],
- },
- ...flattenProjectTree(projectTreeItem.children, depth + 1),
- ];
- },
+ (fullList, projectTreeItem) => [
+ ...fullList,
+ {
+ ...projectTreeItem,
+ numberOfAncestors: depth,
+ // The actual list of ancestors does not matter anymore from this point forward,
+ // but to keep typing straightforward for consumers of this component that use mapResultsFn,
+ // it is marked as required in the interface.
+ ancestors: [],
+ },
+ ...flattenProjectTree(projectTreeItem.children, depth + 1),
+ ],
[],
);
diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts b/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts
index b841bd72a30..f3579617140 100644
--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts
+++ b/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts
@@ -5,21 +5,9 @@ import {
IProjectAutocompleteItemTree,
} from './project-autocomplete-item';
-export const buildTree = (
- projects:IProjectAutocompleteItem[],
-):IProjectAutocompleteItemTree[] => projects.reduce(
- (tree, project) => {
- // The ancestors are listed from direct parent up to root. We'll build a tree structure for these ancestors here.
- // Some might already exist from other children that added them to the tree, or because they were part of the result
- // list themselves. However, if they're not available yet we'll need to generate them.
- return insertProjectWithAncestors(tree, project, project.ancestors);
- },
- [],
-);
-
const insertProjectWithAncestors = (
tree:IProjectAutocompleteItemTree[],
- project: IProjectAutocompleteItem,
+ project:IProjectAutocompleteItem,
ancestors:IHalResourceLink[],
):IProjectAutocompleteItemTree[] => {
// The project has no ancestors, thus it can become a part of the tree right away.
@@ -34,14 +22,12 @@ const insertProjectWithAncestors = (
}
const ancestorToFind = ancestors[0];
- const ancestorInTree = tree.find(leaf => leaf.href === ancestorToFind.href);
-
+ const ancestorInTree = tree.find((leaf) => leaf.href === ancestorToFind.href);
if (ancestorInTree) {
- return tree.map((item) => item === ancestorInTree
+ return tree.map((item) => (item === ancestorInTree
? { ...item, children: insertProjectWithAncestors(item.children, project, ancestors.slice(1)) }
- : { ...item },
- );
+ : { ...item }));
}
return [
@@ -55,3 +41,14 @@ const insertProjectWithAncestors = (
},
];
}
+
+export const buildTree = (
+ projects:IProjectAutocompleteItem[],
+):IProjectAutocompleteItemTree[] => projects.reduce(
+ // The ancestors are listed from direct parent up to root. We'll build a tree structure for these ancestors here.
+ // Some might already exist from other children that added them to the tree, or because they were part of the result
+ // list themselves. However, if they're not available yet we'll need to generate them.
+ (tree, project) => insertProjectWithAncestors(tree, project, project.ancestors),
+ [],
+);
+
diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.ts
index 59a51dfc5cd..dfa86f95482 100644
--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component.ts
@@ -31,12 +31,12 @@ import {
ElementRef,
Injector,
Input,
- OnInit,
forwardRef,
EventEmitter,
Output,
HostBinding,
ViewEncapsulation,
+ ChangeDetectionStrategy,
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
@@ -65,11 +65,12 @@ export interface IProjectAutocompleterData {
id:ID;
href:string;
name:string;
-};
+}
@Component({
templateUrl: './project-autocompleter.component.html',
styleUrls: ['./project-autocompleter.component.sass'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: projectsAutocompleterSelector,
providers: [{
@@ -78,12 +79,10 @@ export interface IProjectAutocompleterData {
multi: true,
}],
})
-export class ProjectAutocompleterComponent implements OnInit, ControlValueAccessor {
+export class ProjectAutocompleterComponent implements ControlValueAccessor {
@HostBinding('class.op-project-autocompleter') public className = true;
- projectTracker = (item:IProjectAutocompleteItem) => {
- return item.href || item.id;
- }
+ projectTracker = (item:IProjectAutocompleteItem):ID => item.href || item.id;
// Load all projects as default
@Input() public url:string = this.apiV3Service.projects.path;
@@ -113,15 +112,15 @@ export class ProjectAutocompleterComponent implements OnInit, ControlValueAccess
set value(value:IProjectAutocompleterData|IProjectAutocompleterData[]|null) {
this._value = value;
this.onChange(value);
- this.changeEmitter.emit(value);
+ this.valueChange.emit(value);
this.onTouched(value);
}
get plainValue():ID|ID[]|undefined {
- return Array.isArray(this.value) ? this.value?.map(i => i.id) : this.value?.id;
+ return Array.isArray(this.value) ? this.value?.map((i) => i.id) : this.value?.id;
}
- @Output('change') changeEmitter = new EventEmitter<IProjectAutocompleterData|IProjectAutocompleterData[]|null>();
+ @Output('valueChange') valueChange = new EventEmitter<IProjectAutocompleterData|IProjectAutocompleterData[]|null>();
constructor(
public elementRef:ElementRef,
@@ -134,11 +133,8 @@ export class ProjectAutocompleterComponent implements OnInit, ControlValueAccess
readonly injector:Injector,
) {
populateInputsFromDataset(this);
- debugger;
}
- ngOnInit() { }
-
public getAvailableProjects(searchTerm:string):Observable<IProjectAutocompleteItem[]> {
return getPaginatedResults<IProject>(
(params) => {
@@ -147,6 +143,7 @@ export class ProjectAutocompleterComponent implements OnInit, ControlValueAccess
if (searchTerm.length) {
filters.push(['name_and_identifier', '~', [searchTerm]]);
}
+
const fullParams = {
filters,
select: [
@@ -182,7 +179,7 @@ export class ProjectAutocompleterComponent implements OnInit, ControlValueAccess
);
}
- writeValue(value:IProjectAutocompleterData|null) {
+ writeValue(value:IProjectAutocompleterData|null):void {
this.value = value;
}
diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/recursive-sort.ts b/frontend/src/app/shared/components/autocompleter/project-autocompleter/recursive-sort.ts
index dd5a06b0fc1..b6e930a4d1c 100644
--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/recursive-sort.ts
+++ b/frontend/src/app/shared/components/autocompleter/project-autocompleter/recursive-sort.ts
@@ -1,6 +1,5 @@
import { IProjectAutocompleteItemTree } from './project-autocomplete-item';
-
// Recursively sort project children and their children by name
export const recursiveSort = (projects:IProjectAutocompleteItemTree[]):IProjectAutocompleteItemTree[] => projects
.map((project) => ({
diff --git a/frontend/src/app/shared/components/dataset-inputs.ts b/frontend/src/app/shared/components/dataset-inputs.ts
index 39f11b5db24..30151b89309 100644
--- a/frontend/src/app/shared/components/dataset-inputs.ts
+++ b/frontend/src/app/shared/components/dataset-inputs.ts
@@ -29,7 +29,7 @@ export interface DatasetInputsComponent extends DatasetInputsDecorated {
* constructor(
* elementRef:ElementRef,
* ) {
- * populateInputsFromDataset(this);
+ * populateInputsFromDataset(this);
* }
* }
* ```
@@ -65,8 +65,6 @@ export function populateInputsFromDataset(instance:DatasetInputsDecorated):any {
const input = cstr[declaredInputsParentKey] as ɵDirectiveDef<unknown>;
const inputs = input.declaredInputs as { [key:string]:string };
- console.log(inputs);
-
Object.keys(inputs)
.forEach((outsideName) => {
const insideName = inputs[outsideName];
diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts
index ec53f023380..4830156255a 100644
--- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts
@@ -1,17 +1,16 @@
-import { Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { FieldType } from '@ngx-formly/core';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
@Component({
selector: 'op-project-input',
templateUrl: './project-input.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProjectInputComponent extends FieldType implements OnInit {
projectId:string|undefined;
public ngOnInit():void {
- if (this.model?.project) {
- this.projectId = idFromLink(this.model.project?.href);
- }
+ this.projectId = idFromLink(this.model?.project?.href);
}
}
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.html
index 54339ad098a..e5fce2daf1b 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.html
+++ b/frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.html
@@ -4,5 +4,5 @@
[url]="schema.allowedValues.$link.href"
[apiFilters]="APIFilters"
- (change)="onModelChange($event)"
+ (valueChange)="onModelChange($event)"
></op-project-autocompleter>
diff --git a/modules/reporting/lib/widget/filters/project.rb b/modules/reporting/lib/widget/filters/project.rb
index cbd1f72cd4d..a47908116d0 100644
--- a/modules/reporting/lib/widget/filters/project.rb
+++ b/modules/reporting/lib/widget/filters/project.rb
@@ -32,17 +32,17 @@ class Widget::Filters::Project < Widget::Filters::Base
def render
write(content_tag(:div, id: "#{filter_class.underscore_name}_arg_1", class: 'advanced-filters--filter-value') do
label = label_tag "#{filter_class.underscore_name}_arg_1_val",
- h(filter_class.label) + ' ' + I18n.t(:label_filter_value),
+ "#{h(filter_class.label)} #{I18n.t(:label_filter_value)}",
class: 'hidden-for-sighted'
box = angular_component_tag 'op-project-autocompleter',
- inputs: {
- apiFilters: [],
- name: "values[#{filter_class.underscore_name}][]",
- multiple: true
- },
- id: "#{filter_class.underscore_name}_select_1",
- class: 'filter-value'
+ inputs: {
+ apiFilters: [],
+ name: "values[#{filter_class.underscore_name}][]",
+ multiple: true
+ },
+ id: "#{filter_class.underscore_name}_select_1",
+ class: 'filter-value'
content_tag(:span, class: 'inline-label') do
label + box