diff --git a/src/components/FormElements/AssetPicker.tsx b/src/components/FormElements/AssetPicker.tsx index ee176085..b754da65 100644 --- a/src/components/FormElements/AssetPicker.tsx +++ b/src/components/FormElements/AssetPicker.tsx @@ -39,6 +39,7 @@ type AssetPickerProps = { includeNative?: boolean; includeLiquidityPoolShares?: boolean; includeSingleLiquidityPoolShare?: boolean; + disabled?: boolean; }; export const AssetPicker = ({ @@ -54,6 +55,7 @@ export const AssetPicker = ({ includeNative = true, includeLiquidityPoolShares, includeSingleLiquidityPoolShare, + disabled, }: AssetPickerProps) => { let options: AssetObject[] = []; @@ -168,6 +170,7 @@ export const AssetPicker = ({ onChange={(e: React.ChangeEvent) => { onChange({ ...poolShareValue, pool_share: e.target.value }); }} + disabled={disabled} /> ); } @@ -192,6 +195,7 @@ export const AssetPicker = ({ }, error: assetError?.issuer || "", }} + disabled={disabled} /> ); }; @@ -217,6 +221,18 @@ export const AssetPicker = ({ }} options={options} fitContent={fitContent} + disabledOptions={ + disabled + ? [ + "native", + "credit_alphanum4", + "credit_alphanum12", + "pool_share", + "liquidity_pool_shares", + "issued", + ] + : [] + } /> ) => void; }; + disabled?: boolean; }; -const AssetPickerFields = ({ id, code, issuer }: AssetPickerFieldsProps) => ( +const AssetPickerFields = ({ + id, + code, + issuer, + disabled, +}: AssetPickerFieldsProps) => (
( value={code.value} onChange={code.onChange} error={code.error} + disabled={disabled} /> ( value={issuer.value} onChange={issuer.onChange} error={issuer.error} + disabled={disabled} />
); diff --git a/src/components/FormElements/ConfigSettingIdPicker.tsx b/src/components/FormElements/ConfigSettingIdPicker.tsx index e9661b32..e88c5762 100644 --- a/src/components/FormElements/ConfigSettingIdPicker.tsx +++ b/src/components/FormElements/ConfigSettingIdPicker.tsx @@ -9,12 +9,14 @@ type ConfigSettingIdPickerProps = { value: string | undefined; onChange: (value: ConfigSettingIdType | undefined) => void; error: string | undefined; + disabled?: boolean; }; export const ConfigSettingIdPicker = ({ id, value, onChange, + disabled, }: ConfigSettingIdPickerProps) => { const configSettingType: { id: ConfigSettingIdType; label: string }[] = [ { @@ -91,6 +93,7 @@ export const ConfigSettingIdPicker = ({ onChange(undefined); } }} + disabled={disabled} > diff --git a/src/components/FormElements/LiquidityPoolShares.tsx b/src/components/FormElements/LiquidityPoolShares.tsx index 6706265d..eb25ca6b 100644 --- a/src/components/FormElements/LiquidityPoolShares.tsx +++ b/src/components/FormElements/LiquidityPoolShares.tsx @@ -13,6 +13,7 @@ type LiquidityPoolSharesProps = { value: AssetPoolShareObjectValue; error: AssetPoolShareError | undefined; onChange: (val: AssetPoolShareObjectValue | undefined) => void; + disabled?: boolean; }; export const LiquidityPoolShares = ({ @@ -20,6 +21,7 @@ export const LiquidityPoolShares = ({ value, error, onChange, + disabled, }: LiquidityPoolSharesProps) => { const getAssetValue = ( val: @@ -52,6 +54,7 @@ export const LiquidityPoolShares = ({ onChange={(val) => { onChange({ ...value, asset_a: getAssetValue(val) }); }} + disabled={disabled} /> { onChange({ ...value, asset_b: getAssetValue(val) }); }} + disabled={disabled} /> ); diff --git a/src/components/FormElements/PubKeyPicker.tsx b/src/components/FormElements/PubKeyPicker.tsx index e76c2133..a77f136a 100644 --- a/src/components/FormElements/PubKeyPicker.tsx +++ b/src/components/FormElements/PubKeyPicker.tsx @@ -8,6 +8,7 @@ interface PubKeyPickerProps extends Omit { labelSuffix?: string | React.ReactNode; placeholder?: string; readOnly?: boolean; + disabled?: boolean; value: string; error: string | undefined; onChange?: (e: React.ChangeEvent) => void; @@ -22,6 +23,7 @@ export const PubKeyPicker = ({ value, error, readOnly, + disabled, onChange, ...props }: PubKeyPickerProps) => ( @@ -34,6 +36,7 @@ export const PubKeyPicker = ({ value={value} error={error} readOnly={readOnly} + disabled={disabled} onChange={onChange} {...props} /> diff --git a/src/components/FormElements/TextPicker.tsx b/src/components/FormElements/TextPicker.tsx index 439665f6..bc839f11 100644 --- a/src/components/FormElements/TextPicker.tsx +++ b/src/components/FormElements/TextPicker.tsx @@ -10,6 +10,7 @@ interface TextPickerProps extends Omit { placeholder?: string; error?: string | undefined; readOnly?: boolean; + disabled?: boolean; autocomplete?: React.HTMLInputAutoCompleteAttribute; onChange?: (e: React.ChangeEvent) => void; } @@ -23,6 +24,7 @@ export const TextPicker = ({ error, onChange, readOnly, + disabled, autocomplete, ...props }: TextPickerProps) => ( @@ -35,6 +37,7 @@ export const TextPicker = ({ error={error} onChange={onChange} readOnly={readOnly} + disabled={disabled} autoComplete={autocomplete} {...props} /> diff --git a/src/components/FormElements/XdrLedgerKeyPicker.tsx b/src/components/FormElements/XdrLedgerKeyPicker.tsx index 2064ab69..9640ff6f 100644 --- a/src/components/FormElements/XdrLedgerKeyPicker.tsx +++ b/src/components/FormElements/XdrLedgerKeyPicker.tsx @@ -109,6 +109,7 @@ export const XdrLedgerKeyPicker = ({ const [selectedLedgerKey, setSelectedLedgerKey] = useState(null); + const [isXdrInputActive, setIsXdrInputActive] = useState(true); const [formError, setFormError] = useState({}); const [ledgerKeyXdrJsonString, setLedgerKeyJsonString] = useState(""); const [ledgerKeyXdrError, setLedgerKeyXdrError] = useState(""); @@ -347,6 +348,7 @@ export const XdrLedgerKeyPicker = ({ ); }, isRequired: true, + disabled: isXdrInputActive, }); } @@ -358,6 +360,7 @@ export const XdrLedgerKeyPicker = ({ handleChange(selectedConfigSetting, selectedConfigSetting); }, isRequired: true, + disabled: isXdrInputActive, }); } @@ -368,6 +371,7 @@ export const XdrLedgerKeyPicker = ({ handleChange(e.target.value, e.target.value); }, isRequired: true, + disabled: isXdrInputActive, }); } return null; @@ -375,7 +379,7 @@ export const XdrLedgerKeyPicker = ({ }; return ( - + - - <>{renderLedgerKeyTemplate()} - <>{rightElement} + Switch input + + + + + <>{renderLedgerKeyTemplate()} + <>{rightElement} + ); }; diff --git a/src/components/formComponentTemplateEndpoints.tsx b/src/components/formComponentTemplateEndpoints.tsx index 44aa1495..a8a730e6 100644 --- a/src/components/formComponentTemplateEndpoints.tsx +++ b/src/components/formComponentTemplateEndpoints.tsx @@ -32,6 +32,7 @@ type TemplateRenderProps = { error: string | undefined; onChange: (val: any) => void; isRequired?: boolean; + disabled?: boolean; }; type TemplateRenderAssetProps = { @@ -45,6 +46,7 @@ type TemplateRenderAssetProps = { | undefined, ) => void; isRequired?: boolean; + disabled?: boolean; }; type TemplateRenderAssetMultiProps = { @@ -96,6 +98,7 @@ export const formComponentTemplateEndpoints = ( value={templ.value || ""} error={templ.error} onChange={templ.onChange} + disabled={templ.disabled} /> ), validate: validate.getPublicKeyError, @@ -116,6 +119,7 @@ export const formComponentTemplateEndpoints = ( includeSingleLiquidityPoolShare={ custom?.includeSingleLiquidityPoolShare } + disabled={templ.disabled} /> ), validate: validate.getAssetError, @@ -131,6 +135,7 @@ export const formComponentTemplateEndpoints = ( value={templ.value || ""} error={templ.error} onChange={templ.onChange} + disabled={templ.disabled} /> ), validate: validate.getAssetCodeError, @@ -146,6 +151,7 @@ export const formComponentTemplateEndpoints = ( value={templ.value || ""} error={templ.error} onChange={templ.onChange} + disabled={templ.disabled} /> ), validate: validate.getPublicKeyError, @@ -213,6 +219,7 @@ export const formComponentTemplateEndpoints = ( value={templ.value || ""} error={templ.error} onChange={templ.onChange} + disabled={templ.disabled} /> ), validate: null, @@ -241,6 +248,7 @@ export const formComponentTemplateEndpoints = ( value={templ.value || ""} error={templ.error} onChange={templ?.onChange} + disabled={templ.disabled} /> ), validate: null, @@ -251,6 +259,7 @@ export const formComponentTemplateEndpoints = ( value: string | undefined; error: string | undefined; onChange: (val: any) => void; + disabled?: boolean; }) => ( ), validate: validate.getContractIdError, @@ -301,6 +311,7 @@ export const formComponentTemplateEndpoints = ( value: string | undefined; error: string | undefined; onChange: (val: any) => void; + disabled?: boolean; }) => ( ), validate: null, @@ -397,6 +409,7 @@ export const formComponentTemplateEndpoints = ( value: string | undefined; error: string | undefined; onChange: (val: any) => void; + disabled?: boolean; }) => (