From be600a91f01f7b008faeec2c7322bef2a9e6e748 Mon Sep 17 00:00:00 2001 From: Jillian Date: Tue, 28 Jan 2025 02:17:09 +1030 Subject: [PATCH] feat: hide some settings fields when editing a library problem (#1601) Hides some XBlock settings fields when editing library blocks. These hidden settings fields are relevant to course blocks, but not library blocks. This change impacts Library Authors, and Course Authors who use Library Blocks and/or Problem Banks. --- .../__snapshots__/index.test.jsx.snap | 183 ++++++++++++++++++ .../EditProblemView/SettingsWidget/index.jsx | 57 +++--- .../SettingsWidget/index.test.jsx | 33 ++++ 3 files changed, 248 insertions(+), 25 deletions(-) diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap index 0fcfc6ed0..8ae716816 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap @@ -1,5 +1,188 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`SettingsWidget isLibrary snapshot: renders Settings widget for Advanced Problem with correct widgets 1`] = ` +
+
+ +
+
+ +
+ +
+ + + + + +
+ + +
+ +
+ +
+
+`; + +exports[`SettingsWidget isLibrary snapshot: renders Settings widget page 1`] = ` +
+
+ +
+
+ +
+ +
+ + + + + +
+ + +
+ +
+ +
+
+`; + +exports[`SettingsWidget isLibrary snapshot: renders Settings widget page advanced settings visible 1`] = ` +
+
+ +
+
+ +
+ +
+ + + + + +
+ + +
+ +
+ +
+
+`; + exports[`SettingsWidget snapshot snapshot: renders Settings widget for Advanced Problem with correct widgets 1`] = `
)} -
- -
+ {!isLibrary && ( +
+ +
+ )}
- -
- -
-
- -
+ {!isLibrary && ( +
+ +
+ )} + {!isLibrary && ( +
+ +
+ )} { problemType === ProblemTypeKeys.ADVANCED && (
@@ -142,9 +147,11 @@ const SettingsWidget = ({
) } -
- -
+ {!isLibrary && ( +
+ +
+ )}
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx index 1630753c0..db7834492 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx @@ -74,6 +74,39 @@ describe('SettingsWidget', () => { }); }); + describe('isLibrary', () => { + const libraryProps = { + ...props, + isLibrary: true, + }; + test('snapshot: renders Settings widget page', () => { + const showAdvancedSettingsCardsProps = { + isAdvancedCardsVisible: false, + setResetTrue: jest.fn().mockName('showAdvancedSettingsCards.setResetTrue'), + }; + showAdvancedSettingsCards.mockReturnValue(showAdvancedSettingsCardsProps); + expect(shallow().snapshot).toMatchSnapshot(); + }); + test('snapshot: renders Settings widget page advanced settings visible', () => { + const showAdvancedSettingsCardsProps = { + isAdvancedCardsVisible: true, + setResetTrue: jest.fn().mockName('showAdvancedSettingsCards.setResetTrue'), + }; + showAdvancedSettingsCards.mockReturnValue(showAdvancedSettingsCardsProps); + expect(shallow().snapshot).toMatchSnapshot(); + }); + test('snapshot: renders Settings widget for Advanced Problem with correct widgets', () => { + const showAdvancedSettingsCardsProps = { + isAdvancedCardsVisible: true, + setResetTrue: jest.fn().mockName('showAdvancedSettingsCards.setResetTrue'), + }; + showAdvancedSettingsCards.mockReturnValue(showAdvancedSettingsCardsProps); + expect(shallow( + , + ).snapshot).toMatchSnapshot(); + }); + }); + describe('mapDispatchToProps', () => { test('setBlockTitle from actions.app.setBlockTitle', () => { expect(mapDispatchToProps.setBlockTitle).toEqual(actions.app.setBlockTitle);