Skip to content

Commit

Permalink
Merge pull request #1233 from w3c/development
Browse files Browse the repository at this point in the history
Create October 9, 2024 Release

Includes the following changes:
* #1214
* #1208, which addresses #1201
* #1225
* #1227, which addresses #1226
* #1224, which addresses #759
* #1229, which addresses #1228
  • Loading branch information
howard-e authored Oct 9, 2024
2 parents fb8c341 + d7cc1fd commit 90914bc
Show file tree
Hide file tree
Showing 51 changed files with 6,236 additions and 811 deletions.
45 changes: 33 additions & 12 deletions client/components/CandidateReview/TestPlans/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ClippedProgressBar from '@components/common/ClippedProgressBar';
import { dates } from 'shared';
import './TestPlans.css';
import { calculations } from 'shared';
import { UserPropType } from '../../common/proptypes';

const FullHeightContainer = styled(Container)`
min-height: calc(100vh - 64px);
Expand Down Expand Up @@ -177,7 +178,7 @@ const None = styled.span`
}
`;

const TestPlans = ({ testPlanVersions }) => {
const TestPlans = ({ testPlanVersions, me }) => {
const [atExpandTableItems, setAtExpandTableItems] = useState({
1: true,
2: true,
Expand Down Expand Up @@ -503,20 +504,39 @@ const TestPlans = ({ testPlanVersions }) => {
.filter(t => t.isCandidateReview === true)
.filter(t => uniqueFilter(t, uniqueLinks, 'link'));

const canReview =
me.roles.includes('ADMIN') ||
(me.roles.includes('VENDOR') &&
me.company.ats.some(at => at.id === atId));

const getTitleEl = () => {
if (canReview) {
return (
<Link
to={`/candidate-test-plan/${testPlanVersion.id}/${atId}`}
>
{getTestPlanVersionTitle(testPlanVersion, {
includeVersionString: true
})}{' '}
({testsCount} Test
{testsCount === 0 || testsCount > 1 ? `s` : ''})
</Link>
);
}
return (
<>
{getTestPlanVersionTitle(testPlanVersion, {
includeVersionString: true
})}{' '}
({testsCount} Test
{testsCount === 0 || testsCount > 1 ? `s` : ''})
</>
);
};
return (
dataExists && (
<tr key={testPlanVersion.id}>
<th>
<Link
to={`/candidate-test-plan/${testPlanVersion.id}/${atId}`}
>
{getTestPlanVersionTitle(testPlanVersion, {
includeVersionString: true
})}{' '}
({testsCount} Test
{testsCount === 0 || testsCount > 1 ? `s` : ''})
</Link>
</th>
<th>{getTitleEl()}</th>
<CenteredTd>
<i>
{dates.convertDateToString(
Expand Down Expand Up @@ -778,6 +798,7 @@ TestPlans.propTypes = {
)
})
).isRequired,
me: UserPropType.isRequired,
triggerPageUpdate: PropTypes.func
};

Expand Down
6 changes: 5 additions & 1 deletion client/components/CandidateReview/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { useQuery } from '@apollo/client';
import PageStatus from '../common/PageStatus';
import TestPlans from './TestPlans';
import { CANDIDATE_REVIEW_PAGE_QUERY } from './queries';
import { ME_QUERY } from '../App/queries';

const CandidateReview = () => {
const { loading, data, error } = useQuery(CANDIDATE_REVIEW_PAGE_QUERY, {
fetchPolicy: 'cache-and-network'
});

const { data: meData } = useQuery(ME_QUERY);
const { me } = meData;

if (error) {
return (
<PageStatus
Expand All @@ -33,7 +37,7 @@ const CandidateReview = () => {

const testPlanVersions = data.testPlanVersions;

return <TestPlans testPlanVersions={testPlanVersions} />;
return <TestPlans testPlanVersions={testPlanVersions} me={me} />;
};

export default CandidateReview;
17 changes: 14 additions & 3 deletions client/components/ConfirmAuth/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
import { Navigate, useParams } from 'react-router-dom';
import PropTypes from 'prop-types';
import { useQuery } from '@apollo/client';
import { ME_QUERY } from '../App/queries';
import { evaluateAuth } from '../../utils/evaluateAuth';

const ConfirmAuth = ({ children, requiredPermission }) => {
const ConfirmAuth = ({ children, requiredPermission, requireVendorForAt }) => {
const { data } = useQuery(ME_QUERY);
const { atId } = useParams();

const auth = evaluateAuth(data && data.me ? data.me : {});
const { roles, username, isAdmin, isSignedIn } = auth;
const company = data && data.me ? data.me.company : null;

if (!username) return <Navigate to={{ pathname: '/invalid-request' }} />;

Expand All @@ -21,6 +23,14 @@ const ConfirmAuth = ({ children, requiredPermission }) => {
return <Navigate to="/404" replace />;
}

// Check if the user's company is the vendor for the associated At
if (requireVendorForAt && !isAdmin) {
const isVendorForAt = company && company.ats.some(at => at.id === atId);
if (!isVendorForAt) {
return <Navigate to="/404" replace />;
}
}

return children;
};

Expand All @@ -29,7 +39,8 @@ ConfirmAuth.propTypes = {
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
]).isRequired,
requiredPermission: PropTypes.string
requiredPermission: PropTypes.string,
requireVendorForAt: PropTypes.bool
};

export default ConfirmAuth;
1 change: 0 additions & 1 deletion client/components/DisclaimerInfo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const DisclaimerInfo = ({ phase }) => {
<Container>
<details>
<summary
id="disclaimer-title"
aria-expanded={expanded}
aria-controls="description"
onClick={() => setExpanded(!expanded)}
Expand Down
3 changes: 3 additions & 0 deletions client/components/ManageBotRunDialog/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export const RETRY_CANCELED_COLLECTIONS = gql`
retryCanceledCollections {
id
status
testStatus {
status
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions client/components/common/fragments/Me.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const ME_FIELDS = gql`
id
username
roles
company {
id
ats {
id
}
}
}
`;

Expand Down
15 changes: 14 additions & 1 deletion client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,20 @@ window.signMeInAsTester = username => {
};

window.signMeInAsVendor = username => {
return signMeInCommon({ username, roles: [{ name: 'VENDOR' }] });
return signMeInCommon({
username,
roles: [{ name: 'VENDOR' }],
company: {
id: '1',
name: 'vispero',
ats: [
{
id: '1',
name: 'JAWS'
}
]
}
});
};

window.startTestTransaction = async () => {
Expand Down
2 changes: 1 addition & 1 deletion client/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default () => (
exact
path="/candidate-test-plan/:testPlanVersionId/:atId"
element={
<ConfirmAuth requiredPermission="VENDOR">
<ConfirmAuth requiredPermission="VENDOR" requireVendorForAt={true}>
<CandidateTestPlanRun />
</ConfirmAuth>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ export default testQueuePageQuery => [
__typename: 'User',
id: '1',
username: 'foo-bar',
roles: ['ADMIN', 'TESTER']
roles: ['ADMIN', 'TESTER'],
company: {
id: '1',
name: 'Company',
ats: []
}
},
users: [
{
Expand All @@ -18,23 +23,38 @@ export default testQueuePageQuery => [
username: 'foo-bar',
roles: ['ADMIN', 'TESTER'],
isBot: false,
ats: []
ats: [],
company: {
id: '1',
name: 'Company',
ats: []
}
},
{
__typename: 'User',
id: '4',
username: 'bar-foo',
roles: ['TESTER'],
isBot: false,
ats: []
ats: [],
company: {
id: '1',
name: 'Company',
ats: []
}
},
{
__typename: 'User',
id: '5',
username: 'boo-far',
roles: ['TESTER'],
isBot: false,
ats: []
ats: [],
company: {
id: '1',
name: 'Company',
ats: []
}
}
],
ats: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ export default testQueuePageQuery => [
__typename: 'User',
id: '4',
username: 'bar-foo',
roles: ['TESTER']
roles: ['TESTER'],
company: {
id: '1',
name: 'Company',
ats: []
}
},
users: [
{
Expand All @@ -18,23 +23,38 @@ export default testQueuePageQuery => [
username: 'foo-bar',
roles: ['ADMIN', 'TESTER'],
isBot: false,
ats: []
ats: [],
company: {
id: '1',
name: 'Company',
ats: []
}
},
{
__typename: 'User',
id: '4',
username: 'bar-foo',
roles: ['TESTER'],
isBot: false,
ats: []
ats: [],
company: {
id: '1',
name: 'Company',
ats: []
}
},
{
__typename: 'User',
id: '5',
username: 'boo-far',
roles: ['TESTER'],
isBot: false,
ats: []
ats: [],
company: {
id: '1',
name: 'Company',
ats: []
}
}
],
ats: [],
Expand Down
Loading

0 comments on commit 90914bc

Please sign in to comment.