mirror of
https://github.com/maubot/maubot.git
synced 2024-10-01 01:06:10 -04:00
Only show config editor if plugin type has config
This commit is contained in:
parent
6e8bf60050
commit
1cb2ec5a9b
@ -53,11 +53,12 @@ class PluginInstance:
|
|||||||
client: Client
|
client: Client
|
||||||
plugin: Plugin
|
plugin: Plugin
|
||||||
config: BaseProxyConfig
|
config: BaseProxyConfig
|
||||||
base_cfg: RecursiveDict[CommentedMap]
|
base_cfg: Optional[RecursiveDict[CommentedMap]]
|
||||||
|
base_cfg_str: Optional[str]
|
||||||
inst_db: sql.engine.Engine
|
inst_db: sql.engine.Engine
|
||||||
inst_db_tables: Dict[str, sql.Table]
|
inst_db_tables: Dict[str, sql.Table]
|
||||||
inst_webapp: 'PluginWebApp'
|
inst_webapp: Optional['PluginWebApp']
|
||||||
inst_webapp_url: str
|
inst_webapp_url: Optional[str]
|
||||||
started: bool
|
started: bool
|
||||||
|
|
||||||
def __init__(self, db_instance: DBPlugin):
|
def __init__(self, db_instance: DBPlugin):
|
||||||
@ -73,6 +74,7 @@ class PluginInstance:
|
|||||||
self.inst_webapp = None
|
self.inst_webapp = None
|
||||||
self.inst_webapp_url = None
|
self.inst_webapp_url = None
|
||||||
self.base_cfg = None
|
self.base_cfg = None
|
||||||
|
self.base_cfg_str = None
|
||||||
self.cache[self.id] = self
|
self.cache[self.id] = self
|
||||||
|
|
||||||
def to_dict(self) -> dict:
|
def to_dict(self) -> dict:
|
||||||
@ -83,6 +85,7 @@ class PluginInstance:
|
|||||||
"started": self.started,
|
"started": self.started,
|
||||||
"primary_user": self.primary_user,
|
"primary_user": self.primary_user,
|
||||||
"config": self.db_instance.config,
|
"config": self.db_instance.config,
|
||||||
|
"base_config": self.base_cfg_str,
|
||||||
"database": (self.inst_db is not None
|
"database": (self.inst_db is not None
|
||||||
and self.mb_config["api_features.instance_database"]),
|
and self.mb_config["api_features.instance_database"]),
|
||||||
}
|
}
|
||||||
@ -161,8 +164,12 @@ class PluginInstance:
|
|||||||
try:
|
try:
|
||||||
base = await self.loader.read_file("base-config.yaml")
|
base = await self.loader.read_file("base-config.yaml")
|
||||||
self.base_cfg = RecursiveDict(yaml.load(base.decode("utf-8")), CommentedMap)
|
self.base_cfg = RecursiveDict(yaml.load(base.decode("utf-8")), CommentedMap)
|
||||||
|
buf = io.StringIO()
|
||||||
|
yaml.dump(self.base_cfg._data, buf)
|
||||||
|
self.base_cfg_str = buf.getvalue()
|
||||||
except (FileNotFoundError, KeyError):
|
except (FileNotFoundError, KeyError):
|
||||||
self.base_cfg = None
|
self.base_cfg = None
|
||||||
|
self.base_cfg_str = None
|
||||||
if self.base_cfg:
|
if self.base_cfg:
|
||||||
base_cfg_func = self.base_cfg.clone
|
base_cfg_func = self.base_cfg.clone
|
||||||
else:
|
else:
|
||||||
|
@ -176,7 +176,7 @@ class Instance extends BaseMainView {
|
|||||||
placeholder="xyz.maubot.example" onChange={this.inputChange}/>
|
placeholder="xyz.maubot.example" onChange={this.inputChange}/>
|
||||||
)}
|
)}
|
||||||
</PrefTable>
|
</PrefTable>
|
||||||
{!this.isNew &&
|
{!this.isNew && Boolean(this.props.entry.base_config) &&
|
||||||
<AceEditor mode="yaml" theme="github" onChange={config => this.setState({ config })}
|
<AceEditor mode="yaml" theme="github" onChange={config => this.setState({ config })}
|
||||||
name="config" value={this.state.config}
|
name="config" value={this.state.config}
|
||||||
editorProps={{
|
editorProps={{
|
||||||
|
Loading…
Reference in New Issue
Block a user