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

ESlint Fixes

Kabiru Mwenjac14af8583246
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts
index 95c5148a1c6..0657f829e74 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts
@@ -74,13 +74,13 @@ export default class EditorController extends withIndexOutletMixin(Controller) {
this.buttonRowTarget.classList.add('d-none');
this.formRowTarget.classList.remove('d-none');
- this.journalsContainerTarget?.classList.add('work-packages-activities-tab-index-component--journals-container_with-input-compensation');
+ this.indexOutlet.showJournalsContainerInput();
this.addCkEditorEventListeners();
if (this.isMobile()) {
this.focusEditor(0);
- } else if (this.sortingValue === 'asc' && journalsContainerAtBottom) {
+ } else if (this.indexOutlet.sortingValue === 'asc' && journalsContainerAtBottom) {
// scroll to (new) bottom if sorting is ascending and journals container was already at bottom before showing the form
this.autoScrollingOutlet.scrollJournalContainer(true);
this.focusEditor();
@@ -152,8 +152,8 @@ export default class EditorController extends withIndexOutletMixin(Controller) {
document.addEventListener('beforeunload', handlers.beforeUnload, { signal });
- this.element.addEventListener('turbo:submit-start', handlers.turboSubmitStart, { signal });
- this.element.addEventListener('turbo:submit-end', handlers.turboSubmitEnd, { signal });
+ (this.element).addEventListener('turbo:submit-start', handlers.turboSubmitStart, { signal });
+ (this.element).addEventListener('turbo:submit-end', handlers.turboSubmitEnd, { signal });
}
private removeEventListeners() {
@@ -186,7 +186,7 @@ export default class EditorController extends withIndexOutletMixin(Controller) {
};
const editorElement = this.ckEditorAugmentedTextarea;
- if (editorElement) {
+ if (editorElement && editorElement.addEventListener) {
editorElement.addEventListener('editorEscape', handlers.onEscapeEditor, { signal });
editorElement.addEventListener('editorKeyup', handlers.adjustMargin, { signal });
editorElement.addEventListener('editorBlur', handlers.onBlurEditor, { signal });
@@ -258,7 +258,7 @@ export default class EditorController extends withIndexOutletMixin(Controller) {
}
private get ckEditorAugmentedTextarea():HTMLElement | null {
- return this.element.querySelector('opce-ckeditor-augmented-textarea');
+ return (this.element).querySelector('opce-ckeditor-augmented-textarea');
}
get ckEditorInstance():ICKEditorInstance | undefined {
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
index ec7a4d9384c..5cfff74ae29 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
@@ -96,12 +96,18 @@ export default class IndexController extends Controller<HTMLElement> {
}
}
+ showJournalsContainerInput() {
+ if (!this.hasJournalsContainerTarget) return;
+
+ this.journalsContainerTarget.classList.add('work-packages-activities-tab-index-component--journals-container_with-input-compensation');
+ }
+
hideJournalsContainerInput() {
if (!this.hasJournalsContainerTarget) return;
this.journalsContainerTarget.style.marginBottom = '';
- this.journalsContainerTarget.classList.add('work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation');
this.journalsContainerTarget.classList.remove('work-packages-activities-tab-index-component--journals-container_with-input-compensation');
+ this.journalsContainerTarget.classList.add('work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation');
}
// used in specs for timing
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts
index 6ee6f7284b2..41420086095 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts
@@ -60,8 +60,8 @@ export default class InternalCommentController extends withIndexOutletMixin(Cont
declare readonly csrfToken:string;
connect() {
- // FIXME: `this` is not typed as HTMLElement, but as any
- useMeta(this as any, { suffix: false });
+ // FIXME: Cast to the proper Controller type for useMeta
+ useMeta(this as unknown as Controller<HTMLElement>, { suffix: false });
}
onSubmitEnd(_event:CustomEvent):void {
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/mixins/with-index-outlet.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/mixins/with-index-outlet.ts
index 56eca91eb1b..c17c1314aaa 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/mixins/with-index-outlet.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/mixins/with-index-outlet.ts
@@ -28,15 +28,11 @@
* ++
*/
-import { useMeta } from 'stimulus-use';
+import { Controller } from '@hotwired/stimulus';
import IndexController from '../index.controller';
-export const withIndexOutletMixin = (BaseController:any) => {
+export const withIndexOutletMixin = (BaseController:typeof Controller) => {
return class extends BaseController<HTMLElement> {
- constructor(...args:any[]) {
- super(...(args));
- }
-
static outlets = [
...(BaseController.outlets || []),
'work-packages--activities-tab--index',
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.ts
index ac227f4661c..636825d8b7f 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/polling.controller.ts
@@ -57,8 +57,8 @@ export default class PollingController extends withIndexOutletMixin(Controller)
private abortController = new AbortController();
async connect() {
- // FIXME: `this` is not typed as HTMLElement, but as any
- useMeta(this as any, { suffix: false });
+ // FIXME: Cast to the proper Controller type for useMeta
+ useMeta(this as unknown as Controller<HTMLElement>, { suffix: false });
const context = await window.OpenProject.getPluginContext();
this.turboRequests = context.services.turboRequests;
@@ -113,11 +113,10 @@ export default class PollingController extends withIndexOutletMixin(Controller)
}
private setLatestKnownChangesetUpdatedAt() {
- const latestKnownChangesetUpdatedAtKey = `work-package-${this.indexOutlet.workPackageIdValue}-latest-known-changeset-updated-at-${this.indexOutlet.userIdValue}`;
const latestChangesetUpdatedAt = this.parseLatestChangesetUpdatedAtFromDom();
if (latestChangesetUpdatedAt) {
- localStorage.setItem(latestKnownChangesetUpdatedAtKey, latestChangesetUpdatedAt.toString());
+ localStorage.setItem(this.latestKnownChangesetUpdatedAtKey, latestChangesetUpdatedAt.toString());
}
}
@@ -126,6 +125,10 @@ export default class PollingController extends withIndexOutletMixin(Controller)
return latestKnownChangesetUpdatedAt ? new Date(latestKnownChangesetUpdatedAt) : null;
}
+ private get latestKnownChangesetUpdatedAtKey():string {
+ return `work-package-${this.indexOutlet.workPackageIdValue}-latest-known-changeset-updated-at-${this.indexOutlet.userIdValue}`;
+ }
+
private setupEventListeners() {
const { signal } = this.abortController;
@@ -267,15 +270,18 @@ export default class PollingController extends withIndexOutletMixin(Controller)
if (!latestChangesetUpdatedAt) return null;
const railsTimestamp = latestChangesetUpdatedAt.getTime() / 1000;
- const userId = this.element
- .querySelector(`[data-journal-with-changeset-updated-at="${railsTimestamp}"]`)
- ?.getAttribute('data-journal-with-changeset-user-id');
+ const element = (this.element)
+ .querySelector(`[data-journal-with-changeset-updated-at="${railsTimestamp}"]`);
+
+ if (!element) return null;
+
+ const userId = element.getAttribute('data-journal-with-changeset-user-id');
return userId ? parseInt(userId, 10) : null;
}
private parseLatestChangesetUpdatedAtFromDom():Date | null {
- const elements = this.element.querySelectorAll('[data-journal-with-changeset-updated-at]') as NodeListOf<HTMLElement>;
+ const elements = (this.element).querySelectorAll('[data-journal-with-changeset-updated-at]');
const dates = Array.from(elements)
.map((element) => element.getAttribute('data-journal-with-changeset-updated-at'))
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts
index 8b4bdb39592..31184559c98 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts
@@ -51,7 +51,7 @@ export default class StemsController extends withIndexOutletMixin(Controller) {
if (this.isMobile()) {
if (this.indexOutlet.sortingValue === 'asc') return;
- const initialJournalContainer = this.element.querySelector('.work-packages-activities-tab-journals-item-component-details--journal-details-container[data-initial="true"]') as HTMLElement;
+ const initialJournalContainer = (this.element).querySelector('.work-packages-activities-tab-journals-item-component-details--journal-details-container[data-initial="true"]');
if (initialJournalContainer) {
initialJournalContainer.classList.add('work-packages-activities-tab-journals-item-component-details--journal-details-container--border-removed');
@@ -60,7 +60,7 @@ export default class StemsController extends withIndexOutletMixin(Controller) {
}
private handleLastStemPartVisibility() {
- const emptyLines = this.element.querySelectorAll('.empty-line') as NodeListOf<HTMLElement>;
+ const emptyLines = (this.element).querySelectorAll('.empty-line');
// make sure all are visible first
emptyLines.forEach((container) => {
@@ -72,8 +72,10 @@ export default class StemsController extends withIndexOutletMixin(Controller) {
// then hide the last one again
if (emptyLines.length > 0) {
// take the parent container of the last empty line
- const lastEmptyLineContainer = emptyLines[emptyLines.length - 1].parentElement as HTMLElement;
- lastEmptyLineContainer.classList.add('work-packages-activities-tab-journals-item-component-details--journal-details-container--hidden');
+ const lastEmptyLineContainer = emptyLines[emptyLines.length - 1].parentElement;
+ if (lastEmptyLineContainer) {
+ lastEmptyLineContainer.classList.add('work-packages-activities-tab-journals-item-component-details--journal-details-container--hidden');
+ }
}
}
}