Skip to content

Commit

Permalink
style: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoa committed Nov 4, 2024
1 parent f418523 commit 869d231
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/editors/data/redux/thunkActions/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { StrictDict, camelizeKeys } from '../../../utils';
import { isLibraryKey } from '../../../../generic/key-utils';
import * as requests from './requests';
// This 'module' self-import hack enables mocking during tests.
// See src/editors/decisions/0005-internal-editor-testability-decisions.md. The whole approach to how hooks are tested
Expand Down
17 changes: 9 additions & 8 deletions src/editors/data/redux/thunkActions/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,17 @@ export const uploadAsset = ({ asset, ...rest }) => (dispatch, getState) => {
asset,
studioEndpointUrl: selectors.app.studioEndpointUrl(getState()),
blockId: selectors.app.blockId(getState()),
}).then(data => {
}).then((resp) => {
if (isLibraryKey(esteid) && !isLibraryV1Key(esteid)) {
const imageTypes = {
png: 'image/png',
jpeg: 'image/jpeg',
jpg: 'image/jpeg',
};
const fileName = data.data.path.replace(/^.*[\\/]/, '');
const fileExt = data.data.path.split('.').pop().toLowerCase();
data.data = {
let { data } = resp;
const fileName = data.path.replace(/^.*[\\/]/, '');
const fileExt = data.path.split('.').pop().toLowerCase();
data = {
asset: {
displayName: fileName,
contentType: imageTypes[fileExt],
Expand All @@ -151,10 +152,10 @@ export const uploadAsset = ({ asset, ...rest }) => (dispatch, getState) => {
thumbnail: data.data.url,
id: data.data.path,
locked: false,
}
}
},
};
}
return data
return resp;
}),
...rest,
}));
Expand Down Expand Up @@ -182,7 +183,7 @@ export const fetchImages = ({ pageNumber, ...rest }) => (dispatch, getState) =>
(obj, file) => {
const fileName = file.path.replace(/^.*[\\/]/, '');
const fileExt = file.path.split('.').pop().toLowerCase();
return imageTypes.hasOwnProperty(fileExt) ? {
return Object.prototype.hasOwnProperty.call(imageTypes, fileExt) ? {
...obj,
[fileName]: {
displayName: fileName,
Expand Down
5 changes: 4 additions & 1 deletion src/editors/data/services/cms/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ describe('cms api', () => {

describe('fetchImages', () => {
it('should call get with url.courseAssets', () => {
apiMethods.fetchImages({ learningContextId, studioEndpointUrl, pageNumber: 0 });
apiMethods.fetchImages({
blockId, learningContextId, studioEndpointUrl, pageNumber: 0,
});
const params = {
asset_type: 'Images',
page: 0,
Expand Down Expand Up @@ -251,6 +253,7 @@ describe('cms api', () => {
const mockFormdata = new FormData();
mockFormdata.append('file', asset);
apiMethods.uploadAsset({
blockId,
learningContextId,
studioEndpointUrl,
asset,
Expand Down
4 changes: 3 additions & 1 deletion src/editors/data/services/cms/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import type { AxiosRequestConfig } from 'axios';
import { camelizeKeys } from '../../../utils';
import { isLibraryKey, isLibraryV1Key } from '../../../../generic/key-utils';
import * as urls from './urls';
import { get, post, put, deleteObject } from './utils';
import {
get, post, put, deleteObject,
} from './utils';
import { durationStringFromValue } from '../../../containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks';

const fetchByUnitIdOptions: AxiosRequestConfig = {};
Expand Down
2 changes: 1 addition & 1 deletion src/editors/sharedComponents/SelectionModal/Gallery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
} from '@edx/frontend-platform/i18n';

// SelectableBox in paragon has a bug where you can't change selection. So we override it
import { useSelector } from 'react-redux';
import SelectableBox from '../SelectableBox';
import messages from './messages';
import GalleryCard from './GalleryCard';
import GalleryLoadMoreButton from './GalleryLoadMoreButton';
import { useSelector } from 'react-redux';
import { selectors } from '../../data/redux';

const Gallery = ({
Expand Down
3 changes: 1 addition & 2 deletions src/editors/sharedComponents/TinyMceWidget/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export const editorConfig = ({
setEditorRef,
editorContentHtml,
images,
isLibrary,
placeholder,
initializeEditor,
openImgModal,
Expand All @@ -268,7 +267,7 @@ export const editorConfig = ({
imageToolbar,
quickbarsInsertToolbar,
quickbarsSelectionToolbar,
} = pluginConfig({ placeholder, editorType });
} = pluginConfig({ learningContextId, placeholder, editorType });
const isLocaleRtl = isRtl(getLocale());
return {
onInit: (evt, editor) => {
Expand Down
11 changes: 6 additions & 5 deletions src/editors/sharedComponents/TinyMceWidget/pluginConfig.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { isLibraryV1Key } from '../../../generic/key-utils';
import { StrictDict } from '../../utils';
import { buttons, plugins } from '../../data/constants/tinyMCE';

const mapToolbars = toolbars => toolbars.map(toolbar => toolbar.join(' ')).join(' | ');

const pluginConfig = ({ isLibrary, placeholder, editorType }) => {
const image = isLibrary ? '' : plugins.image;
const imageTools = isLibrary ? '' : plugins.imagetools;
const imageUploadButton = isLibrary ? '' : buttons.imageUploadButton;
const editImageSettings = isLibrary ? '' : buttons.editImageSettings;
const pluginConfig = ({ learningContextId, placeholder, editorType }) => {
const image = isLibraryV1Key(learningContextId) ? '' : plugins.image;
const imageTools = isLibraryV1Key(learningContextId) ? '' : plugins.imagetools;
const imageUploadButton = isLibraryV1Key(learningContextId) ? '' : buttons.imageUploadButton;
const editImageSettings = isLibraryV1Key(learningContextId) ? '' : buttons.editImageSettings;
const codePlugin = editorType === 'text' ? plugins.code : '';
const codeButton = editorType === 'text' ? buttons.code : '';
const labelButton = editorType === 'question' ? buttons.customLabelButton : '';
Expand Down

0 comments on commit 869d231

Please sign in to comment.