mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
- Updated import statements in ComponentSettingsModal, ComponentValuePickerModal, ComponentsModal, DocumentationViewer, RunForm, RunModal, Utils, VariableModal, Workflow, WorkflowStatus, Config, EntityFieldType, and various API utility files to reflect the new directory structure. - Ensured all imports from "Common/Types" are now sourced from "../../../Types" to maintain consistency and improve module resolution.
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import DictionaryForm, { ValueType } from "./Dictionary";
|
|
import Dictionary from "../../../Types/Dictionary";
|
|
import React, { FunctionComponent, ReactElement } from "react";
|
|
|
|
export interface ComponentProps {
|
|
onChange?: undefined | ((value: Dictionary<string>) => void);
|
|
initialValue?: Dictionary<string>;
|
|
keyPlaceholder?: string;
|
|
valuePlaceholder?: string;
|
|
addButtonSuffix?: string;
|
|
}
|
|
|
|
const DictionaryOfStrings: FunctionComponent<ComponentProps> = (
|
|
props: ComponentProps,
|
|
): ReactElement => {
|
|
return (
|
|
// only allow text values
|
|
<DictionaryForm
|
|
{...props}
|
|
valueTypes={[ValueType.Text]}
|
|
onChange={(value: Dictionary<string | number | boolean>) => {
|
|
const stringDict: Dictionary<string> = value as Dictionary<string>;
|
|
|
|
// convert all values to strings
|
|
|
|
for (const key in stringDict) {
|
|
if (stringDict[key]) {
|
|
stringDict[key] = stringDict[key]?.toString() || "";
|
|
}
|
|
}
|
|
|
|
if (props.onChange) {
|
|
props.onChange(stringDict);
|
|
}
|
|
}}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default DictionaryOfStrings;
|