fix context cards for admins who can't read the course list

test plan:
 - enable student context cards feature
 - create an admin role that has "Users - view list" permission
   but no permissions on courses
 - as an admin in that role, go to /courses/X/users
 - click a student
 - the context card tray thing should appear
   (it might not have much in it, but it should appear)

fixes ADMIN-2207

Change-Id: I78d86dbe11e0d3ced3490027fd2f48e9da513625
Reviewed-on: https://gerrit.instructure.com/172592
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
Jeremy Stanley 2018-11-15 13:02:46 -07:00
parent 0c0af583e6
commit 4fea447db6
2 changed files with 13 additions and 2 deletions

View File

@ -95,13 +95,24 @@ const SCC_QUERY = gql`
}
`
// for admins who can view the roster but not the course list
function placeholderCourse(courseId) {
return {
_id: courseId,
permissions: {},
submissionsConnection: {
edges: []
}
}
}
export default props => {
return (
<ApolloProvider client={client}>
<Query query={SCC_QUERY} variables={{courseId: props.courseId, studentId: props.studentId}}>
{({data, loading}) => {
const {course, user} = data
return <StudentContextTray data={{loading, course, user}} {...props} />
return <StudentContextTray data={{loading, course: course || placeholderCourse(props.courseId), user}} {...props} />
}}
</Query>
</ApolloProvider>

View File

@ -206,7 +206,7 @@ export default class StudentContextTray extends React.Component {
<div>
<header className="StudentContextTray-Header">
<Avatar user={user}
canMasquerade={course.permissions.become_user}
canMasquerade={course.permissions && course.permissions.become_user}
courseId={this.props.courseId}
/>