PascalCasing for enums
This commit is contained in:
parent
b91309be82
commit
9771f4d6c4
6 changed files with 36 additions and 36 deletions
|
@ -24,8 +24,8 @@ import Field from "../elements/Field";
|
|||
import StyledRadioGroup from "../elements/StyledRadioGroup";
|
||||
import StyledCheckbox from "../elements/StyledCheckbox";
|
||||
import {
|
||||
exportFormats,
|
||||
exportTypes,
|
||||
ExportFormats,
|
||||
ExportTypes,
|
||||
textForFormat,
|
||||
textForType,
|
||||
} from "../../../utils/exportUtils/exportUtils";
|
||||
|
@ -42,8 +42,8 @@ interface IProps extends IDialogProps {
|
|||
}
|
||||
|
||||
const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
||||
const [exportFormat, setExportFormat] = useState(exportFormats.HTML);
|
||||
const [exportType, setExportType] = useState(exportTypes.TIMELINE);
|
||||
const [exportFormat, setExportFormat] = useState(ExportFormats.HTML);
|
||||
const [exportType, setExportType] = useState(ExportTypes.TIMELINE);
|
||||
const [includeAttachments, setAttachments] = useState(false);
|
||||
const [isExporting, setExporting] = useState(false);
|
||||
const [numberOfMessages, setNumberOfMessages] = useState<number>(100);
|
||||
|
@ -70,31 +70,31 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
maxSize: sizeLimit * 1024 * 1024,
|
||||
};
|
||||
switch (exportFormat) {
|
||||
case exportFormats.HTML:
|
||||
case ExportFormats.HTML:
|
||||
setExporter(
|
||||
new HTMLExporter(
|
||||
room,
|
||||
exportTypes[exportType],
|
||||
ExportTypes[exportType],
|
||||
exportOptions,
|
||||
exportProgressRef,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case exportFormats.JSON:
|
||||
case ExportFormats.JSON:
|
||||
setExporter(
|
||||
new JSONExporter(
|
||||
room,
|
||||
exportTypes[exportType],
|
||||
ExportTypes[exportType],
|
||||
exportOptions,
|
||||
exportProgressRef,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case exportFormats.PLAIN_TEXT:
|
||||
case ExportFormats.PLAIN_TEXT:
|
||||
setExporter(
|
||||
new PlainTextExporter(
|
||||
room,
|
||||
exportTypes[exportType],
|
||||
ExportTypes[exportType],
|
||||
exportOptions,
|
||||
exportProgressRef,
|
||||
),
|
||||
|
@ -114,7 +114,7 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
sizeLimitRef.current.validate({ focused: true });
|
||||
return;
|
||||
}
|
||||
if (exportType === exportTypes.LAST_N_MESSAGES) {
|
||||
if (exportType === ExportTypes.LAST_N_MESSAGES) {
|
||||
const isValidNumberOfMessages =
|
||||
await messageCountRef.current.validate({ focused: false });
|
||||
if (!isValidNumberOfMessages) {
|
||||
|
@ -202,12 +202,12 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
});
|
||||
};
|
||||
|
||||
const exportFormatOptions = Object.keys(exportFormats).map((format) => ({
|
||||
const exportFormatOptions = Object.keys(ExportFormats).map((format) => ({
|
||||
value: format,
|
||||
label: textForFormat(format),
|
||||
}));
|
||||
|
||||
const exportTypeOptions = Object.keys(exportTypes).map((type) => {
|
||||
const exportTypeOptions = Object.keys(ExportTypes).map((type) => {
|
||||
return (
|
||||
<option key={type} value={type}>
|
||||
{ textForType(type) }
|
||||
|
@ -216,7 +216,7 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
});
|
||||
|
||||
let messageCount = null;
|
||||
if (exportType === exportTypes.LAST_N_MESSAGES) {
|
||||
if (exportType === ExportTypes.LAST_N_MESSAGES) {
|
||||
messageCount = (
|
||||
<Field
|
||||
element="input"
|
||||
|
@ -322,7 +322,7 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
<StyledRadioGroup
|
||||
name="exportFormat"
|
||||
value={exportFormat}
|
||||
onChange={(key) => setExportFormat(exportFormats[key])}
|
||||
onChange={(key) => setExportFormat(ExportFormats[key])}
|
||||
definitions={exportFormatOptions}
|
||||
/>
|
||||
|
||||
|
@ -334,7 +334,7 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
element="select"
|
||||
value={exportType}
|
||||
onChange={(e) => {
|
||||
setExportType(exportTypes[e.target.value]);
|
||||
setExportType(ExportTypes[e.target.value]);
|
||||
}}
|
||||
>
|
||||
{ exportTypeOptions }
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import { IExportOptions, exportTypes } from "./exportUtils";
|
||||
import { IExportOptions, ExportTypes } from "./exportUtils";
|
||||
import { decryptFile } from "../DecryptFile";
|
||||
import { mediaFromContent } from "../../customisations/Media";
|
||||
import { formatFullDateNoDay } from "../../DateUtils";
|
||||
|
@ -38,7 +38,7 @@ export default abstract class Exporter {
|
|||
|
||||
protected constructor(
|
||||
protected room: Room,
|
||||
protected exportType: exportTypes,
|
||||
protected exportType: ExportTypes,
|
||||
protected exportOptions: IExportOptions,
|
||||
protected exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
|
@ -114,10 +114,10 @@ export default abstract class Exporter {
|
|||
protected getLimit(): number {
|
||||
let limit: number;
|
||||
switch (this.exportType) {
|
||||
case exportTypes.LAST_N_MESSAGES:
|
||||
case ExportTypes.LAST_N_MESSAGES:
|
||||
limit = this.exportOptions.numberOfMessages;
|
||||
break;
|
||||
case exportTypes.TIMELINE:
|
||||
case ExportTypes.TIMELINE:
|
||||
limit = 40;
|
||||
break;
|
||||
default:
|
||||
|
@ -162,7 +162,7 @@ export default abstract class Exporter {
|
|||
events.push(mxEv);
|
||||
}
|
||||
this.updateProgress(
|
||||
("Fetched " + events.length + " events ") + (this.exportType === exportTypes.LAST_N_MESSAGES
|
||||
("Fetched " + events.length + " events ") + (this.exportType === ExportTypes.LAST_N_MESSAGES
|
||||
? `out of ${this.exportOptions.numberOfMessages}`
|
||||
: "so far"),
|
||||
);
|
||||
|
|
|
@ -33,7 +33,7 @@ import BaseAvatar from "../../components/views/avatars/BaseAvatar";
|
|||
import exportCSS from "./exportCSS";
|
||||
import exportJS from "./exportJS";
|
||||
import exportIcons from "./exportIcons";
|
||||
import { exportTypes } from "./exportUtils";
|
||||
import { ExportTypes } from "./exportUtils";
|
||||
import { IExportOptions } from "./exportUtils";
|
||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default class HTMLExporter extends Exporter {
|
|||
|
||||
constructor(
|
||||
room: Room,
|
||||
exportType: exportTypes,
|
||||
exportType: ExportTypes,
|
||||
exportOptions: IExportOptions,
|
||||
exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import { Room } from "matrix-js-sdk/src/models/room";
|
|||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { formatFullDateNoDay, formatFullDateNoDayNoTime } from "../../DateUtils";
|
||||
import { haveTileForEvent } from "../../components/views/rooms/EventTile";
|
||||
import { exportTypes } from "./exportUtils";
|
||||
import { ExportTypes } from "./exportUtils";
|
||||
import { IExportOptions } from "./exportUtils";
|
||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||
import { MutableRefObject } from "react";
|
||||
|
@ -30,7 +30,7 @@ export default class JSONExporter extends Exporter {
|
|||
|
||||
constructor(
|
||||
room: Room,
|
||||
exportType: exportTypes,
|
||||
exportType: ExportTypes,
|
||||
exportOptions: IExportOptions,
|
||||
exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
|||
import { formatFullDateNoDay } from "../../DateUtils";
|
||||
import { _t } from "../../languageHandler";
|
||||
import { haveTileForEvent } from "../../components/views/rooms/EventTile";
|
||||
import { exportTypes } from "./exportUtils";
|
||||
import { ExportTypes } from "./exportUtils";
|
||||
import { IExportOptions } from "./exportUtils";
|
||||
import { textForEvent } from "../../TextForEvent";
|
||||
import { MutableRefObject } from "react";
|
||||
|
@ -31,7 +31,7 @@ export default class PlainTextExporter extends Exporter {
|
|||
|
||||
constructor(
|
||||
room: Room,
|
||||
exportType: exportTypes,
|
||||
exportType: ExportTypes,
|
||||
exportOptions: IExportOptions,
|
||||
exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
|
|
|
@ -16,37 +16,37 @@ limitations under the License.
|
|||
|
||||
import { _t } from "../../languageHandler";
|
||||
|
||||
export enum exportFormats {
|
||||
export enum ExportFormats {
|
||||
HTML = "HTML",
|
||||
PLAIN_TEXT = "PLAIN_TEXT",
|
||||
JSON = "JSON",
|
||||
}
|
||||
|
||||
export enum exportTypes {
|
||||
export enum ExportTypes {
|
||||
TIMELINE = "TIMELINE",
|
||||
BEGINNING = "BEGINNING",
|
||||
// START_DATE = "START_DATE",
|
||||
LAST_N_MESSAGES = "LAST_N_MESSAGES",
|
||||
// START_DATE = "START_DATE",
|
||||
}
|
||||
|
||||
export const textForFormat = (format: string): string => {
|
||||
switch (format) {
|
||||
case exportFormats.HTML:
|
||||
case ExportFormats.HTML:
|
||||
return _t("HTML");
|
||||
case exportFormats.JSON:
|
||||
case ExportFormats.JSON:
|
||||
return _t("JSON");
|
||||
case exportFormats.PLAIN_TEXT:
|
||||
case ExportFormats.PLAIN_TEXT:
|
||||
return _t("Plain Text");
|
||||
}
|
||||
};
|
||||
|
||||
export const textForType = (type: string): string => {
|
||||
switch (type) {
|
||||
case exportTypes.BEGINNING:
|
||||
case ExportTypes.BEGINNING:
|
||||
return _t("From the beginning");
|
||||
case exportTypes.LAST_N_MESSAGES:
|
||||
case ExportTypes.LAST_N_MESSAGES:
|
||||
return _t("Specify a number of messages");
|
||||
case exportTypes.TIMELINE:
|
||||
case ExportTypes.TIMELINE:
|
||||
return _t("Current Timeline");
|
||||
// case exportTypes.START_DATE:
|
||||
// return _t("From a specific date");
|
||||
|
|
Loading…
Reference in a new issue