swarm-ui: show and toggle an agent's unrestricted internet flag, add it to the create dialog
This commit is contained in:
parent
24beb167d8
commit
10508895c4
1 changed files with 136 additions and 2 deletions
|
|
@ -21,3 +21,27 @@ export function grantSummary(stored: string[] | undefined): string {
|
|||
if (stored.length === 0) return "none";
|
||||
return `${stored.length} granted`;
|
||||
}
|
||||
|
||||
/**
|
||||
* How the panel reads the stored `unrestricted_internet`. An absent value
|
||||
* counts as on, and says "legacy" because the swarm never set it.
|
||||
*/
|
||||
export function internetSummary(stored: boolean | undefined): string {
|
||||
if (stored === undefined) return "unrestricted (legacy)";
|
||||
return stored ? "unrestricted" : "restricted";
|
||||
}
|
||||
|
||||
/**
|
||||
* The `PUT` body that sets the internet flag. A `PUT` without `permissions`
|
||||
* resets a stored list to the default, so the stored list goes along; an
|
||||
* agent with none stored sends the flag alone, which leaves it unset.
|
||||
*/
|
||||
export function internetBody(
|
||||
stored: string[] | undefined,
|
||||
unrestricted: boolean,
|
||||
): { permissions?: string[]; unrestricted_internet: boolean } {
|
||||
return {
|
||||
...(stored === undefined ? {} : { permissions: stored }),
|
||||
unrestricted_internet: unrestricted,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue