Skip to content

Commit

Permalink
fix #3679 -- "courses should show "Loading..." while loading"
Browse files Browse the repository at this point in the history
  • Loading branch information
williamstein committed Mar 13, 2019
1 parent c1b887e commit b3f65c6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
32 changes: 30 additions & 2 deletions src/smc-webapp/course/main.tsx
Expand Up @@ -188,6 +188,7 @@ interface CourseReduxProps {
handouts: HandoutsMap;
settings: CourseSettingsRecord;
unsaved: boolean;
loading: boolean;

user_map: UserMap;

Expand All @@ -201,6 +202,7 @@ export const CourseEditor = rclass<CourseReactProps>(
static reduxProps = ({ name }) => {
return {
[name]: {
loading: rtypes.bool,
error: rtypes.string,
tab: rtypes.string,
activity: rtypes.immutable.Map, // status messages about current activity happening (e.g., things being assigned)
Expand Down Expand Up @@ -353,8 +355,20 @@ export const CourseEditor = rclass<CourseReactProps>(
);
}

render_loading() {
if (!this.props.loading) {
return;
}
return (
<div style={{ textAlign: "center" }}>
<Loading theme={"medium"} />
</div>
);
}

render_students() {
if (
!this.props.loading &&
this.props.redux != null &&
this.props.students != null &&
this.props.user_map != null &&
Expand All @@ -378,6 +392,7 @@ export const CourseEditor = rclass<CourseReactProps>(

render_assignments() {
if (
!this.props.loading &&
this.props.redux != null &&
this.props.assignments != null &&
this.props.user_map != null &&
Expand All @@ -401,6 +416,7 @@ export const CourseEditor = rclass<CourseReactProps>(

render_handouts() {
if (
!this.props.loading &&
this.props.redux != null &&
this.props.assignments != null &&
this.props.user_map != null &&
Expand All @@ -426,7 +442,11 @@ export const CourseEditor = rclass<CourseReactProps>(
}

render_configuration() {
if (this.props.redux != null && this.props.settings != null) {
if (
!this.props.loading &&
this.props.redux != null &&
this.props.settings != null
) {
return (
<ConfigurationPanel
redux={this.props.redux}
Expand All @@ -448,7 +468,11 @@ export const CourseEditor = rclass<CourseReactProps>(
}

render_shared_project() {
if (this.props.redux != null && this.props.settings != null) {
if (
!this.props.loading &&
this.props.redux != null &&
this.props.settings != null
) {
return (
<SharedProjectPanel
redux={this.props.redux}
Expand All @@ -466,6 +490,9 @@ export const CourseEditor = rclass<CourseReactProps>(
}

render_tabs() {
if (this.props.loading) {
return;
}
return (
<Tabs
id={"course-tabs"}
Expand Down Expand Up @@ -524,6 +551,7 @@ export const CourseEditor = rclass<CourseReactProps>(
{this.render_files_button()}
{this.render_save_timetravel()}
{this.render_tabs()}
{this.render_loading()}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/smc-webapp/course/store.ts
Expand Up @@ -133,6 +133,7 @@ export interface CourseState {
expanded_skip_gradings: Set<string>;
active_feedback_edits: IsGradingMap;
handouts: HandoutsMap;
loading: boolean; // initially loading the syncdoc from disk.
saving: boolean;
settings: CourseSettingsRecord;
show_save_button: boolean;
Expand Down
4 changes: 3 additions & 1 deletion src/smc-webapp/course/sync.ts
Expand Up @@ -36,6 +36,7 @@ export let create_sync_db = (redux, actions, store, filename) => {

const project_id = store.get("course_project_id");
const path = store.get("course_filename");
actions.setState({loading:true});

const syncdb = webapp_client.sync_db2({
project_id,
Expand Down Expand Up @@ -63,7 +64,8 @@ export let create_sync_db = (redux, actions, store, filename) => {
},
assignments: {},
students: {},
handouts: {}
handouts: {},
loading : false
};
for (let x of syncdb.get().toJS()) {
if (x.table === "settings") {
Expand Down

0 comments on commit b3f65c6

Please sign in to comment.