Skip to content

PM-1068 refactor: allow PMs to view all copilot requests #801

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

Merged
merged 1 commit into from
May 5, 2025
Merged
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
10 changes: 1 addition & 9 deletions src/routes/copilotRequest/list.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import _ from 'lodash';

import models from '../../models';
import { ADMIN_ROLES } from '../../constants';
import util from '../../util';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ADMIN_ROLES import has been removed. Ensure that this constant is no longer needed in the code. If it is still required elsewhere, consider re-importing it.

import { PERMISSION } from '../../permissions/constants';

Expand All @@ -16,9 +15,6 @@ module.exports = [
return next(err);
}

const isAdmin = util.hasRoles(req, ADMIN_ROLES);

const userId = req.authUser.userId;
const projectId = _.parseInt(req.params.projectId);

let sort = req.query.sort ? decodeURIComponent(req.query.sort) : 'createdAt desc';
Expand All @@ -31,11 +27,7 @@ module.exports = [
}
const sortParams = sort.split(' ');

// Admin can see all requests and the PM can only see requests created by them
const whereCondition = _.assign({},
isAdmin ? {} : { createdBy: userId },
projectId ? { projectId } : {},
);
const whereCondition = projectId ? { projectId } : {};

return models.CopilotRequest.findAll({
where: whereCondition,
Expand Down