Skip to content

Commit

Permalink
fix publishing a moduleless course without manage permission
Browse files Browse the repository at this point in the history
was trying to open a dialog to force a change on the home
page type but if they don't have the rights for that we
should just publish it

test plan:
* have an account admin in a custom role
 with "Change course state" permission
 but not "Manage courses"
* they should be able to publish a new course
 that doesn't have a module

closes #CNVS-38759

Change-Id: I5817dcd36d5a559ac67aa63a0477c5de73b7c829
Reviewed-on: https://gerrit.instructure.com/123650
Tested-by: Jenkins
Reviewed-by: Jon Willesen <[email protected]>
QA-Review: Deepeeca Soundarrajan <[email protected]>
Product-Review: James Williams  <[email protected]>
  • Loading branch information
maneframe committed Aug 23, 2017
1 parent 91cc648 commit 454bd8f
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions app/jsx/courses/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,35 @@ $('#course_status_form').submit((e) => {
e.preventDefault()

const defaultView = defaultViewStore.getState().savedDefaultView
axios.get(`/api/v1/courses/${ENV.COURSE.id}/modules`)
.then(({data: modules}) => {
if (defaultView === 'modules' && modules.length === 0) {
ReactDOM.render(
<HomePagePromptContainer
forceOpen
store={defaultViewStore}
courseId={ENV.COURSE.id}
wikiFrontPageTitle={ENV.COURSE.front_page_title}
wikiUrl={ENV.COURSE.pages_url}
returnFocusTo={$(".btn-publish").get(0)}
onSubmit={() => {
if (defaultViewStore.getState().savedDefaultView !== 'modules') {
publishCourse()
}
}}
/>,
document.getElementById('choose_home_page_not_modules')
)
} else {
publishCourse()
}
})
const container = document.getElementById('choose_home_page_not_modules');
if (!!container) {
axios.get(`/api/v1/courses/${ENV.COURSE.id}/modules`)
.then(({data: modules}) => {
if (defaultView === 'modules' && modules.length === 0) {
ReactDOM.render(
<HomePagePromptContainer
forceOpen
store={defaultViewStore}
courseId={ENV.COURSE.id}
wikiFrontPageTitle={ENV.COURSE.front_page_title}
wikiUrl={ENV.COURSE.pages_url}
returnFocusTo={$(".btn-publish").get(0)}
onSubmit={() => {
if (defaultViewStore.getState().savedDefaultView !== 'modules') {
publishCourse()
}
}}
/>,
container
)
} else {
publishCourse()
}
})
} else {
// we don't have the ability to change to change the course home page so just publish it
publishCourse()
}
}
})

Expand Down

0 comments on commit 454bd8f

Please sign in to comment.