Skip to content

Commit f0c80fa

Browse files
authored
Refactor and fix group filter (#3116)
1 parent c63c423 commit f0c80fa

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/pages/academy/grading/Grading.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import GradingSubmissionsTable from './subcomponents/GradingSubmissionsTable';
2525
import GradingWorkspace from './subcomponents/GradingWorkspace';
2626

2727
const groupOptions = [
28-
{ value: false, label: 'my groups' },
29-
{ value: true, label: 'all groups' }
28+
{ value: true, label: 'my groups' },
29+
{ value: false, label: 'all groups' }
3030
];
3131

3232
const showOptions = [
@@ -46,7 +46,7 @@ const Grading: React.FC = () => {
4646
const params = useParams<{ submissionId: string; questionId: string }>();
4747

4848
const isAdmin = role === Role.Admin;
49-
const [showAllGroups, setShowAllGroups] = useState(isAdmin || group === null);
49+
const [showUserGroups, setShowUserGroups] = useState(!isAdmin && group !== null);
5050

5151
const [pageSize, setPageSize] = useState(10);
5252
const [showAllSubmissions, setShowAllSubmissions] = useState(false);
@@ -71,23 +71,23 @@ const Grading: React.FC = () => {
7171
dispatch(WorkspaceActions.increaseRequestCounter());
7272
dispatch(
7373
SessionActions.fetchGradingOverviews(
74-
!showAllGroups,
74+
showUserGroups,
7575
unpublishedToBackendParams(showAllSubmissions),
7676
paginationToBackendParams(page, pageSize),
7777
filterParams,
7878
allColsSortStates
7979
)
8080
);
8181
},
82-
[dispatch, showAllGroups, showAllSubmissions, pageSize, allColsSortStates]
82+
[dispatch, showUserGroups, showAllSubmissions, pageSize, allColsSortStates]
8383
);
8484

8585
useEffect(() => {
8686
if (refreshQueried) {
8787
dispatch(WorkspaceActions.increaseRequestCounter());
8888
dispatch(
8989
SessionActions.fetchGradingOverviews(
90-
showAllGroups,
90+
showUserGroups,
9191
unpublishedToBackendParams(showAllSubmissions),
9292
paginationToBackendParams(refreshQueryData.page, pageSize),
9393
refreshQueryData.filterParams,
@@ -98,7 +98,7 @@ const Grading: React.FC = () => {
9898
}
9999
}, [
100100
dispatch,
101-
showAllGroups,
101+
showUserGroups,
102102
showAllSubmissions,
103103
pageSize,
104104
allColsSortStates,
@@ -152,7 +152,7 @@ const Grading: React.FC = () => {
152152
<ContentDisplay
153153
loadContentDispatch={() => {
154154
if (!hasLoadedBefore) {
155-
dispatch(SessionActions.fetchGradingOverviews(showAllGroups));
155+
dispatch(SessionActions.fetchGradingOverviews(showUserGroups));
156156
}
157157
}}
158158
display={
@@ -196,8 +196,8 @@ const Grading: React.FC = () => {
196196
<GradingText>submissions from</GradingText>
197197
<SimpleDropdown
198198
options={groupOptions}
199-
selectedValue={showAllGroups}
200-
onClick={setShowAllGroups}
199+
selectedValue={showUserGroups}
200+
onClick={setShowUserGroups}
201201
popoverProps={{ position: Position.BOTTOM }}
202202
buttonProps={{ minimal: true, rightIcon: 'caret-down' }}
203203
/>

0 commit comments

Comments
 (0)