Skip to content

Commit 73328fa

Browse files
pwjablonskioutoftime
authored andcommitted
Saving assignment indicator (#1681)
* update package lock * delete package lock * addresses #1680 * update creating indicator button * add fragment
1 parent 27653d1 commit 73328fa

File tree

8 files changed

+83
-31
lines changed

8 files changed

+83
-31
lines changed

locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"date-not-valid": "Please enter a valid date",
1010
"past-date-not-valid": "Please pick a future date",
1111
"input-placeholder": "When is it due?",
12-
"value-label": "{{valueLabel, formatDate}}"
12+
"value-label": "{{valueLabel, formatDate}}",
13+
"creating": "Creating..."
1314
},
1415
"top-bar": {
1516
"create-snapshot": "Create Snapshot",

src/components/AssignmentCreator.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const AssignmentCreatorForm = lazy(
1717
export default function AssignmentCreator({
1818
areCoursesLoaded,
1919
courses,
20+
isAssignmentExportInProgress,
2021
isOpen,
2122
parsedDate,
2223
projectTitle,
@@ -42,6 +43,7 @@ export default function AssignmentCreator({
4243
areCoursesLoaded ?
4344
<AssignmentCreatorForm
4445
courses={courses}
46+
isAssignmentExportInProgress={isAssignmentExportInProgress}
4547
parsedDate={parsedDate}
4648
onAssignAssignment={onAssignAssignment}
4749
onCloseAssignmentCreator={onCloseAssignmentCreator}
@@ -58,6 +60,7 @@ export default function AssignmentCreator({
5860
AssignmentCreator.propTypes = {
5961
areCoursesLoaded: PropTypes.bool.isRequired,
6062
courses: ImmutablePropTypes.iterable.isRequired,
63+
isAssignmentExportInProgress: PropTypes.bool.isRequired,
6164
isOpen: PropTypes.bool.isRequired,
6265
parsedDate: PropTypes.instanceOf(Date),
6366
projectTitle: PropTypes.string,

src/components/AssignmentCreatorForm.jsx

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function formatDate(value) {
3333
export default function AssignmentCreatorForm({
3434
courses,
3535
handleSubmit,
36+
isAssignmentExportInProgress,
3637
parsedDate,
3738
onAssignAssignment,
3839
onDraftAssignment,
@@ -69,43 +70,61 @@ export default function AssignmentCreatorForm({
6970
valueLabel={parsedDate}
7071
/>
7172
</div>
72-
<button
73-
className={classnames(
74-
'assignment-creator__button',
75-
'assignment-creator__button_reject',
76-
)}
77-
type="button"
78-
onClick={onCloseAssignmentCreator}
79-
>
80-
{t('assignment-creator.cancel-button')}
81-
</button>
82-
<button
83-
className={classnames(
84-
'assignment-creator__button',
85-
'assignment-creator__button_confirm',
86-
)}
87-
type="button"
88-
onClick={handleSubmit(onDraftAssignment)}
89-
>
90-
{t('assignment-creator.draft-button')}
91-
</button>
92-
<button
93-
className={classnames(
94-
'assignment-creator__button',
95-
'assignment-creator__button_confirm',
96-
)}
97-
type="button"
98-
onClick={handleSubmit(onAssignAssignment)}
99-
>
100-
{t('assignment-creator.assign-button')}
101-
</button>
73+
<div>
74+
{
75+
isAssignmentExportInProgress ?
76+
<button
77+
disabled
78+
className={classnames(
79+
'assignment-creator__button',
80+
'assignment-creator__button_disabled',
81+
)}
82+
type="button"
83+
>
84+
{t('assignment-creator.creating')}
85+
</button> :
86+
<>
87+
<button
88+
className={classnames(
89+
'assignment-creator__button',
90+
'assignment-creator__button_reject',
91+
)}
92+
type="button"
93+
onClick={onCloseAssignmentCreator}
94+
>
95+
{t('assignment-creator.cancel-button')}
96+
</button>
97+
<button
98+
className={classnames(
99+
'assignment-creator__button',
100+
'assignment-creator__button_confirm',
101+
)}
102+
type="button"
103+
onClick={handleSubmit(onDraftAssignment)}
104+
>
105+
{t('assignment-creator.draft-button')}
106+
</button>
107+
<button
108+
className={classnames(
109+
'assignment-creator__button',
110+
'assignment-creator__button_confirm',
111+
)}
112+
type="button"
113+
onClick={handleSubmit(onAssignAssignment)}
114+
>
115+
{t('assignment-creator.assign-button')}
116+
</button>
117+
</>
118+
}
119+
</div>
102120
</form>
103121
);
104122
}
105123

106124
AssignmentCreatorForm.propTypes = {
107125
courses: ImmutablePropTypes.iterable.isRequired,
108126
handleSubmit: PropTypes.func.isRequired,
127+
isAssignmentExportInProgress: PropTypes.bool.isRequired,
109128
parsedDate: PropTypes.instanceOf(Date),
110129
onAssignAssignment: PropTypes.func.isRequired,
111130
onCloseAssignmentCreator: PropTypes.func.isRequired,

src/containers/AssignmentCreator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import {
1010
getCourses,
1111
isAssignmentCreatorOpen,
12+
isAssignmentExportInProgress,
1213
getCurrentProjectPreview,
1314
getParsedDate,
1415
makeIsRemoteCollectionFullyLoaded,
@@ -23,6 +24,7 @@ function mapStateToProps(state) {
2324
return {
2425
courses: getCourses(state),
2526
areCoursesLoaded: areCoursesLoaded(state),
27+
isAssignmentExportInProgress: isAssignmentExportInProgress(state),
2628
isOpen: isAssignmentCreatorOpen(state),
2729
projectTitle: getCurrentProjectPreview(state),
2830
parsedDate: getParsedDate(state),

src/css/application.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,11 @@ body {
930930
margin: 1em;
931931
}
932932

933+
.assignment-creator__button_disabled {
934+
background-color: var(--color-gray);
935+
color: var(--color-chrome);
936+
}
937+
933938
.assignment-creator__button_confirm {
934939
background-color: var(--color-dark-green);
935940
color: var(--color-low-contrast-gray);

src/reducers/clients.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Immutable from 'immutable';
33
const defaultState = new Immutable.Map({
44
firebase: new Immutable.Map({exportingSnapshot: false}),
55
projectExports: new Immutable.Map(),
6+
exportingAssignment: false,
67
gapi: new Immutable.Map({ready: false}),
78
});
89

@@ -42,6 +43,19 @@ export default function clients(stateIn, action) {
4243

4344
case 'GAPI_CLIENT_READY':
4445
return state.setIn(['gapi', 'ready'], true);
46+
47+
case 'CREATE_ASSIGNMENT':
48+
return state.setIn(
49+
['exportingAssignment'],
50+
true,
51+
);
52+
53+
case 'ASSIGNMENT_CREATED':
54+
case 'ASSIGNMENT_NOT_CREATED':
55+
return state.setIn(
56+
['exportingAssignment'],
57+
false,
58+
);
4559
}
4660

4761
return state;

src/selectors/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import getParsedDate from './getParsedDate';
2525
import getProject from './getProject';
2626
import getRequestedFocusedLine from './getRequestedFocusedLine';
2727
import isAssignmentCreatorOpen from './isAssignmentCreatorOpen';
28+
import isAssignmentExportInProgress from './isAssignmentExportInProgress';
2829
import isClassroomExportInProgress from './isClassroomExportInProgress';
2930
import isCurrentlyValidating from './isCurrentlyValidating';
3031
import isCurrentProjectSyntacticallyValid
@@ -75,6 +76,7 @@ export {
7576
getProject,
7677
getRequestedFocusedLine,
7778
isAssignmentCreatorOpen,
79+
isAssignmentExportInProgress,
7880
isClassroomExportInProgress,
7981
isCurrentlyValidating,
8082
isCurrentProjectSyntacticallyValid,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default function isAssignmentExportInProgress(state) {
2+
return state.getIn([
3+
'clients',
4+
'exportingAssignment',
5+
]);
6+
}

0 commit comments

Comments
 (0)