Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat-mobile: add feature to add nodes to settings (#5625)
Co-authored-by: paul-boegelsack <paul.boegelsack@iota.org>
- Loading branch information
1 parent
209e937
commit 6a46d8b
Showing
7 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './actions' | ||
export * from './enums' | ||
export * from './interfaces' | ||
export * from './actions' | ||
export * from './routers' | ||
export * from './utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ws/settings/views/networkConfiguration/views/NetworkConfigurationAddUpdateNodeView.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<script lang="typescript"> | ||
import { showAppNotification } from '@auxiliary/notification' | ||
import { localize } from '@core/i18n' | ||
import { addNodeToClientOptions, editNodeInClientOptions, INode } from '@core/network' | ||
import { activeProfile } from '@core/profile' | ||
import { Button, HTMLButtonType, NodeConfigurationForm } from 'shared/components' | ||
const DEFAULT_EMPTY_NODE: INode = { url: '', auth: { username: '', password: '', jwt: '' } } | ||
export let node: INode = DEFAULT_EMPTY_NODE | ||
export let isEditingNode: boolean = false | ||
export let onSuccess: (..._: any[]) => void | ||
const currentNode = node | ||
let nodeConfigurationForm: NodeConfigurationForm | ||
let isBusy = false | ||
async function handleSubmit(): Promise<void> { | ||
try { | ||
isBusy = true | ||
await nodeConfigurationForm.validate({ | ||
validateUrl: true, | ||
checkSameNetwork: true, | ||
uniqueCheck: !isEditingNode, | ||
checkNodeInfo: true, | ||
validateClientOptions: true, | ||
}) | ||
if (isEditingNode) { | ||
await editNodeInClientOptions(currentNode, node) | ||
} else { | ||
await addNodeToClientOptions(node) | ||
} | ||
node = DEFAULT_EMPTY_NODE | ||
onSuccess() | ||
} catch (err) { | ||
if (err.type !== 'validationError') { | ||
showAppNotification({ | ||
type: 'error', | ||
message: localize(err?.error ?? 'error.global.generic'), | ||
}) | ||
} | ||
} finally { | ||
isBusy = false | ||
} | ||
} | ||
</script> | ||
|
||
<div class="flex flex-col justify-between space-y-4 h-full"> | ||
<NodeConfigurationForm | ||
bind:this={nodeConfigurationForm} | ||
bind:node | ||
onSubmit={handleSubmit} | ||
{isBusy} | ||
isDeveloperProfile={$activeProfile.isDeveloperProfile} | ||
/> | ||
<Button | ||
disabled={!node.url || isBusy} | ||
type={HTMLButtonType.Submit} | ||
form="node-configuration-form" | ||
classes="w-full" | ||
{isBusy} | ||
busyMessage={localize(`popups.node.${isEditingNode ? 'updatingNode' : 'addingNode'}`)} | ||
> | ||
{localize(`actions.${isEditingNode ? 'updateNode' : 'addNode'}`)} | ||
</Button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../views/dashboard/drawers/profile/views/settings/views/networkConfiguration/views/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as NetworkConfigurationInitNodeInfoView } from './NetworkConfigurationInitNodeInfoView.svelte' | ||
export { default as NetworkConfigurationAddUpdateNodeView } from './NetworkConfigurationAddUpdateNodeView.svelte' | ||
export { default as NetworkConfigurationInitView } from './NetworkConfigurationInitView.svelte' | ||
export { default as NetworkConfigurationNodeInfoView } from './NetworkConfigurationNodeInfoView.svelte' |