Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update client dependencies #4150

Merged
merged 80 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
dc4175e
Update react and react-dom to the latest versions
zhuhanming Sep 14, 2021
fe130ab
Update unsafe methods
zhuhanming Sep 14, 2021
2943f44
Update manual bind to arrow
zhuhanming Sep 14, 2021
b88ac6d
Clean up React imports
zhuhanming Sep 14, 2021
b3bfbe0
Sort methods
zhuhanming Sep 14, 2021
99e8909
Fix incorrect type import
zhuhanming Sep 15, 2021
27b8956
Merge branch 'rails-6' into update-client-deps
zhuhanming Sep 15, 2021
10a77cb
Update babel to compile without need for explicit import of React
zhuhanming Sep 15, 2021
1bf19e0
Update fabric
zhuhanming Sep 15, 2021
ca04166
Update webpack to v5
zhuhanming Sep 15, 2021
b7f76f9
Fix naming of webpack chunks
zhuhanming Sep 15, 2021
c4ca187
Update enzyme to use temporary React 17 adapter
zhuhanming Sep 15, 2021
b3afa60
Fix tests
zhuhanming Sep 16, 2021
86636e8
Update all remaining deps
zhuhanming Sep 16, 2021
06646d5
Fix breaking changes in @material-ui/pickers and react-dnd
zhuhanming Sep 16, 2021
2942ff2
Update CircleCI image node version
zhuhanming Sep 16, 2021
692996f
Update node to v14 LTS in CircleCI pipeline
zhuhanming Sep 16, 2021
bb31a0c
Fix incorrectly ordered methods from codemodding
zhuhanming Sep 16, 2021
4168cc1
Merge branch 'master' of https://github.com/Coursemology/coursemology…
zhuhanming Oct 3, 2021
6ad1a96
Add yarn log files to gitignore
zhuhanming Oct 3, 2021
1edb163
Merge branch 'update-client-deps' of https://github.com/Coursemology/…
zhuhanming Oct 3, 2021
e378d9a
chore: merge from master
zhuhanming Oct 27, 2021
4b2f4d8
chore: fix application js includes
zhuhanming Oct 27, 2021
88882e7
fix: resolve issues due to jquery
zhuhanming Oct 27, 2021
25df3f3
fix: revert certain deps that are difficult to upgrade now
zhuhanming Oct 27, 2021
ccf151f
style(client): rearrange methods
zhuhanming Oct 27, 2021
eb5b233
chore: upgrade sass-loader
zhuhanming Oct 27, 2021
b737bf9
style(client): clean up on unused vars
zhuhanming Oct 27, 2021
4bbb806
chore(client): improve linting and formatting of files
zhuhanming Oct 28, 2021
a75477c
style(client): clean up on import paths
zhuhanming Oct 28, 2021
3fc9cb5
fix(client): fix regression with datetime picker
zhuhanming Oct 28, 2021
2483a5e
style(client): fix minor issues
zhuhanming Oct 28, 2021
9402d65
style(client): fix eslint config and lint test files
zhuhanming Oct 28, 2021
67f564c
merge: merge from upstream master
zhuhanming Dec 18, 2021
771219e
ci: update node version
zhuhanming Dec 18, 2021
b1679a0
merge: merge from upstream master
zhuhanming Dec 22, 2021
ab88119
Merge branch 'master' of https://github.com/Coursemology/coursemology…
zhuhanming Dec 22, 2021
623b40f
fix: fix duplicated methods and import issues
zhuhanming Dec 22, 2021
eb89001
fix: fix jest method
zhuhanming Dec 22, 2021
41c6666
fix: fix eslint issues for test files
zhuhanming Dec 22, 2021
25c7ffa
chore: revert router upgrade
zhuhanming Dec 22, 2021
37aa760
tests: fix failing dnd test
zhuhanming Dec 23, 2021
9aa7c82
fix: fix dnd issue for survey questions
zhuhanming Dec 23, 2021
eadf875
fix: fix dnd provider issue for surveys
zhuhanming Dec 23, 2021
b0b381c
chore: allow hot reload of modules
zhuhanming Dec 23, 2021
afd73c7
fix: fix date time picker
zhuhanming Dec 23, 2021
e0fcdad
refactor: remove confirm-dialog and use ConfirmationDialog for condit…
zhuhanming Dec 24, 2021
56fe20d
fix: fix bug with date time picker
zhuhanming Dec 24, 2021
0618aaf
fix: bring back rails confirmation dialog
zhuhanming Dec 24, 2021
b66ef60
tests: update selector
zhuhanming Dec 24, 2021
045233c
chore: clean up code
zhuhanming Dec 24, 2021
dd1e49d
chore: convert some classes to functional components via codemod
zhuhanming Dec 24, 2021
0f9d9e4
style: clean up unused eslint comment
zhuhanming Dec 24, 2021
22d1451
style: reorder props using codemod
zhuhanming Dec 24, 2021
d60057c
revert: undo location.href changes
zhuhanming Dec 26, 2021
4ab4c49
fix: clear time error and add relevant comments
zhuhanming Dec 26, 2021
9a6743b
chore: update some final deps
zhuhanming Dec 27, 2021
3c1bae1
chore: change jquery and jquery-ui version in package.json
zhuhanming Dec 27, 2021
0b2e45a
chore: bump up some dependencies manually
zhuhanming Dec 28, 2021
fde6441
Merge branch 'master' of https://github.com/Coursemology/coursemology…
zhuhanming Dec 28, 2021
599d1bf
style: fix jest expect method
zhuhanming Dec 28, 2021
382633f
merge: merge from upstream master
zhuhanming Jan 11, 2022
fbfd046
fix: fix issues arising from merge conflicts
zhuhanming Jan 11, 2022
09bde73
chore: refactor React.Component to Component
zhuhanming Jan 11, 2022
bee527c
Merge changes from upstream master
zhuhanming Feb 16, 2022
6af9a8d
Merge branch 'master' of https://github.com/Coursemology/coursemology…
zhuhanming Feb 23, 2022
60e4862
fix: fix broken narrow editor due to react-overlays upgrade
zhuhanming Feb 23, 2022
42b442d
chore: bump up deps
zhuhanming Feb 23, 2022
c63c2cb
style: remove unnecessary braces
zhuhanming Feb 24, 2022
866e806
ci: update node version used for caching
zhuhanming Feb 24, 2022
cc51d95
fix: fix broken narrow editor again and change its behaviour to be si…
zhuhanming Feb 24, 2022
3e2799b
fix: memoize dnd manager for survey show
zhuhanming Feb 25, 2022
871672d
fix: fix strange bug with post packs turning undefined
zhuhanming Feb 25, 2022
85f7eba
merge: merge from upstream master
zhuhanming Mar 1, 2022
016a00d
feat: switch summernote dependencies to custom deps
zhuhanming Mar 2, 2022
836d149
fix: fix summernote ui
zhuhanming Mar 2, 2022
8b0c560
chore(mui chip input): downgrade mui chip input as there are breaking…
ekowidianto Mar 2, 2022
4536835
fix(summernote): fix summernote airmode issues and double enter or re…
ekowidianto Mar 4, 2022
c0c97c3
fix: update custom react-summernote and fix lint issues
zhuhanming Mar 6, 2022
4da4784
style: fix scss issues
zhuhanming Mar 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ commands:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install v14.16.1
nvm alias default 14.16.1
nvm install v14.18.2
nvm alias default 14.18.2

echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

# Ignore installed node libraries and log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
node_modules

# Ignore generated js bundles
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ gem 'simple_form'
gem 'simple_form-bootstrap', git: 'https://github.com/raymondtangsc/simple_form-bootstrap'
# Dynamic nested forms
gem 'cocoon'
gem 'momentjs-rails' # Needed for bootstrap3-datetimepicker-rails
gem 'bootstrap3-datetimepicker-rails'
gem 'bootstrap-select-rails'
gem 'bootstrap_tokenfield_rails'
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ DEPENDENCIES
loofah (>= 2.2.1)
mimemagic (>= 0.3.7)
mini_magick
momentjs-rails
nokogiri (>= 1.8.1)
parallel_tests
pg
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//= require jquery_ujs
//= require i18n/translations
//= require js-routes
//= require moment
//= require bootstrap-sprockets
//= require bootstrap-datetimepicker
//= require bootstrap-select
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/course/discussion/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// TODO: Display error messages.
}

$(document).ready(function () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been deprecated in jQuery 1.8. Recommended way is the updated way.

See https://api.jquery.com/ready/

$(function () {
showCommentBoxes();
DISCUSSION_POST_HELPERS.initializeToolbar(document, DOCUMENT_SELECTOR);
});
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/helpers/discussion/post_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var DISCUSSION_POST_HELPERS = (function (
* @param {String} selector The selector for the specific discussion posts.
*/
function initializeToolbar(element, selector) {
$(document).ready(function () {
$(function () {
showCommentToolbar(element, selector);
});
EVENT_HELPERS.onNodesInserted($(element), function (insertedElement) {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
//
// This prevents missing definitions for things like Ace themes, which are loaded after the
// application script.
$(document).ready(function () {
$(function () {
initializeComponents(document);

EVENT_HELPERS.onNodesInserted($(document), initializeComponents);
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/patches/dropdown_mobile_fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
});
}

$(document).ready(function () {
$(function () {
initializeDropdownEventListener();
});
})(jQuery);
7 changes: 6 additions & 1 deletion client/.babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
[
"@babel/preset-react",
{
"runtime": "automatic"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added to support the new JSX Transform: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html which has the following benefits:

Upgrading to the new transform is completely optional, but it has a few benefits:

  • With the new transform, you can use JSX without importing React.
  • Depending on your setup, its compiled output may slightly improve the bundle size.
  • It will enable future improvements that reduce the number of concepts you need to learn React.

See this section: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#manual-babel-setup

}
]
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
Expand Down
69 changes: 64 additions & 5 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
module.exports = {
parser: 'babel-eslint',
plugins: ['jest'],
extends: [
'airbnb',
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:import/recommended',
'prettier',
],
settings: {
'import/resolver': {
node: {},
webpack: {},
alias: {
map: [
['lib', './app/lib'],
['api', './app/api'],
['course', './app/bundles/course'],
['testUtils', './app/__test__/utils'],
],
extensions: ['.js', '.jsx'],
},
},
react: {
// TODO: Update this to 'detect' once React is upgraded >=16.9
version: '16.8.6',
version: 'detect',
},
},
rules: {
Expand All @@ -34,7 +43,7 @@ module.exports = {
'jsx-a11y/mouse-events-have-key-events': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'max-len': ['warn', 120],
camelcase: ['warn', { properties: 'never' }],
camelcase: ['warn', { properties: 'never', allow: ['^UNSAFE_'] }],
'comma-dangle': ['error', 'always-multiline'],
'func-names': 'off',
'no-multi-str': 'off',
Expand All @@ -55,4 +64,54 @@ module.exports = {
File: true,
FileReader: true,
},
overrides: [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged in the test ESLint config using the overrides config. Also added jest-specific configuration.

{
files: [
'**/__test__/**/*.js',
'**/__test__/**/*.jsx',
'**/*.test.js',
'**/*.test.jsx',
'**/*.spec.js',
'**/*.spec.jsx',
],
env: {
jest: true,
},
globals: {
courseId: true,
intl: true,
intlShape: true,
sleep: true,
buildContextOptions: true,
localStorage: true,
},
rules: {
'jest/no-disabled-tests': 'error',
'jest/no-focused-tests': 'error',
'jest/no-alias-methods': 'error',
'jest/no-identical-title': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-jest-import': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-done-callback': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-to-be': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
'jest/prefer-spy-on': 'error',
'jest/valid-expect': 'error',
'jest/no-deprecated-functions': 'error',
'react/no-find-dom-node': 'off',
'react/jsx-filename-extension': 'off',
'import/no-extraneous-dependencies': 'off',
'import/extensions': 'off',
'import/no-unresolved': [
'error',
{
ignore: ['utils/'],
},
],
},
},
],
};
26 changes: 0 additions & 26 deletions client/.eslintrc.test

This file was deleted.

9 changes: 7 additions & 2 deletions client/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module.exports = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more configurations to improve Prettier formatting.

semi: true,
trailingComma: 'all',
arrowParens: 'always',
endOfLine: 'lf',
jsxSingleQuote: false,
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
};
9 changes: 4 additions & 5 deletions client/app/__test__/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IntlProvider, intlShape } from 'react-intl';
import getMuiTheme from 'material-ui/styles/getMuiTheme';

import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';

Enzyme.configure({ adapter: new Adapter() });

Expand All @@ -16,6 +16,7 @@ const intlProvider = new IntlProvider({ locale: 'en', timeZone }, {});
const courseId = '1';

const muiTheme = getMuiTheme();
const intl = intlProvider.getChildContext().intl;
const buildContextOptions = (store) => ({
context: { intl, store, muiTheme },
childContextTypes: {
Expand All @@ -28,7 +29,7 @@ const buildContextOptions = (store) => ({
// Global variables
global.courseId = courseId;
global.window = window;
global.intl = intlProvider.getChildContext().intl;
global.intl = intl;
global.intlShape = intlShape;
global.muiTheme = muiTheme;
global.$ = jQuery;
Expand All @@ -50,8 +51,6 @@ global.sleep = sleep;

// summernote does not work well with jsdom in tests, stub it to normal text field.
jest.mock('lib/components/redux-form/RichTextField', () => {
const TextField = require.requireActual(
'lib/components/redux-form/TextField',
);
const TextField = jest.requireActual('lib/components/redux-form/TextField');
return TextField;
});
19 changes: 10 additions & 9 deletions client/app/__test__/utils/__test__/shallowUntil.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { Component } from 'react';
import PropTypes from 'prop-types';
import shallowUntil from '../shallowUntil';

describe('#shallowUntil', () => {
const Div = () => <div />;
const hoc = (Component) => {
const component = () => <Component />;
const hoc = (Comp) => {
const component = () => <Comp />;
return component;
};

Expand Down Expand Up @@ -43,33 +43,34 @@ describe('#shallowUntil', () => {
).toBeTruthy();
});

describe('with context', () => {
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('with context', () => {
const Foo = () => <Div />;
Foo.contextTypes = { open: PropTypes.bool.isRequired };

class Bar extends React.Component {
class Bar extends Component {
getChildContext = () => ({ open: true });

render = () => <Foo />;
}

Bar.childContextTypes = { open: PropTypes.bool };

xit('passes down context from the root component', () => {
it('passes down context from the root component', () => {
const EnhancedFoo = hoc(Foo);
const wrapper = shallowUntil(
<EnhancedFoo />,
{ context: { open: true } },
'Foo',
);
expect(wrapper.context('open')).toEqual(true);
expect(wrapper.context('open')).toBe(true);
expect(wrapper.contains(<Div />)).toBeTruthy();
});

xit('passes down context from an intermediary component', () => {
it('passes down context from an intermediary component', () => {
const EnhancedBar = hoc(Bar);
const wrapper = shallowUntil(<EnhancedBar />, 'Foo');
expect(wrapper.context('open')).toEqual(true);
expect(wrapper.context('open')).toBe(true);
expect(wrapper.contains(<Div />)).toBeTruthy();
});
});
Expand Down
2 changes: 2 additions & 0 deletions client/app/__test__/utils/shallowUntil.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function until(selector, options) {
*/
export default function shallowUntil(component, options, selector) {
if (selector === undefined) {
// eslint-disable-next-line no-param-reassign
selector = options;
// eslint-disable-next-line no-param-reassign
options = undefined;
}
return until.call(shallow(component, options), selector, options);
Expand Down
9 changes: 2 additions & 7 deletions client/app/api/course/Admin/LessonPlan.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ export default class LessonPlanAPI extends BaseAdminAPI {
* Update a lesson plan setting.
*
* @param {object} params
* - params in the format of {
* lesson_plan_settings:
* {
* lesson_plan_item_settings:
* { :component, :key, :enabled, :options }
* }
* }
* - params in the format of
* { lesson_plan_settings: { lesson_plan_item_settings: { :component, :key, :enabled, :options } } }
*
* @return {Promise}
* success response: {}
Expand Down
3 changes: 1 addition & 2 deletions client/app/bundles/course/achievement/achievements-edit.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import { render } from 'react-dom';
import ProviderWrapper from 'lib/components/ProviderWrapper';
import storeCreator from './store';
import AchievementEditPage from './pages/AchievementEdit';

$(document).ready(() => {
$(() => {
const mountNode = document.getElementById('achievement-edit');
if (mountNode) {
const dataAttr = mountNode.getAttribute('data');
Expand Down
3 changes: 1 addition & 2 deletions client/app/bundles/course/achievement/achievements-index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import { render } from 'react-dom';
import ProviderWrapper from 'lib/components/ProviderWrapper';
import storeCreator from './store';
import AchievementIndexPage from './pages/AchievementIndex';

$(document).ready(() => {
$(() => {
const mountNode = $('.new-btn')[0];

if (mountNode) {
Expand Down
2 changes: 1 addition & 1 deletion client/app/bundles/course/achievement/achievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ function initializeReorderingButton() {
});
}

$(document).ready(() => {
$(() => {
initializeReorderingButton();
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { reduxForm, Field, Form } from 'redux-form';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { mount } from 'enzyme';
import ProviderWrapper from 'lib/components/ProviderWrapper';
import CourseAPI from 'api/course';
Expand Down
Loading