Last active
December 20, 2016 19:43
-
-
Save jfeldstein/8646648cd05935762fd707b4325b1e23 to your computer and use it in GitHub Desktop.
My suggestion for settings state.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getState() => ({ | |
// For | |
// - https://cl.ly/0G2G0N2U2f1V | |
// - and all of https://cl.ly/0b2O04192j2R | |
studentsInClassSettings: { | |
selectedClassId: "...", | |
// Get students to show using this classId, from | |
// getState().students.itemsById | |
currentSubScreenId: *_SCREEN_ID, | |
// Screens include: | |
// - MANAGE_STUDENTS_SCREEN_ID https://cl.ly/111a0h1l203O | |
// - IMPORT_STUDENTS_FROM_CLASS_CHOOSE_CLASS_SCREEN_ID https://cl.ly/3g2M2K2C2x1B | |
// - IMPORT_STUDENTS_FROM_CLASS_CHOOSE_STUDENTS_SCREEN_ID https://cl.ly/1A1E1e2Y1L3L | |
// - IMPORT_STUDENTS_FROM_CHOOSE_WHERE_SCREEN_ID https://cl.ly/3S182Q1m2w3R | |
// - IMPORT_STUDENTS_FROM_CLASS_CODE_SCREEN_ID https://cl.ly/2I1W3p0t0V2m | |
// - IMPORT_STUDENTS_FROM_GOOGLE_GROUP_SCREEN_ID https://cl.ly/2o3m433Z1x0d | |
// - IMPORT_STUDENTS_FROM_MANUAL_SCREEN_ID https://cl.ly/3U3i1Z053i1D | |
// - IMPORT_STUDENTS_FROM_PASTE_ROSTER_SCREEN_ID https://cl.ly/0M3E14192m2c | |
// - STUDENT_MODAL_FORM_SCREEN_ID https://cl.ly/3x1W3h2m010w | |
importFromClassId: "...", | |
// When copying from a class, students are being copied from | |
// importFromClassId into selectedClassId | |
selectedStudentIds: ["...", ...], | |
// Which students are selected? Relevant to MANAGE_STUDENTS_SCREEN_ID | |
// and IMPORT_STUDENTS_FROM_CLASS_CHOOSE_STUDENTS_SCREEN_ID | |
expanded: { | |
googleContactGroupIds: ["...", ...], | |
// IDs of google groups that are expanded in | |
// IMPORT_STUDENTS_FROM_GOOGLE_GROUP_SCREEN_ID | |
mergeConfirmationMenu: bool, | |
// When students are selected on MANAGE_STUDENTS_SCREEN_ID, is | |
// https://cl.ly/1R1O1V0G4533 shown? | |
moveToClassMenu: bool, | |
// Same as above, but for https://cl.ly/1B1O3N221g1Q | |
contextMenuOnStudentId: "...", | |
// On which student are we showing this menu: | |
// https://cl.ly/3o0z0u3y1G38 | |
}, | |
tempData: { | |
customClassCode: "...", | |
// If user chooses to customize code, https://cl.ly/3a2D1f0a1N1J | |
// becomes an <EditableInlineTitle /> and this is the current | |
// value. | |
student: { | |
[id: "...",] | |
// If ID is set, use this space to hold unsaved edits the user has | |
// made to an existing student on STUDENT_MODAL_FORM_SCREEN_ID. If | |
// there is no ID, the user is adding a new student (we don't | |
// currently do that via this modal, but we could and this is how | |
// state would manage it). | |
// | |
name: "...", | |
... | |
}, | |
manualStudents: [{ | |
name: "...", | |
email: "...", | |
}], | |
// List of students on IMPORT_STUDENTS_FROM_MANUAL_SCREEN_ID | |
} | |
}, | |
accountSettings: { | |
isSchoolEditable: bool, | |
tempData: { | |
[name: "...",] | |
[avatarUrl: "...",] | |
// tempData contains any values which have been entered but not | |
// yet saved. eg, If the user uploads a new image the URL should | |
// be set in tempData.avatarUrl which takes precedence and gets | |
// shown. | |
}, | |
} | |
collaborationSettings: { | |
selectedClassId: "..." / null, | |
// Class ID to which the collaborators shown should be filtered when | |
// showing https://cl.ly/0I011w2k1p3W -- If null, show all all | |
// collaborators eg in Account Settings. Only show the "Add New" | |
// collaborator row if this is set. | |
// | |
// Collaborators themselves are in getState().collaborators.itemsById | |
tempData: { | |
collaborator: { | |
email: "...", | |
permission: *_PERMISSION_ID, | |
// Values include: | |
// - CAN_VIEW_PERMISSION_ID | |
// - CAN_EDIT_PERMISSION_ID | |
}, | |
// This is the collaborator being added via https://cl.ly/0I011w2k1p3W | |
}, | |
}, | |
rubricSettings: { | |
selectedClassId: "...", | |
// Only show rubrics attached to this class. Rubrics themselves are | |
// stored all together in getState().rubrics.itemsById | |
currentModalScreenId: *_SCREEN_ID, | |
// Which of these is shown? https://cl.ly/1y3N1T1r0T31 | |
// Values include: | |
// - MANAGE_RUBRICS_IN_CLASS_CUSTOM_SCREEN_ID | |
// - MANAGE_RUBRICS_IN_CLASS_PRESET_SCREEN_ID | |
selectedRubricIds: ["...", ...], | |
// Which rubrics are selected in either | |
// MANAGE_RUBRICS_IN_CLASS_PRESET_SCREEN_ID or | |
// MANAGE_RUBRICS_IN_CLASS_CUSTOM_SCREEN_ID | |
isEditingEnabled: bool, | |
// When user clicks the pencil icon https://cl.ly/0e3J3n0V1z1W the | |
// modal changes to "edit mode", eg toggles become delete icons and | |
// names and point-descriptions become inline editable. | |
expanded: { | |
rubricIds: ["...", ...], | |
// Which rubrics are expanded on the main screen | |
rubricIdsInModal: ["...", ...], | |
// Which rubrics are expanded in either | |
// MANAGE_RUBRICS_IN_CLASS_PRESET_SCREEN_ID or | |
// MANAGE_RUBRICS_IN_CLASS_CUSTOM_SCREEN_ID | |
confirmDeleteMenuOnRubricId: "...", | |
// Which rubric has this menu attached: https://cl.ly/3W1B1E3y2i1M | |
confirmDeleteMenuOnPointId: "...", | |
// Same as above, but for when the menu is placed on the X next to | |
// a specific Rubric-Point: https://cl.ly/0i0Z1X2E1L3o | |
confirmCopyMenuOnRubricId: "...", | |
// When showing the confirm menu on a Preset rubric | |
// https://cl.ly/3j1D1T3C3q43 -- (I'm assuming we confirm this | |
// after the user clicks the icon) | |
}, | |
tempData: { | |
newRubric: { | |
id: "...", | |
name: "...", | |
points: [{ | |
id: "...", | |
description: "...", | |
}], | |
}, | |
// If the user has clicked Add Rubric, tempData.newRubric | |
rubricsBeingEdited: { | |
"...": { | |
id: "...", | |
name: "...", | |
points: [{ | |
id: "...", | |
description: "...", | |
}], | |
} | |
// Key here is the rubric's ID. | |
// When a rubric is being edited in the UI, add the | |
// modified data here. eg, if the name is changed, set it: | |
// "[id]": { | |
// name: "This is the changed name" | |
// points: [], | |
// } | |
// Once the user edits one of the points, add a point to | |
// the array with the updated description. | |
// "[rubricId]": { | |
// points: [{ | |
// id: "[pointId]", | |
// description: "This is the updated description." | |
// }] | |
// } | |
// And if a rubric or point is removed, add isRemoved: true to | |
// that object. We will look for these in the model and make | |
// the corresponding requests. | |
} | |
} | |
}, | |
gradingSettings: { | |
selectedClassId: "...", | |
// Pull the current settings from state.user.classes using this ID. | |
currentSubScreenId: *_SCREEN_ID, | |
// Values include: | |
// - EDIT_GRADE_REPORTING_SCREEN_ID https://cl.ly/0E1O1A3l3L1H | |
// - EDIT_ASSIGNMENT_TYPE_SCREEN_ID https://cl.ly/1X1G1v0D0r3d | |
// | |
// If set to either of these, show the corresponding modal over | |
// the main screen. | |
tempData: { | |
assignmentType: { | |
[id: "...",] | |
// If no ID specified, we're adding a new/custom assignment | |
// type. Otherwise use this space to hold changes to an | |
// existing rubric the user has not yet saved. | |
name: "...", | |
iconUrl: "...", | |
isCustom: bool, | |
}, | |
reportingMethod: *_REPORTING_METHOD_ID, | |
// Values include: | |
// - MASTERY_REPORTING_METHOD_ID | |
// - LETTER_GRADE_REPORTING_METHOD_ID | |
// - PERCENT_REPORTING_METHOD_ID | |
// - GPA_REPORTING_METHOD_ID | |
// | |
// Only show the "Levels" and "Sliders" when user has chosen | |
// MASTERY or LETTER GRADE. | |
gradeLevels: { | |
"0": { | |
name: "...", | |
min: 0, | |
max: 0.5, | |
}, | |
... | |
// If set, tempData.gradeLevels overrides the names and ranges | |
// for grade levels in the currently selected class. These are | |
// the unsaved values the user is currently editing. | |
}, | |
}, | |
}, | |
notificationSettings: { | |
isDigestEnabled: bool, | |
isFeedbackEnabled: bool, | |
isNewFeatureEnabled: bool, | |
isNewsletterEnabled: bool, | |
isJoinClassEnabled: bool, | |
isReadyToGradeEnabled: bool, | |
// No need for temp data for these. The toggles will show whatever is | |
// in state.notificationSettings, and when the toggles are changed we | |
// will PUT that value back to the server. | |
// | |
// This data should not exist in state.user.* because it's fetched via | |
// a new restful API and added directly to state.notificationSettings. | |
}, | |
connectionSettings: { | |
expandedIntegrations: [*_CONTENT_SOURCE_ID, ...], | |
// Values include: | |
// - KHAN_CONTENT_SOURCE_ID, | |
// - CK12_CONTENT_SOURCE_ID, | |
// | |
// Look in getState().user.connectedIntegrations for which the user | |
// actually is using. | |
}, | |
classSettings: { | |
selectedClassId: "...", | |
isClassStandardsExpanded: bool, | |
tempData: { | |
name: "...", | |
grades: ["...", ...], | |
subjects: ["...", ...], | |
isCommentsEnabled: bool, | |
isStudentsSeeFeedEnabled: bool, | |
}, | |
}, | |
globalSettings: { | |
selectedClassId: "..." / null (Account Settings), | |
// This value is the selected left-side nav item. If set, show | |
// settings for the corresponding class. If null, show | |
// AccountSettings. | |
// | |
// We don't need a state value for the top nav bar, because we can use | |
// http://makotot.github.io/react-scrollspy/ and regular links. | |
}, | |
collaborators: { | |
itemsById: { | |
"...": { | |
id: "...", | |
name: "...", | |
email: "...", | |
avatarUrl: "...", | |
pendingByClassId: { | |
"...": true, | |
// Has the collaborator accepted the invite to classId="..."? | |
}, | |
permissionByClassId: { | |
"...": *_PERMISSION_ID, | |
// What level of authority does this collaborator have in | |
// classId="..."? | |
// | |
// Values include: | |
// - CAN_VIEW_PERMISSION_ID | |
// - CAN_EDIT_PERMISSION_ID | |
}, | |
} | |
}, | |
// Fetch collaborators for the current user, and put the data here as | |
// it returns. | |
permissionsByClassId: { | |
"class_id": { | |
"collab_id": *_PERMISSION_ID, | |
}, | |
}, | |
isPendingByClassId: { | |
"class_id": { | |
"collab_id": true, | |
}, | |
} | |
// Collaborators should come from server as a flat array with props | |
// pendingByClassId and permissionByClassId. Fold this data into | |
// getState().collaborators.permissionsByClassId and | |
// .isPendingByClassId, as well. That way, if we have a collaborator | |
// object, we know which classes to show, and if we have a class ID, | |
// we know which collaborators to show. | |
}, | |
students: { | |
itemsById: { | |
"...": { | |
id: "...", | |
name: "...", | |
avatarUrl: "...", | |
email: "...", | |
isEnrolledByClassId: { | |
"...": true, | |
}, | |
isPendingByClassId: { | |
"...": true, | |
}, | |
} | |
}, | |
itemIdsByClassId: {}, | |
validityByClassId: {}, | |
isFetchingByClassId: {}, | |
// Refactor students to use the getState().students.*by*ID format, like | |
// standards, standardGroups, etc | |
}, | |
user: { | |
connectedIntegrations: [*_CONTENT_SOURCE_ID, ...], | |
// Right now, this is provided by UserModel.getCurrentUser() as a | |
// hack. That method looks into the data in sessionStorage.user and | |
// if there is a ck12_userid it includes the CK12_CONTENT_SOURCE_ID | |
// value here. Khan never shows up, I don't know how to find out if | |
// the user has one of those. | |
}, | |
rubrics: { | |
itemsById: {}, | |
itemIdsByClassId: {}, | |
validityByClassId: {}, | |
isFetchingByClassId: {}, | |
// Refactor rubrics to use the getState().rubrics.*by*ID format, like | |
// standards, standardGroups, etc | |
}, | |
googleGroups: { | |
itemsById: {}, | |
itemIdsByGoogleEmail: {}, | |
validityByGoogleEmail: {}, | |
isFetchingByGoogleEmail: {}, | |
// Refactor to use the getState().googleGroups.*by*ID format, like | |
// standards, standardGroups, etc. | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment