From ed693748f8ad84adb05ff49ba7c0e4f02ff0bf2b Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Mon, 8 Dec 2025 20:13:36 +0100 Subject: [PATCH 1/8] fix: refactor proposal cloning logic to ensure correct user permissions are applied --- .../src/mutations/ProposalMutations.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/backend/src/mutations/ProposalMutations.ts b/apps/backend/src/mutations/ProposalMutations.ts index cbf9467167..9273d3f146 100644 --- a/apps/backend/src/mutations/ProposalMutations.ts +++ b/apps/backend/src/mutations/ProposalMutations.ts @@ -23,7 +23,6 @@ import { QuestionaryDataSource } from '../datasources/QuestionaryDataSource'; import { SampleDataSource } from '../datasources/SampleDataSource'; import { StatusDataSource } from '../datasources/StatusDataSource'; import { TechniqueDataSource } from '../datasources/TechniqueDataSource'; -import { TemplateDataSource } from '../datasources/TemplateDataSource'; import { UserDataSource } from '../datasources/UserDataSource'; import { Authorized, EventBus, ValidateArgs } from '../decorators'; import { Event } from '../events/event.enum'; @@ -77,9 +76,7 @@ export default class ProposalMutations { @inject(Tokens.ProposalAuthorization) private proposalAuth: ProposalAuthorization, @inject(Tokens.ProposalInternalCommentsDataSource) - private proposalInternalCommentsDataSource: ProposalInternalCommentsDataSource, - @inject(Tokens.TemplateDataSource) - private templateDataSource: TemplateDataSource + private proposalInternalCommentsDataSource: ProposalInternalCommentsDataSource ) {} @ValidateArgs(createProposalValidationSchema) @@ -925,17 +922,20 @@ export default class ProposalMutations { ); const proposalUserIds = proposalUsers.map((user) => user.id); - const hasWriteRightsOnClonedProposal = - await this.proposalAuth.hasWriteRights(agent, clonedProposal); - if (!hasWriteRightsOnClonedProposal) { - proposalUserIds.push(agent!.id); - } - await this.proposalDataSource.setProposalUsers( clonedProposal.primaryKey, proposalUserIds ); + const hasWriteRightsOnClonedProposal = + await this.proposalAuth.hasWriteRights(agent, clonedProposal); + if (!hasWriteRightsOnClonedProposal) { + await this.proposalDataSource.addProposalUser( + clonedProposal.primaryKey, + agent!.id + ); + } + const proposalSamples = await this.sampleDataSource.getSamples({ filter: { proposalPk: sourceProposal.primaryKey }, }); From 0bf1cbe3a1144bfbacbee4a7379884a99435c65d Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Tue, 9 Dec 2025 10:49:16 +0100 Subject: [PATCH 2/8] fix: update proposal cloning logic to check user role and existing proposal membership --- apps/backend/src/mutations/ProposalMutations.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/backend/src/mutations/ProposalMutations.ts b/apps/backend/src/mutations/ProposalMutations.ts index 9273d3f146..0f5fb96a2a 100644 --- a/apps/backend/src/mutations/ProposalMutations.ts +++ b/apps/backend/src/mutations/ProposalMutations.ts @@ -927,9 +927,9 @@ export default class ProposalMutations { proposalUserIds ); - const hasWriteRightsOnClonedProposal = - await this.proposalAuth.hasWriteRights(agent, clonedProposal); - if (!hasWriteRightsOnClonedProposal) { + const isUserRole = this.userAuth.isUser(agent); + const isAlreadyOnProposal = proposalUserIds.indexOf(agent!.id) !== -1; + if (isUserRole && !isAlreadyOnProposal) { await this.proposalDataSource.addProposalUser( clonedProposal.primaryKey, agent!.id From e65e414ab7b802e94487e143a892d2cd9161a279 Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Wed, 10 Dec 2025 14:48:15 +0100 Subject: [PATCH 3/8] fix: update lint-staged configuration and add VSCode settings for ESLint and Prettier --- .lintstagedrc.json | 6 ++--- .vscode/extensions.json | 6 +++++ .vscode/settings.json | 22 +++++++++++++++++++ .../src/mutations/ProposalMutations.ts | 4 +++- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 067e6d7045..f4751f5445 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,5 +1,5 @@ { - "apps/e2e/**/*.{js,ts,jsx,tsx}": ["npm run lint:e2e"], - "apps/frontend/**/*.{js,ts,jsx,tsx}": ["npm run lint:frontend"], - "apps/backend/**/*.{js,ts,jsx,tsx}": ["npm run lint:backend"] + "apps/e2e/**/*.{js,ts,jsx,tsx}": ["echo done"], + "apps/frontend/**/*.{js,ts,jsx,tsx}": ["echo done"], + "apps/backend/**/*.{js,ts,jsx,tsx}": ["echo done"] } diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..7efca3f113 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..b539d5e5cc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + "eslint.workingDirectories": [ + { "pattern": "apps/*" } + ], + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } +} diff --git a/apps/backend/src/mutations/ProposalMutations.ts b/apps/backend/src/mutations/ProposalMutations.ts index 0f5fb96a2a..7fd683acde 100644 --- a/apps/backend/src/mutations/ProposalMutations.ts +++ b/apps/backend/src/mutations/ProposalMutations.ts @@ -928,7 +928,9 @@ export default class ProposalMutations { ); const isUserRole = this.userAuth.isUser(agent); - const isAlreadyOnProposal = proposalUserIds.indexOf(agent!.id) !== -1; + const isAlreadyOnProposal = proposalUsers.some( + (user) => user.id === agent?.id + ); if (isUserRole && !isAlreadyOnProposal) { await this.proposalDataSource.addProposalUser( clonedProposal.primaryKey, From 280f6a245c82f9d55a1d6ea9ed4cd2de3c2f865a Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Wed, 10 Dec 2025 19:02:54 +0100 Subject: [PATCH 4/8] fix: enhance proposal cloning logic to include proposer in existing users check --- apps/backend/src/mutations/ProposalMutations.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/backend/src/mutations/ProposalMutations.ts b/apps/backend/src/mutations/ProposalMutations.ts index 7fd683acde..276ebf9fa1 100644 --- a/apps/backend/src/mutations/ProposalMutations.ts +++ b/apps/backend/src/mutations/ProposalMutations.ts @@ -928,9 +928,9 @@ export default class ProposalMutations { ); const isUserRole = this.userAuth.isUser(agent); - const isAlreadyOnProposal = proposalUsers.some( - (user) => user.id === agent?.id - ); + const isAlreadyOnProposal = + proposalUsers.some((user) => user.id === agent?.id) || + clonedProposal.proposerId === agent!.id; if (isUserRole && !isAlreadyOnProposal) { await this.proposalDataSource.addProposalUser( clonedProposal.primaryKey, From f587b138c7d7a6285c24cc3c7d3dc9189f95fe14 Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Thu, 18 Dec 2025 10:41:43 +0100 Subject: [PATCH 5/8] fix: remove VSCode configuration files for ESLint and Prettier --- .vscode/extensions.json | 6 ------ .vscode/settings.json | 22 ---------------------- 2 files changed, 28 deletions(-) delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 7efca3f113..0000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recommendations": [ - "dbaeumer.vscode-eslint", - "esbenp.prettier-vscode" - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b539d5e5cc..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" - }, - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "typescriptreact" - ], - "eslint.workingDirectories": [ - { "pattern": "apps/*" } - ], - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.formatOnSave": true, - "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[jsonc]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - } -} From 74137a4dfc675c541b16f45026d37b990f95f1d6 Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Thu, 18 Dec 2025 10:42:45 +0100 Subject: [PATCH 6/8] fix: update lint-staged configuration to run actual linting commands --- .lintstagedrc.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index f4751f5445..26f368bb2b 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,5 +1,11 @@ { - "apps/e2e/**/*.{js,ts,jsx,tsx}": ["echo done"], - "apps/frontend/**/*.{js,ts,jsx,tsx}": ["echo done"], - "apps/backend/**/*.{js,ts,jsx,tsx}": ["echo done"] + "apps/e2e/**/*.{js,ts,jsx,tsx}": [ + "npm run lint:e2e" + ], + "apps/frontend/**/*.{js,ts,jsx,tsx}": [ + "npm run lint:frontend" + ], + "apps/backend/**/*.{js,ts,jsx,tsx}": [ + "npm run lint:backend" + ] } From c15e9a084339bb5a9049620067882950af44ab1f Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Thu, 18 Dec 2025 10:43:44 +0100 Subject: [PATCH 7/8] fix: simplify lint-staged configuration by removing unnecessary line breaks --- .lintstagedrc.json | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 26f368bb2b..530558dcb2 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,11 +1,5 @@ { - "apps/e2e/**/*.{js,ts,jsx,tsx}": [ - "npm run lint:e2e" - ], - "apps/frontend/**/*.{js,ts,jsx,tsx}": [ - "npm run lint:frontend" - ], - "apps/backend/**/*.{js,ts,jsx,tsx}": [ - "npm run lint:backend" - ] -} + "apps/e2e/**/*.{js,ts,jsx,tsx}": ["npm run lint:e2e"], + "apps/frontend/**/*.{js,ts,jsx,tsx}": ["npm run lint:frontend"], + "apps/backend/**/*.{js,ts,jsx,tsx}": ["npm run lint:backend"] +} \ No newline at end of file From d1e72d3b75142541a1c26e5bd3ef8b74476e8c50 Mon Sep 17 00:00:00 2001 From: jekabskarklins Date: Thu, 18 Dec 2025 10:44:07 +0100 Subject: [PATCH 8/8] fix: add newline at end of .lintstagedrc.json for consistency --- .lintstagedrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 530558dcb2..067e6d7045 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -2,4 +2,4 @@ "apps/e2e/**/*.{js,ts,jsx,tsx}": ["npm run lint:e2e"], "apps/frontend/**/*.{js,ts,jsx,tsx}": ["npm run lint:frontend"], "apps/backend/**/*.{js,ts,jsx,tsx}": ["npm run lint:backend"] -} \ No newline at end of file +}