Fix TS errors in select_content_dialog

Adds ENV types for context modules

Refs CFA-11
flag=none

QA Risk Low:
- This shouldn't change any emitted javascript at all.

Test plan:
- automated tests pass

Change-Id: Ief8e1a9f845648f861f61d4e3557260f6a272714
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/318026
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Omar Soto-Fortuño <omar.soto@instructure.com>
Reviewed-by: Chawn Neal <chawn.neal@instructure.com>
QA-Review: Chawn Neal <chawn.neal@instructure.com>
Product-Review: Chawn Neal <chawn.neal@instructure.com>
This commit is contained in:
Yona Appletree 2023-05-11 14:42:33 -07:00
parent 8794f1ce1d
commit 224b3cfa8c
4 changed files with 72 additions and 2 deletions

View File

@ -21,7 +21,8 @@
*
* From assignments_controller.rb
*/
export type EnvAssignments = Partial<EnvAssignmentsA2StudentView>
export type EnvAssignments = Partial<EnvAssignmentsA2StudentView> &
Partial<EnvAssignmentsDefaultToolInfo>
/**
* A2-related ENV variables.
@ -57,3 +58,13 @@ export interface EnvAssignmentsA2StudentView {
PREREQS: any
SUBMISSION_ID: string | number
}
/**
* From From AssignmentsController#set_default_tool_env!
*/
export interface EnvAssignmentsDefaultToolInfo {
DEFAULT_ASSIGNMENT_TOOL_URL?: string
DEFAULT_ASSIGNMENT_TOOL_NAME?: string
DEFAULT_ASSIGNMENT_TOOL_BUTTON_TEXT?: string
DEFAULT_ASSIGNMENT_TOOL_INFO_MESSAGE?: string
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2023 - 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/>.
*/
/**
* Context modules environment data.
*
* From ContextModulesController::ModuleIndexHelper#load_modules
*/
export interface EnvContextModules {
course_id: string
CONTEXT_URL_ROOT: string
FILES_CONTEXTS: Array<{asset_string: string}>
MODULE_FILE_DETAILS: Record<
string,
{
content_id: string
module_id: string
}
>
MODULE_FILE_PERMISSIONS: {
usage_rights_required: boolean
manage_files_edit: boolean
}
MODULE_TOOLS: Record<string, unknown>
DEFAULT_POST_TO_SIS: boolean
new_quizzes_modules_support: boolean
MASTER_COURSE_SETTINGS?: {
IS_MASTER_COURSE: boolean
IS_CHILD_COURSE: boolean
MASTER_COURSE_DATA_URL: string
}
}

View File

@ -26,6 +26,7 @@ import {EnvGradebook} from '@canvas/global/env/EnvGradebook'
import {EnvGradingStandards} from '@canvas/global/env/EnvGradingStandards'
import {EnvPlatformStorage} from '@canvas/global/env/EnvPlatformStorage'
import {EnvAccounts} from '@canvas/global/env/EnvAccounts'
import {EnvContextModules} from '@canvas/global/env/EnvContextModules'
/**
* Top level ENV variable.
@ -50,5 +51,6 @@ export type GlobalEnv =
EnvGradebook &
EnvGradingStandards &
EnvPlatformStorage &
EnvRce
EnvRce &
EnvContextModules
>

View File

@ -45,10 +45,19 @@ import '@canvas/util/templateData'
import {DeepLinkResponse} from '@canvas/deep-linking/DeepLinkResponse'
import {contentItemProcessorPrechecks} from '@canvas/deep-linking/ContentItemProcessor'
import {ResourceLinkContentItem} from '@canvas/deep-linking/models/ResourceLinkContentItem'
import {EnvContextModules} from '@canvas/global/env/EnvContextModules'
import {GlobalEnv} from '@canvas/global/env/GlobalEnv'
// @ts-expect-error
if (!('INST' in window)) window.INST = {}
// Allow unchecked access to ENV variables that should exist in this context
declare const ENV: GlobalEnv &
EnvContextModules & {
// From app/views/shared/_select_content_dialog.html.erb
NEW_QUIZZES_BY_DEFAULT: boolean
}
type LtiLaunchPlacement = {
message_type:
| 'LtiDeepLinkingRequest'