Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 63f3559

Browse files
author
Kerry Archibald
committed
tidy debugs, rename setting to Parameters
Signed-off-by: Kerry Archibald <[email protected]>
1 parent 3146317 commit 63f3559

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/components/views/dialogs/ExportDialog.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ const validateNumberInRange = (min: number, max: number) => (value?: string | nu
5757
};
5858

5959
// Sanitize setting values, exclude invalid or missing values
60-
export type ForceRoomExportSettings = {
60+
export type ForceRoomExportParameters = {
6161
format?: ExportFormat; range?: ExportType; numberOfMessages?: number; includeAttachments?: boolean; sizeMb?: number;
6262
};
63-
export const getSafeForceRoomExportSettings = (): ForceRoomExportSettings => {
64-
const config = SettingsStore.getValue<ForceRoomExportSettings>(UIFeature.ForceRoomExportSettings);
63+
export const getSafeForceRoomExportParameters = (): ForceRoomExportParameters => {
64+
const config = SettingsStore.getValue<ForceRoomExportParameters>(UIFeature.ForceRoomExportParameters);
6565
if (!config || typeof config !== "object") return {};
6666

6767
const { format, range, numberOfMessages, includeAttachments, sizeMb } = config;
@@ -90,12 +90,12 @@ interface ExportConfig {
9090
}
9191

9292
/**
93-
* Set up form state using UIFeature.ForceRoomExportSettings or defaults
94-
* Form fields configured in ForceRoomExportSettings are not allowed to be edited
93+
* Set up form state using UIFeature.ForceRoomExportParameters or defaults
94+
* Form fields configured in ForceRoomExportParameters are not allowed to be edited
9595
* Only return change handlers for editable values
9696
*/
9797
const useExportFormState = (): ExportConfig => {
98-
const config = getSafeForceRoomExportSettings();
98+
const config = getSafeForceRoomExportParameters();
9999

100100
const [exportFormat, setExportFormat] = useState(config.format || ExportFormat.Html);
101101
const [exportType, setExportType] = useState(config.range || ExportType.Timeline);

src/settings/Settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
956956
supportedLevels: LEVELS_UI_FEATURE,
957957
default: true,
958958
},
959-
[UIFeature.ForceRoomExportSettings]: {
959+
[UIFeature.ForceRoomExportParameters]: {
960960
supportedLevels: LEVELS_UI_FEATURE,
961961
default: {},
962962
},

src/settings/UIFeature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export enum UIFeature {
3333
AdvancedSettings = "UIFeature.advancedSettings",
3434
RoomHistorySettings = "UIFeature.roomHistorySettings",
3535
TimelineEnableRelativeDates = "UIFeature.timelineEnableRelativeDates",
36-
ForceRoomExportSettings = "UIFeature.forceRoomExportSettings"
36+
ForceRoomExportParameters = "UIFeature.ForceRoomExportParameters"
3737
}
3838

3939
export enum UIComponent {

test/components/views/dialogs/ExportDialog-test.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { act } from "react-dom/test-utils";
2222
import { Room } from 'matrix-js-sdk';
2323

2424
import ExportDialog,
25-
{ getSafeForceRoomExportSettings, ForceRoomExportSettings }
25+
{ getSafeForceRoomExportParameters, ForceRoomExportParameters }
2626
from '../../../../src/components/views/dialogs/ExportDialog';
2727
import { ExportType, ExportFormat } from '../../../../src/utils/exportUtils/exportUtils';
2828
import { createTestClient, mkStubRoom } from '../../../test-utils';
@@ -140,7 +140,7 @@ describe('<ExportDialog />', () => {
140140
expect(htmlExporterInstance.export).toHaveBeenCalled();
141141
});
142142

143-
it('exports room using values set from ForceRoomExportSettings', async () => {
143+
it('exports room using values set from ForceRoomExportParameters', async () => {
144144
SettingsStoreMock.getValue.mockReturnValue({
145145
format: ExportFormat.PlainText,
146146
range: ExportType.Beginning,
@@ -188,12 +188,12 @@ describe('<ExportDialog />', () => {
188188
expect(getExportFormatInput(component, ExportFormat.Html).props().checked).toBeFalsy();
189189
});
190190

191-
it('hides export format input when format is valid in ForceRoomExportSettings', () => {
191+
it('hides export format input when format is valid in ForceRoomExportParameters', () => {
192192
const component = getComponent();
193193
expect(getExportFormatInput(component, ExportFormat.Html).props().checked).toBeTruthy();
194194
});
195195

196-
it('does not render export format when set in ForceRoomExportSettings', () => {
196+
it('does not render export format when set in ForceRoomExportParameters', () => {
197197
SettingsStoreMock.getValue.mockReturnValue({
198198
format: ExportFormat.PlainText,
199199
});
@@ -214,7 +214,7 @@ describe('<ExportDialog />', () => {
214214
expect(getExportTypeInput(component).props().value).toEqual(ExportType.Beginning);
215215
});
216216

217-
it('does not render export type when set in ForceRoomExportSettings', () => {
217+
it('does not render export type when set in ForceRoomExportParameters', () => {
218218
SettingsStoreMock.getValue.mockReturnValue({
219219
range: ExportType.Beginning,
220220
});
@@ -305,7 +305,7 @@ describe('<ExportDialog />', () => {
305305
expect(htmlExporterInstance.export).toHaveBeenCalled();
306306
});
307307

308-
it('does not render size limit input when set in ForceRoomExportSettings', () => {
308+
it('does not render size limit input when set in ForceRoomExportParameters', () => {
309309
SettingsStoreMock.getValue.mockReturnValue({
310310
sizeMb: 10000,
311311
});
@@ -316,7 +316,7 @@ describe('<ExportDialog />', () => {
316316
/**
317317
* 2000mb size limit does not apply when higher limit is configured in config
318318
*/
319-
it('exports when size limit set in ForceRoomExportSettings is larger than 2000', async () => {
319+
it('exports when size limit set in ForceRoomExportParameters is larger than 2000', async () => {
320320
SettingsStoreMock.getValue.mockReturnValue({
321321
sizeMb: 10000,
322322
});
@@ -339,7 +339,7 @@ describe('<ExportDialog />', () => {
339339
expect(getAttachmentsCheckbox(component).props().checked).toEqual(true);
340340
});
341341

342-
it('does not render input when set in ForceRoomExportSettings', () => {
342+
it('does not render input when set in ForceRoomExportParameters', () => {
343343
SettingsStoreMock.getValue.mockReturnValue({
344344
includeAttachments: false,
345345
});
@@ -348,8 +348,8 @@ describe('<ExportDialog />', () => {
348348
});
349349
});
350350

351-
describe('getSafeForceRoomExportSettings()', () => {
352-
const testCases: [string, ForceRoomExportSettings, ForceRoomExportSettings][] = [
351+
describe('getSafeForceRoomExportParameters()', () => {
352+
const testCases: [string, ForceRoomExportParameters, ForceRoomExportParameters][] = [
353353
['setting is falsy', undefined, {}],
354354
['setting is configured to string', 'test' as unknown, {}],
355355
['setting is empty', {}, {}],
@@ -373,7 +373,7 @@ describe('<ExportDialog />', () => {
373373
it.each(testCases)('sanitizes correctly when %s', (_d, setting, expected) => {
374374
SettingsStoreMock.getValue.mockReturnValue(setting);
375375

376-
expect(getSafeForceRoomExportSettings()).toEqual(expected);
376+
expect(getSafeForceRoomExportParameters()).toEqual(expected);
377377
});
378378
});
379379
});

0 commit comments

Comments
 (0)