Skip to content

Commit

Permalink
set showSharingColumn rather than toggling it
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsbailey committed Feb 12, 2019
1 parent acb34e4 commit 4d2befb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/src/sites/studio/pages/teacher_dashboard/show.js
Expand Up @@ -8,7 +8,7 @@ import manageStudents, {
setLoginType,
setStudents,
convertStudentServerData,
toggleSharingColumn
setShowSharingColumn
} from '@cdo/apps/templates/manageStudents/manageStudentsRedux';
import teacherSections, {
setSections,
Expand Down Expand Up @@ -64,7 +64,7 @@ $(document).ready(function() {
if (
courseFamiliesToShowShareColumn.includes(section.script.course_family_name)
) {
store.dispatch(toggleSharingColumn());
store.dispatch(setShowSharingColumn(true));
}

$.ajax({
Expand Down
13 changes: 13 additions & 0 deletions apps/src/templates/manageStudents/manageStudentsRedux.js
Expand Up @@ -133,6 +133,7 @@ const ADD_STUDENT_SUCCESS = 'manageStudents/ADD_STUDENT_SUCCESS';
const ADD_STUDENT_FAILURE = 'manageStudents/ADD_STUDENT_FAILURE';
const ADD_MULTIPLE_ROWS = 'manageStudents/ADD_MULTIPLE_ROWS';
const TOGGLE_SHARING_COLUMN = 'manageStudents/TOGGLE_SHARING_COLUMN';
const SET_SHOW_SHARING_COLUMN = 'manageStudents/SET_SHOW_SHARING_COLUMN';
const EDIT_ALL = 'manageStudents/EDIT_ALL';
const UPDATE_ALL_SHARE_SETTING = 'manageStudents/UPDATE_ALL_SHARE_SETTING';
const SET_SHARING_DEFAULT = 'manageStudents/SET_SHARING_DEFAULT';
Expand Down Expand Up @@ -221,6 +222,11 @@ export const addMultipleRows = studentData => ({
});
export const toggleSharingColumn = () => ({type: TOGGLE_SHARING_COLUMN});

export const setShowSharingColumn = visible => ({
type: SET_SHOW_SHARING_COLUMN,
visible
});

export const handleShareSetting = disable => {
return (dispatch, getState) => {
dispatch(editAll());
Expand Down Expand Up @@ -653,6 +659,13 @@ export default function manageStudents(state = initialState, action) {
showSharingColumn: !state.showSharingColumn
};
}
if (action.type === SET_SHOW_SHARING_COLUMN) {
return {
...state,
showSharingColumn: !!action.visible
};
}

if (action.type === UPDATE_STUDENT_TRANSFER) {
return {
...state,
Expand Down
4 changes: 2 additions & 2 deletions apps/src/templates/teacherDashboard/sections.js
Expand Up @@ -10,7 +10,7 @@ import manageStudents, {
setLoginType,
setStudents,
convertStudentServerData,
toggleSharingColumn
setShowSharingColumn
} from '@cdo/apps/templates/manageStudents/manageStudentsRedux';
import sectionData, {setSection} from '@cdo/apps/redux/sectionDataRedux';
import textResponses, {
Expand Down Expand Up @@ -149,7 +149,7 @@ export function renderSectionTable(section, studioUrlPrefix) {
];

if (scriptsToShowShareSetting.includes(section.script.name)) {
store.dispatch(toggleSharingColumn());
store.dispatch(setShowSharingColumn(true));
}

const dataUrl = `/dashboardapi/sections/${section.id}/students`;
Expand Down
26 changes: 26 additions & 0 deletions apps/test/unit/templates/manageStudents/manageStudentsReduxTest.js
Expand Up @@ -18,6 +18,7 @@ import manageStudents, {
addMultipleRows,
RowType,
toggleSharingColumn,
setShowSharingColumn,
updateAllShareSetting,
setSharingDefault,
TransferStatus,
Expand Down Expand Up @@ -261,6 +262,31 @@ describe('manageStudentsRedux', () => {
});
});

describe('setShowSharingColumn', () => {
it('set showSharingColumn state', () => {
let action = setShowSharingColumn(true);
let nextState = manageStudents(initialState, action);
assert.deepEqual(nextState.showSharingColumn, true);

action = setShowSharingColumn(false);
nextState = manageStudents(initialState, action);
assert.deepEqual(nextState.showSharingColumn, false);

const state = {
...initialState,
showSharingColumn: true
};

action = setShowSharingColumn(true);
nextState = manageStudents(state, action);
assert.deepEqual(nextState.showSharingColumn, true);

action = setShowSharingColumn(false);
nextState = manageStudents(state, action);
assert.deepEqual(nextState.showSharingColumn, false);
});
});

describe('updateStudentTransfer', () => {
it('sets transferData from action', () => {
const transferData = {
Expand Down

0 comments on commit 4d2befb

Please sign in to comment.