Skip to content

Commit f476907

Browse files
committed
course: fix button state logic
1 parent 53ad64f commit f476907

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

src/packages/frontend/course/assignments/assignment.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,10 @@ export function Assignment({
457457
) {
458458
type = "primary";
459459
} else {
460-
type = "dashed";
460+
type = "default";
461461
}
462462
if (status.assignment > 0 && status.not_assignment === 0) {
463-
type = "default";
463+
type = "dashed";
464464
}
465465

466466
return [
@@ -831,12 +831,12 @@ export function Assignment({
831831
if (status.collect > 0) {
832832
// Have already collected something
833833
if (status.not_collect === 0) {
834-
type = "primary";
835-
} else {
836834
type = "dashed";
835+
} else {
836+
type = "default";
837837
}
838838
} else {
839-
type = "default";
839+
type = "primary";
840840
}
841841
return [
842842
<Button
@@ -898,13 +898,12 @@ export function Assignment({
898898
if (status.peer_assignment > 0) {
899899
// haven't peer-assigned anything yet
900900
if (status.not_peer_assignment === 0) {
901-
type = "primary";
901+
type = "dashed";
902902
} else {
903903
type = "default";
904904
}
905905
} else {
906-
// we have assigned already and this may overwrite
907-
type = "dashed";
906+
type = "primary";
908907
}
909908
return [
910909
<Button
@@ -962,13 +961,13 @@ export function Assignment({
962961
if (status.peer_collect > 0) {
963962
// haven't peer-collected anything yet
964963
if (status.not_peer_collect === 0) {
965-
type = "primary";
964+
type = "dashed";
966965
} else {
967966
type = "default";
968967
}
969968
} else {
970969
// warning, since we have already collected and this may overwrite
971-
type = "dashed";
970+
type = "primary";
972971
}
973972
return [
974973
<Button
@@ -1065,12 +1064,12 @@ export function Assignment({
10651064
if (status.return_graded > 0) {
10661065
// Have already returned some
10671066
if (status.not_return_graded === 0) {
1068-
type = "primary";
1069-
} else {
10701067
type = "dashed";
1068+
} else {
1069+
type = "default";
10711070
}
10721071
} else {
1073-
type = "default";
1072+
type = "primary";
10741073
}
10751074
return [
10761075
<Button

src/packages/frontend/course/handouts/handout.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,21 @@ export function Handout({
383383

384384
function render_handout_button(status) {
385385
const handout_count = status.handout;
386+
const { not_handout } = status;
387+
let type;
388+
if (handout_count === 0) {
389+
type = "primary";
390+
} else {
391+
if (not_handout === 0) {
392+
type = "dashed";
393+
} else {
394+
type = "default";
395+
}
396+
}
386397
return (
387398
<Button
388399
key="handout"
389-
type={handout_count === 0 ? "primary" : undefined}
400+
type={type}
390401
onClick={() => {
391402
set_copy_confirm_handout(true);
392403
set_copy_confirm(true);

src/packages/frontend/course/handouts/handouts-info-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function StudentHandoutInfo({
6969
return <Space>{v}</Space>;
7070
} else {
7171
return (
72-
<Button key="copy" onClick={() => setRecopy(true)}>
72+
<Button type="dashed" key="copy" onClick={() => setRecopy(true)}>
7373
<Tip title={name} tip={<span>{copy_tip}</span>}>
7474
<Icon name="share-square" /> {name}...
7575
</Tip>

0 commit comments

Comments
 (0)