mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 22:17:00 +00:00
Hide connectors that need admin setup; they start turned off
A connector's enabled switch is now optional: unset means on when the connector has the server settings it needs, so Google Drive, SharePoint and Confluence start off until their OAuth settings are present, and an admin's explicit switch always wins. Changing only the sharing mode no longer switches a connector on. Members only see connectors they can use. The catalog, Add Source tiles and Add Tool leave out anything turned off or still needing setup, except a connector a member already has a connection to, which stays listed as turned off so it can be managed or removed.
This commit is contained in:
1 parent
324d54ea67
commit
a564dea401
18 files changed
+248
-62
No files matched your search
@@ -198,6 +198,16 @@ class AvailableTools(Resource):
|
||||
def get(self):
|
||||
if not request.decoded_token:
|
||||
return make_response(jsonify({"success": False}), 401)
|
||||
from docsgpt.connectors import service as connection_service
|
||||
|
||||
try:
|
||||
with db_readonly() as conn:
|
||||
policies = connection_service.load_policies(conn)
|
||||
except Exception:
|
||||
# Without the admin's switches, fall back to the defaults (a
|
||||
# connector is on when its server settings are present).
|
||||
current_app.logger.warning("Could not read connector policies", exc_info=True)
|
||||
policies = {}
|
||||
try:
|
||||
tools_metadata = []
|
||||
for tool_name, tool_instance in tool_manager.tools.items():
|
||||
@@ -209,6 +219,10 @@ class AvailableTools(Resource):
|
||||
actions = tool_instance.get_actions_metadata()
|
||||
definition = definition_for_tool(tool_name)
|
||||
if definition is not None:
|
||||
if not (definition.configured and connection_service.connector_is_enabled(
|
||||
policies, definition.key,
|
||||
)):
|
||||
continue
|
||||
group, connector_key = "service", definition.key
|
||||
elif tool_name in _CUSTOM_CONNECTOR_TOOLS:
|
||||
group, connector_key = "custom", _CUSTOM_CONNECTOR_TOOLS[tool_name]
|
||||
|
||||
Reference in new issue
Block a user