replace LF use of underscore shim with lodash (2)
flag=none refs CFA-33 Change-Id: I85fdb8a5cad6cb4e11c9f5226c5b6dba74d45a5e Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/336477 Reviewed-by: Jacob DeWar <jacob.dewar@instructure.com> QA-Review: Jacob DeWar <jacob.dewar@instructure.com> Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
a735dda4e7
commit
61d455e179
|
@ -18,7 +18,7 @@
|
|||
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import {debounce} from 'lodash'
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import {connect} from 'react-redux'
|
||||
|
@ -147,7 +147,7 @@ export default class BlueprintAssociations extends React.Component {
|
|||
courses={this.props.courses}
|
||||
terms={this.props.terms}
|
||||
subAccounts={this.props.subAccounts}
|
||||
loadCourses={_.debounce(this.props.loadCourses, 200)}
|
||||
loadCourses={debounce(this.props.loadCourses, 200)}
|
||||
isLoadingCourses={this.props.isLoadingCourses}
|
||||
selectedCourses={this.props.addedAssociations.map(course => course.id)}
|
||||
onSelectedChanged={this.onSelectedChanged}
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import _ from 'underscore'
|
||||
import {each} from 'lodash'
|
||||
import {each, defer} from 'lodash'
|
||||
import $ from 'jquery'
|
||||
|
||||
function CheckingCheckboxesForTree($tree, bindEvents) {
|
||||
|
@ -115,7 +114,7 @@ CheckingCheckboxesForTree.prototype.checkCheckboxes = function (options) {
|
|||
const afterEach = options.afterEach
|
||||
return $checkboxes.each(function () {
|
||||
const $checkbox = $(this)
|
||||
return _.defer(function () {
|
||||
return defer(function () {
|
||||
$checkbox.prop({
|
||||
indeterminate: false,
|
||||
checked: state,
|
||||
|
|
|
@ -20,8 +20,7 @@ import React from 'react'
|
|||
import $ from 'jquery'
|
||||
import '@canvas/rails-flash-notifications'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import _ from 'underscore'
|
||||
import {map} from 'lodash'
|
||||
import {map, filter, clone} from 'lodash'
|
||||
import ValidatorResultsRow from './ValidatorResultsRow'
|
||||
|
||||
const I18n = useI18nScope('link_validator')
|
||||
|
@ -72,14 +71,14 @@ export default class ValidatorResults extends React.Component {
|
|||
if (!this.state.showUnpublished) {
|
||||
// filter out unpublished results
|
||||
results = map(results, result => {
|
||||
const new_result = _.clone(result)
|
||||
new_result.invalid_links = _.filter(
|
||||
const new_result = clone(result)
|
||||
new_result.invalid_links = filter(
|
||||
result.invalid_links,
|
||||
link => link.reason !== 'unpublished_item'
|
||||
)
|
||||
return new_result
|
||||
})
|
||||
results = _.filter(results, result => result.invalid_links.length > 0)
|
||||
results = filter(results, result => result.invalid_links.length > 0)
|
||||
}
|
||||
|
||||
if (results.length === 0) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import {find} from 'lodash'
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
|
@ -72,7 +72,7 @@ class InfoFrame extends React.Component {
|
|||
}
|
||||
|
||||
getWizardItem = key => {
|
||||
const item = _.findWhere(ListItems, {key})
|
||||
const item = find(ListItems, {key})
|
||||
|
||||
this.setState(
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import {omit, defer, pick} from 'lodash'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import * as tz from '@canvas/datetime'
|
||||
import moment from 'moment-timezone'
|
||||
|
@ -67,7 +67,7 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
|
||||
super.initialize(...arguments)
|
||||
this.model.fetch().done(() => {
|
||||
const picked_params = _.pick(
|
||||
const picked_params = pick(
|
||||
{...this.model.attributes, ...deparam()},
|
||||
'start_at',
|
||||
'start_date',
|
||||
|
@ -382,9 +382,9 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
const $textarea = this.$('textarea')
|
||||
RichContentEditor.loadNewEditor($textarea, {focus: true, manageParent: true})
|
||||
|
||||
_.defer(this.toggleDuplicateOptions)
|
||||
_.defer(this.renderConferenceWidget)
|
||||
_.defer(this.disableDatePickers)
|
||||
defer(this.toggleDuplicateOptions)
|
||||
defer(this.renderConferenceWidget)
|
||||
defer(this.disableDatePickers)
|
||||
|
||||
return this
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
const end_time = this.$el.find(`[name='${end_time_key}']`).change().data('date')
|
||||
if (!start_date) return
|
||||
|
||||
data = _.omit(data, start_date_key, start_time_key, end_time_key)
|
||||
data = omit(data, start_date_key, start_time_key, end_time_key)
|
||||
|
||||
let start_at = start_date.toString('yyyy-MM-dd')
|
||||
if (start_time && !data.blackout_date) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import $ from 'jquery'
|
||||
import '@canvas/backbone'
|
||||
import _ from 'lodash'
|
||||
import {defer} from 'lodash'
|
||||
import moment from 'moment-timezone'
|
||||
import {fireEvent, within, getByText, waitFor} from '@testing-library/dom'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
@ -64,7 +64,7 @@ describe('EditEventView', () => {
|
|||
const promise = new Promise(resolve => {
|
||||
rendered = resolve
|
||||
})
|
||||
_.defer(() => rendered())
|
||||
defer(() => rendered())
|
||||
await promise
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import _ from 'underscore'
|
||||
import {find} from 'lodash'
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import MoveDialog from './react/components/MoveDialog'
|
||||
|
@ -27,7 +27,7 @@ function openMoveDialog(
|
|||
thingsToMove,
|
||||
{contextType, contextId, returnFocusTo, clearSelectedItems, onMove}
|
||||
) {
|
||||
const rootFolderToShow = _.find(filesEnv.rootFolders, folder => {
|
||||
const rootFolderToShow = find(filesEnv.rootFolders, folder => {
|
||||
return (
|
||||
`${folder.get('context_type').toLowerCase()}s` === contextType &&
|
||||
String(folder.get('context_id')) === String(contextId)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import _ from 'underscore'
|
||||
import {indexOf} from 'lodash'
|
||||
import React from 'react'
|
||||
import createReactClass from 'create-react-class'
|
||||
import SearchResults from '../legacy/components/SearchResults'
|
||||
|
@ -126,7 +126,7 @@ SearchResults.render = function () {
|
|||
<FolderChild
|
||||
key={child.cid}
|
||||
model={child}
|
||||
isSelected={_.indexOf(this.props.selectedItems, child) >= 0}
|
||||
isSelected={indexOf(this.props.selectedItems, child) >= 0}
|
||||
toggleSelected={this.props.toggleItemSelected.bind(null, child)}
|
||||
userCanEditFilesForContext={this.props.userCanEditFilesForContext}
|
||||
userCanDeleteFilesForContext={this.props.userCanDeleteFilesForContext}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import React from 'react'
|
||||
import createReactClass from 'create-react-class'
|
||||
import _ from 'underscore'
|
||||
import {indexOf} from 'lodash'
|
||||
import classnames from 'classnames'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import ShowFolder from '../legacy/components/ShowFolder'
|
||||
|
@ -78,7 +78,7 @@ ShowFolder.renderFolderChildOrEmptyContainer = function () {
|
|||
<FolderChild
|
||||
key={child.cid}
|
||||
model={child}
|
||||
isSelected={_.indexOf(this.props.selectedItems, child) >= 0}
|
||||
isSelected={indexOf(this.props.selectedItems, child) >= 0}
|
||||
toggleSelected={this.props.toggleItemSelected.bind(null, child)}
|
||||
userCanEditFilesForContext={this.props.userCanEditFilesForContext}
|
||||
userCanDeleteFilesForContext={this.props.userCanDeleteFilesForContext}
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
*/
|
||||
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import {map} from 'lodash'
|
||||
import {map, isEqual, isArray} from 'lodash'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import FilesCollection from '@canvas/files/backbone/collections/FilesCollection'
|
||||
import customPropTypes from '@canvas/files/react/modules/customPropTypes'
|
||||
|
@ -55,7 +54,7 @@ export default {
|
|||
responseText = {errors: [{message}]}
|
||||
}
|
||||
|
||||
const errors = _.isArray(responseText.errors)
|
||||
const errors = isArray(responseText.errors)
|
||||
? this.translateErrors(responseText.errors)
|
||||
: responseText.errors && responseText.errors.base
|
||||
? [{message: `${responseText.errors.base}, ${responseText.status}`}]
|
||||
|
@ -88,7 +87,7 @@ export default {
|
|||
// Refactor this when given time. Maybe even use setState instead of forceUpdate
|
||||
if (
|
||||
!this.state.collection.loadedAll ||
|
||||
!_.isEqual(this.props.query.search_term, props.query && props.query.search_term)
|
||||
!isEqual(this.props.query.search_term, props.query && props.query.search_term)
|
||||
) {
|
||||
const forceUpdate = () => {
|
||||
// eslint-disable-next-line react/no-is-mounted
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import $ from 'jquery'
|
||||
import page from 'page'
|
||||
import _ from 'underscore'
|
||||
import {debounce} from 'lodash'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import filesEnv from '@canvas/files/react/modules/filesEnv'
|
||||
import getAllPages from '../util/getAllPages'
|
||||
|
@ -32,7 +32,7 @@ const LEADING_SLASH_TILL_BUT_NOT_INCLUDING_NEXT_SLASH = /^\/[^\/]*/
|
|||
export default {
|
||||
displayName: 'ShowFolder',
|
||||
|
||||
debouncedForceUpdate: _.debounce(function () {
|
||||
debouncedForceUpdate: debounce(function () {
|
||||
// eslint-disable-next-line react/no-is-mounted
|
||||
if (this.isMounted()) this.forceUpdate()
|
||||
}, 0),
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import _ from 'underscore'
|
||||
import {last, without} from 'lodash'
|
||||
import $ from 'jquery'
|
||||
|
||||
// To use this, your view must implement a `selectables` method that
|
||||
|
@ -67,7 +67,7 @@ export default {
|
|||
selectRange(item) {
|
||||
const selectables = this.selectables()
|
||||
const newPos = selectables.indexOf(item)
|
||||
const lastPos = selectables.indexOf(_.last(this.state.selectedItems))
|
||||
const lastPos = selectables.indexOf(last(this.state.selectedItems))
|
||||
const range = selectables.slice(Math.min(newPos, lastPos), Math.max(newPos, lastPos) + 1)
|
||||
// the anchor needs to stay at the end
|
||||
if (newPos > lastPos) {
|
||||
|
@ -93,7 +93,7 @@ export default {
|
|||
(event && event.target.type) === 'checkbox'
|
||||
|
||||
if (leaveOthersAlone && itemIsSelected) {
|
||||
selectedItems = _.without(this.state.selectedItems, item)
|
||||
selectedItems = without(this.state.selectedItems, item)
|
||||
} else if (leaveOthersAlone) {
|
||||
selectedItems = this.state.selectedItems.slice() // .slice() is to not mutate state directly
|
||||
selectedItems.push(item)
|
||||
|
|
|
@ -21,7 +21,7 @@ import ReactDOM from 'react-dom'
|
|||
import DragFeedback from '../../components/DragFeedback'
|
||||
import moveStuff from '../util/moveStuff'
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import {isArray} from 'lodash'
|
||||
|
||||
export default {
|
||||
itemsToDrag() {
|
||||
|
@ -52,7 +52,7 @@ export default {
|
|||
// make it so you can drag stuff to other apps and it will at least copy a list of urls
|
||||
// see: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Recommended_Drag_Types#link
|
||||
const itemsToDrag = this.itemsToDrag()
|
||||
if (itemsToDrag.length && _.isArray(itemsToDrag)) {
|
||||
if (itemsToDrag.length && isArray(itemsToDrag)) {
|
||||
event.dataTransfer.setData(
|
||||
'text/uri-list',
|
||||
itemsToDrag.map(item => item.get('url')).join('\n')
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import _ from 'underscore'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import $ from 'jquery'
|
||||
import {throttle} from 'lodash'
|
||||
import Progress from '@canvas/progress/backbone/models/Progress'
|
||||
import Folder from '@canvas/files/backbone/models/Folder'
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default function downloadStuffAsAZip(filesAndFolders, {contextType, conte
|
|||
// SR users set it much higher speed (300 wpm according to http://webaim.org/techniques/screenreader/)
|
||||
// This works well for the default read speed which is around 180 wpm.
|
||||
const screenreaderMessageWaitTimeMS = 2500
|
||||
const throttledSRMessage = _.throttle(
|
||||
const throttledSRMessage = throttle(
|
||||
$.screenReaderFlashMessageExclusive,
|
||||
screenreaderMessageWaitTimeMS,
|
||||
{leading: false}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
// if you change which column to order by or wheather to to sort asc or desc,
|
||||
// use this to change the api url of the collection
|
||||
import _ from 'underscore'
|
||||
import {param} from 'jquery'
|
||||
import {extend} from 'lodash'
|
||||
import deparam from 'deparam'
|
||||
|
||||
export default function updateAPIQuerySortParams(collection, queryParams) {
|
||||
|
@ -32,7 +32,7 @@ export default function updateAPIQuerySortParams(collection, queryParams) {
|
|||
|
||||
const oldUrl = collection.url
|
||||
const [baseUrl, search] = oldUrl.split('?')
|
||||
const params = _.extend(deparam(search), newParams)
|
||||
const params = extend(deparam(search), newParams)
|
||||
const newUrl = `${baseUrl}?${param(params)}`
|
||||
collection.url = newUrl
|
||||
if (newUrl !== oldUrl && !collection.loadedAll) return collection.reset()
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
// with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
import _ from 'underscore'
|
||||
|
||||
import {each} from 'lodash'
|
||||
import PaginatedCollection from '@canvas/pagination/backbone/collections/PaginatedCollection'
|
||||
|
||||
export default class SyllabusAppointmentGroupsCollection extends PaginatedCollection {
|
||||
|
@ -43,7 +42,7 @@ export default class SyllabusAppointmentGroupsCollection extends PaginatedCollec
|
|||
// Overridden to make the id unique when aggregated in
|
||||
// a collection with other models
|
||||
parse(resp) {
|
||||
_.each(super.parse(...arguments), ev => (ev.related_id = ev.id = `appointment_group_${ev.id}`))
|
||||
each(super.parse(...arguments), ev => (ev.related_id = ev.id = `appointment_group_${ev.id}`))
|
||||
return resp
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
import _ from 'underscore'
|
||||
import {each} from 'lodash'
|
||||
import PaginatedCollection from '@canvas/pagination/backbone/collections/PaginatedCollection'
|
||||
|
||||
export default class SyllabusCalendarEventsCollection extends PaginatedCollection {
|
||||
|
@ -53,7 +53,7 @@ export default class SyllabusCalendarEventsCollection extends PaginatedCollectio
|
|||
ev.related_id = ev.id
|
||||
|
||||
let overridden = false
|
||||
_.each(ev.assignment_overrides != null ? ev.assignment_overrides : [], override => {
|
||||
each(ev.assignment_overrides != null ? ev.assignment_overrides : [], override => {
|
||||
if (!overridden) {
|
||||
ev.id = `${ev.id}_override_${override.id}`
|
||||
return (overridden = true)
|
||||
|
@ -75,7 +75,7 @@ export default class SyllabusCalendarEventsCollection extends PaginatedCollectio
|
|||
}
|
||||
|
||||
const result = []
|
||||
_.each(super.parse(...args), ev => {
|
||||
each(super.parse(...args), ev => {
|
||||
if (!ev.hidden) result.push(normalize(ev))
|
||||
})
|
||||
return result
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
//
|
||||
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import {reduce, each} from 'lodash'
|
||||
import Backbone from '@canvas/backbone'
|
||||
import template from '../../jst/Syllabus.handlebars'
|
||||
|
||||
|
@ -144,7 +144,7 @@ export default class SyllabusView extends Backbone.View {
|
|||
}
|
||||
|
||||
let override = null
|
||||
_.each(json.assignment_overrides != null ? json.assignment_overrides : [], ov => {
|
||||
each(json.assignment_overrides != null ? json.assignment_overrides : [], ov => {
|
||||
if (override == null) {
|
||||
override = {}
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ export default class SyllabusView extends Backbone.View {
|
|||
}
|
||||
|
||||
// Get the dates and events
|
||||
const dates = _.reduce(super.toJSON(...arguments), dateCollator, [])
|
||||
const dates = reduce(super.toJSON(...arguments), dateCollator, [])
|
||||
|
||||
// Remove extraneous override information for single events
|
||||
let overrides_present = false
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
import React from 'react'
|
||||
import page from 'page'
|
||||
import $ from 'jquery'
|
||||
import {each, find} from 'lodash'
|
||||
import classnames from 'classnames'
|
||||
import {Mask, Overlay} from '@instructure/ui-overlays'
|
||||
import FilePreviewInfoPanel from './FilePreviewInfoPanel'
|
||||
import CollectionHandler from '../../util/collectionHandler'
|
||||
import preventDefault from '@canvas/util/preventDefault'
|
||||
|
||||
import _ from 'underscore'
|
||||
import PropTypes from 'prop-types'
|
||||
import customPropTypes from '../modules/customPropTypes'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
|
@ -100,7 +100,7 @@ export default class FilePreview extends React.PureComponent {
|
|||
order: this.props.query.order || undefined,
|
||||
}
|
||||
|
||||
_.each(obj, (v, k) => {
|
||||
each(obj, (v, k) => {
|
||||
if (
|
||||
!v ||
|
||||
(opts.except && opts.except.length && (opts.except === k || opts.except.includes(k)))
|
||||
|
@ -129,7 +129,7 @@ export default class FilePreview extends React.PureComponent {
|
|||
return onlyIdsToPreview.includes(file.id)
|
||||
})
|
||||
|
||||
const visibleFile = props.query.preview && _.findWhere(files, {id: props.query.preview})
|
||||
const visibleFile = props.query.preview && find(files, {id: props.query.preview})
|
||||
|
||||
if (!visibleFile) {
|
||||
const responseDataRequested = ['enhanced_preview_url']
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
// this is just https://github.com/usepropeller/react.backbone but without the UMD wrapper.
|
||||
|
||||
import Backbone from '@canvas/backbone'
|
||||
import _ from 'underscore'
|
||||
import {debounce, identity} from 'lodash'
|
||||
|
||||
const collectionBehavior = {
|
||||
changeOptions: 'add remove reset sort',
|
||||
updateScheduler(func) {
|
||||
return _.debounce(func, 0)
|
||||
return debounce(func, 0)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ const modelBehavior = {
|
|||
|
||||
// note: if we debounce models too we can no longer use model attributes
|
||||
// as properties to react controlled components due to https://github.com/facebook/react/issues/955
|
||||
updateScheduler: _.identity,
|
||||
updateScheduler: identity,
|
||||
}
|
||||
|
||||
function subscribe(component, modelOrCollection, customChangeOptions) {
|
||||
|
|
Loading…
Reference in New Issue