Skip to content

Commit 8474790

Browse files
committed
refactor: change readOnly to isEditable to keep consistency
1 parent 39ffd85 commit 8474790

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/advanced-settings/AdvancedSettings.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ const AdvancedSettings = () => {
7070

7171
const isLoading = isPendingSettingsStatus || (isAuthzEnabled && isLoadingUserPermissions);
7272

73-
// Determine if UI should be read-only (has VIEW but not MANAGE)
74-
const isReadOnly = isAuthzEnabled
75-
&& !isLoadingUserPermissions
76-
&& !!canViewAdvancedSettings
77-
&& !canManageAdvancedSettings;
73+
const isEditable = !isAuthzEnabled
74+
|| isLoadingUserPermissions
75+
|| !!canManageAdvancedSettings;
7876

7977
const updateSettingsButtonState = {
8078
labels: {
@@ -218,7 +216,7 @@ const AdvancedSettings = () => {
218216
/>
219217
<article>
220218
<div>
221-
<section className="setting-items-policies" aria-disabled={isReadOnly || undefined}>
219+
<section className="setting-items-policies" aria-disabled={!isEditable || undefined}>
222220
<div className="small">
223221
<FormattedMessage
224222
id="course-authoring.advanced-settings.policies.description"
@@ -260,7 +258,7 @@ const AdvancedSettings = () => {
260258
handleBlur={handleSettingBlur}
261259
isEditableState={isEditableState}
262260
setIsEditableState={setIsEditableState}
263-
readOnly={isReadOnly}
261+
isEditable={isEditable}
264262
/>
265263
);
266264
})}

src/advanced-settings/setting-card/SettingCard.test.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,13 @@ describe('<SettingCard />', () => {
9292
expect(handleBlur).toHaveBeenCalled();
9393
});
9494
});
95-
it('renders in readOnly mode with disabled input', () => {
96-
render(<RootWrapper readOnly />);
95+
it('renders in read-only mode with disabled input', () => {
96+
render(<RootWrapper isEditable={false} />);
9797
const input = screen.getByLabelText(/Setting Name/i);
9898
expect(input).toBeDisabled();
9999
});
100100

101-
it('renders enabled by default when readOnly is not specified (default false)', () => {
102-
// readOnly defaults to false - input should be enabled
101+
it('renders enabled by default when isEditable is not specified (default true)', () => {
103102
render(<RootWrapper />);
104103
const input = screen.getByLabelText(/Setting Name/i);
105104
expect(input).not.toBeDisabled();

src/advanced-settings/setting-card/SettingCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const SettingCard = ({
2525
saveSettingsPrompt,
2626
isEditableState,
2727
setIsEditableState,
28-
readOnly = false,
28+
isEditable = true,
2929
}) => {
3030
const intl = useIntl();
3131
const { deprecated, help, displayName } = settingData;
@@ -100,7 +100,7 @@ const SettingCard = ({
100100
onChange={handleSettingChange}
101101
aria-label={displayName}
102102
onBlur={handleCardBlur}
103-
disabled={readOnly}
103+
disabled={!isEditable}
104104
/>
105105
</Form.Group>
106106
</Card.Section>
@@ -135,7 +135,7 @@ SettingCard.propTypes = {
135135
saveSettingsPrompt: PropTypes.bool.isRequired,
136136
isEditableState: PropTypes.bool.isRequired,
137137
setIsEditableState: PropTypes.func.isRequired,
138-
readOnly: PropTypes.bool,
138+
isEditable: PropTypes.bool,
139139
};
140140

141141
export default SettingCard;

0 commit comments

Comments
 (0)