3 Commits

Author SHA1 Message Date
Eric Tuvesson
9433cde97f fix: Allow empty description 2024-03-26 22:04:41 +01:00
Eric Tuvesson
fcf3a740e7 fix: save appId and url 2024-03-25 09:44:17 +01:00
Eric Tuvesson
985d609f03 feat: Cloud Services, allow changing all fields 2024-03-25 09:21:59 +01:00
3 changed files with 31 additions and 8 deletions

View File

@@ -52,9 +52,11 @@ export class ExternalCloudService {
const broker = brokers.find((x) => x.id === options.id); const broker = brokers.find((x) => x.id === options.id);
if (!broker) return false; if (!broker) return false;
if (options.name) broker.name = options.name; if (typeof options.name !== undefined) broker.name = options.name;
if (options.description) broker.description = options.description; if (typeof options.description !== undefined) broker.description = options.description;
if (options.masterKey) broker.masterKey = options.masterKey; if (typeof options.appId !== undefined) broker.appId = options.appId;
if (typeof options.masterKey !== undefined) broker.masterKey = options.masterKey;
if (typeof options.url !== undefined) broker.endpoint = options.url;
await JSONStorage.set('externalBrokers', { brokers }); await JSONStorage.set('externalBrokers', { brokers });

View File

@@ -14,7 +14,9 @@ export type UpdateEnvironmentRequest = {
id: string; id: string;
name: string | undefined; name: string | undefined;
description: string | undefined; description: string | undefined;
appId: string | undefined;
masterKey: string | undefined; masterKey: string | undefined;
url: string | undefined;
}; };
export type CreateEnvironment = { export type CreateEnvironment = {

View File

@@ -42,16 +42,31 @@ function AsSelfHosted({
}: CloudServiceModalProps) { }: CloudServiceModalProps) {
const [name, setName] = useState(environment.name); const [name, setName] = useState(environment.name);
const [description, setDescription] = useState(environment.description); const [description, setDescription] = useState(environment.description);
const [appId, setAppId] = useState(environment.appId);
const [url, setUrl] = useState(environment.url);
const [showMasterKey, setShowMasterKey] = useState(false); const [showMasterKey, setShowMasterKey] = useState(false);
const [masterKey, setMasterKey] = useState(environment.masterKey); const [masterKey, setMasterKey] = useState(environment.masterKey);
function update() { function update() {
// Early return if none of the values changed
if (
name === environment.name &&
description === environment.description &&
appId === environment.appId &&
masterKey === environment.masterKey &&
url === environment.url
) {
return;
}
CloudService.instance.backend CloudService.instance.backend
.update({ .update({
id: environment.id, id: environment.id,
name, name,
description, description,
masterKey appId,
masterKey,
url
}) })
.then(() => { .then(() => {
ToastLayer.showSuccess(`Updated Cloud Service`); ToastLayer.showSuccess(`Updated Cloud Service`);
@@ -86,12 +101,14 @@ function AsSelfHosted({
<Columns hasXGap={4} layoutString="1 1"> <Columns hasXGap={4} layoutString="1 1">
<TextInput <TextInput
value={environment.appId} value={appId}
variant={TextInputVariant.InModal} variant={TextInputVariant.InModal}
label="App Id" label="App Id"
isReadonly
isCopyable isCopyable
UNSAFE_style={{ flex: 1 }} UNSAFE_style={{ flex: 1 }}
onChange={(e) => setAppId(e.target.value)}
onBlur={update}
onEnter={update}
/> />
<VStack> <VStack>
<TextInput <TextInput
@@ -125,11 +142,13 @@ function AsSelfHosted({
</Columns> </Columns>
<TextInput <TextInput
value={environment.url} value={url}
variant={TextInputVariant.InModal} variant={TextInputVariant.InModal}
label="Endpoint" label="Endpoint"
isReadonly
isCopyable isCopyable
onChange={(e) => setUrl(e.target.value)}
onBlur={update}
onEnter={update}
/> />
</VStack> </VStack>
</Box> </Box>