aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ui.py
diff options
context:
space:
mode:
authorEyeDeck <eyedeck@gmail.com>2022-09-11 20:00:42 +0000
committerEyeDeck <eyedeck@gmail.com>2022-09-11 20:00:42 +0000
commit29a2933e23e68900bbae741a98439d0c9d6f26f6 (patch)
treec3493d35f1ff517c7b8b7e8a4ccc87abc8894c7f /modules/ui.py
parentcacd14bee89d1c1ff00fb11ebd2c68b407c90f1f (diff)
downloadstable-diffusion-webui-gfx803-29a2933e23e68900bbae741a98439d0c9d6f26f6.tar.gz
stable-diffusion-webui-gfx803-29a2933e23e68900bbae741a98439d0c9d6f26f6.tar.bz2
stable-diffusion-webui-gfx803-29a2933e23e68900bbae741a98439d0c9d6f26f6.zip
Add --hide-ui-dir-config command line flag
Adds `--hide-ui-dir-config` flag to disable editing directory configs from the web UI. This can be set to prevent users from setting the directory to somewhere they shouldn't, for public (or semi-public) interfaces. Directories are still read from config.json, so the server admin can still set them in the web UI and then relaunch with the hide flag, or edit the config manually. Also: - fix OptionInfo `component_args` keyword argument not being read if `component` isn't also set - ensure that hidden settings aren't still read from the web UI (otherwise they could still be changed by tampering with the interface)
Diffstat (limited to 'modules/ui.py')
-rw-r--r--modules/ui.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/modules/ui.py b/modules/ui.py
index b9af2c86..3b7eb9bb 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -661,19 +661,20 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
info = opts.data_labels[key]
t = type(info.default)
+ args = info.component_args() if callable(info.component_args) else info.component_args
+
if info.component is not None:
- args = info.component_args() if callable(info.component_args) else info.component_args
- item = info.component(label=info.label, value=fun, **(args or {}))
+ comp = info.component
elif t == str:
- item = gr.Textbox(label=info.label, value=fun, lines=1)
+ comp = gr.Textbox
elif t == int:
- item = gr.Number(label=info.label, value=fun)
+ comp = gr.Number
elif t == bool:
- item = gr.Checkbox(label=info.label, value=fun)
+ comp = gr.Checkbox
else:
raise Exception(f'bad options item type: {str(t)} for key {key}')
- return item
+ return comp(label=info.label, value=fun, **(args or {}))
components = []
keys = list(opts.data_labels.keys())
@@ -684,6 +685,10 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
up = []
for key, value, comp in zip(opts.data_labels.keys(), args, components):
+ comp_args = opts.data_labels[key].component_args
+ if comp_args and isinstance(comp_args, dict) and comp_args.get('visible') is False:
+ continue
+
opts.data[key] = value
up.append(comp.update(value=value))