add warning modal on course copy
added a warning modal on course copy process to advise the user the grading scheme should not be copy because is archived. fixes EVAL-3918 flag=archived_grading_schemes test plan: - Go to database and set for one of grading standards the workflow_state to archived - change a course to use this archived grading scheme setting the field grading_standard_id - go to this course copy UI - a modal with a warning should be displayed saying the grading standard should be not copy - Validate the modal can be closed and the copy process works without problems Change-Id: Ica85ff261776ef39b0743c08021addebad320201 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/339117 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Spencer Olson <solson@instructure.com> Product-Review: Ravi Koll <ravi.koll@instructure.com> Reviewed-by: Derek Williams <derek.williams@instructure.com> Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
This commit is contained in:
parent
56136448e6
commit
c4827e4144
|
@ -18,6 +18,9 @@
|
|||
|
||||
<% provide :page_title, t('titles.copy_course', 'Copy Course') %>
|
||||
<% add_crumb t('#crumbs.copy_course', 'Copy Course') %>
|
||||
<div id="warning_messages_modal_container"></div>
|
||||
<% js_bundle :copy_warnings_modal %>
|
||||
|
||||
|
||||
<h1><%= t'headings.copy_course', 'Copy %{course}', :course => @context.name %></h1>
|
||||
<p>
|
||||
|
|
|
@ -202,6 +202,7 @@ const featureBundles: {
|
|||
teacher_activity_report: () => import('./features/teacher_activity_report/index'),
|
||||
terms_index: () => import('./features/terms_index/index'),
|
||||
terms_of_service_modal: () => import('./features/terms_of_service_modal/index'),
|
||||
copy_warnings_modal: () => import('./features/copy_warnings_modal/index'),
|
||||
terms_of_use: () => import('./features/terms_of_use/index'),
|
||||
theme_editor: () => import('./features/theme_editor/index'),
|
||||
theme_preview: () => import('./features/theme_preview/index'),
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2017 - present Instructure, Inc.
|
||||
*
|
||||
* This file is part of Canvas.
|
||||
*
|
||||
* Canvas is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3 of the License.
|
||||
*
|
||||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import ready from '@instructure/ready'
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import CopyWarningsModal from './react/CopyWarningsModal'
|
||||
|
||||
ready(() => {
|
||||
const container = document.querySelector('#warning_messages_modal_container')
|
||||
if (container && ENV.EXPORT_WARNINGS && ENV.EXPORT_WARNINGS.length > 0) {
|
||||
ReactDOM.render(<CopyWarningsModal errorMessages={ENV.EXPORT_WARNINGS} />, container)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "@canvas-features/copy_warnings_modal",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"owner": "FOO"
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2024 - present Instructure, Inc.
|
||||
*
|
||||
* This file is part of Canvas.
|
||||
*
|
||||
* Canvas is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3 of the License.
|
||||
*
|
||||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import React, {useState} from 'react'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import Modal from '@canvas/instui-bindings/react/InstuiModal'
|
||||
import {Text} from '@instructure/ui-text'
|
||||
import {Flex} from '@instructure/ui-flex'
|
||||
|
||||
const I18n = useI18nScope('copy_warnings_modal')
|
||||
|
||||
interface CopyWarningsModalProps {
|
||||
errorMessages: string[]
|
||||
}
|
||||
|
||||
const CopyWarningsModal = ({errorMessages}: CopyWarningsModalProps) => {
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const handleCloseModal = () => {
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal size="auto" open={open} onDismiss={handleCloseModal} label={I18n.t('Attention')}>
|
||||
<Modal.Body>
|
||||
<Flex direction="column">
|
||||
{errorMessages.map(warning => (
|
||||
<Flex.Item>
|
||||
<strong>*</strong>
|
||||
<Text>{warning}</Text>
|
||||
</Flex.Item>
|
||||
))}
|
||||
</Flex>
|
||||
</Modal.Body>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default CopyWarningsModal
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (C) 2024 - present Instructure, Inc.
|
||||
*
|
||||
* This file is part of Canvas.
|
||||
*
|
||||
* Canvas is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3 of the License.
|
||||
*
|
||||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import React from 'react'
|
||||
import {render} from '@testing-library/react'
|
||||
import CopyWarningsModal from '../CopyWarningsModal'
|
||||
|
||||
function renderComponent(errorMessages: string[]) {
|
||||
return render(<CopyWarningsModal errorMessages={errorMessages} />)
|
||||
}
|
||||
|
||||
describe('CourseDefaultDueTime', () => {
|
||||
describe('can render with the warning message', () => {
|
||||
it('renders course default due time', () => {
|
||||
const {getByLabelText} = renderComponent(['This is a test warning message'])
|
||||
expect(getByLabelText('This is a test warning message')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
})
|
|
@ -32,4 +32,5 @@ export interface EnvContentMigrations {
|
|||
NEW_QUIZZES_MIGRATION?: boolean
|
||||
QUIZZES_NEXT_ENABLED?: boolean
|
||||
NEW_QUIZZES_MIGRATION_DEFAULT?: boolean
|
||||
EXPORT_WARNINGS?: string[]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue