Skip to content

🙌 OpenHands: AI-Driven Development

feat(jira-dc): fix the integration panel so members get guidance, not the admin setup form (#15040)

Alona59834684e87c
diff --git a/enterprise/integrations/jira_dc/jira_dc_conversation_secret_enricher.py b/enterprise/integrations/jira_dc/jira_dc_conversation_secret_enricher.py
index 7349ad2ee7..5d1023364f 100644
--- a/enterprise/integrations/jira_dc/jira_dc_conversation_secret_enricher.py
+++ b/enterprise/integrations/jira_dc/jira_dc_conversation_secret_enricher.py
@@ -36,6 +36,33 @@ JIRA_DC_SECRET_HINT = """You have credentialed access to the Jira Data Center RE
The token value is supplied only as a sandbox secret/environment variable. Never echo or log the value of $JIRA_DC_TOKEN."""
+def _email_mode_hint(host: str) -> str:
+ # Hedged on purpose: the user may have their own Jira token/MCP tools, so tell
+ # the agent to use those if present and only otherwise list the enablement
+ # options -- don't assert "no access", which would be wrong in that case.
+ # `host` comes from the active workspace, not JIRA_DC_BASE_URL, which the
+ # chart only sets in OAuth mode.
+ return (
+ f'Jira Data Center for this workspace is at {host}, but the admin has '
+ 'enabled email-linking mode so no Jira token is automatically provided '
+ 'to conversations. If the user asks you to read or query Jira Data '
+ 'Center, check to see if you have an available Jira token (e.g. a Secret) '
+ 'or Jira MCP tools in your environment; otherwise, tell the user how to '
+ 'enable access: an admin can enable OAuth mode in the OHE Admin Config '
+ 'and redeploy, or the user can add their Jira API token as a Secret, or '
+ 'connect a Jira Data Center MCP server (Settings → MCP).'
+ )
+
+
+def _append_email_mode_hint(system_message_suffix: str | None, host: str) -> str:
+ hint = _email_mode_hint(host)
+ if not system_message_suffix:
+ return hint
+ if 'Jira Data Center MCP server' in system_message_suffix:
+ return system_message_suffix
+ return f'{system_message_suffix}\n\n{hint}'
+
+
def _workspace_matches_configured_jira_dc_host(workspace_name: str) -> bool:
configured_host = urlparse(JIRA_DC_BASE_URL).hostname
if not configured_host:
@@ -145,6 +172,17 @@ class JiraDcConversationSecretEnricher(ConversationSecretEnricher):
del user
if not JIRA_DC_ENABLE_OAUTH:
+ # Email mode: no per-user token to inject. When a connection is set up
+ # for the caller's org, tell the agent how to point the user at
+ # enabling live access instead of failing silently.
+ store = JiraDcIntegrationStore.get_instance()
+ workspace = await store.get_active_workspace()
+ if workspace and await _workspace_matches_context(workspace, user_context):
+ return ConversationSecretEnrichment(
+ system_message_suffix=_append_email_mode_hint(
+ system_message_suffix, workspace.name
+ )
+ )
return ConversationSecretEnrichment(
system_message_suffix=system_message_suffix
)
diff --git a/enterprise/server/auth/authorization.py b/enterprise/server/auth/authorization.py
index b773148196..ab63108592 100644
--- a/enterprise/server/auth/authorization.py
+++ b/enterprise/server/auth/authorization.py
@@ -56,6 +56,9 @@ class Permission(str, Enum):
# Integrations
MANAGE_INTEGRATIONS = 'manage_integrations'
+ # Setting up an integration connection (admin/owner) vs the member-level
+ # MANAGE_INTEGRATIONS (linking/using an already-configured integration).
+ MANAGE_INTEGRATION_PROVIDERS = 'manage_integration_providers'
# Application Settings
MANAGE_APPLICATION_SETTINGS = 'manage_application_settings'
@@ -164,6 +167,8 @@ ROLE_PERMISSIONS: dict[RoleName, frozenset[Permission]] = {
Permission.PROVISION_USER,
# Organization Conversations (Admin/Owner only)
Permission.VIEW_ORG_CONVERSATIONS,
+ # Integration provider setup (Admin/Owner only)
+ Permission.MANAGE_INTEGRATION_PROVIDERS,
]
),
RoleName.ADMIN: frozenset(
@@ -193,6 +198,8 @@ ROLE_PERMISSIONS: dict[RoleName, frozenset[Permission]] = {
Permission.PROVISION_USER,
# Organization Conversations (Admin/Owner only)
Permission.VIEW_ORG_CONVERSATIONS,
+ # Integration provider setup (Admin/Owner only)
+ Permission.MANAGE_INTEGRATION_PROVIDERS,
]
),
RoleName.MEMBER: frozenset(
diff --git a/enterprise/server/routes/integration/jira_dc.py b/enterprise/server/routes/integration/jira_dc.py
index b5215d0e04..b2c47c44b7 100644
--- a/enterprise/server/routes/integration/jira_dc.py
+++ b/enterprise/server/routes/integration/jira_dc.py
@@ -32,6 +32,7 @@ from integrations.jira_dc.jira_dc_user_token import (
from integrations.models import Message, SourceType
from jwt import InvalidTokenError
from pydantic import BaseModel, Field, field_validator
+from server.auth.authorization import Permission, require_permission
from server.auth.constants import (
AUTOMATION_EVENT_FORWARDING_ENABLED,
JIRA_DC_BASE_URL,
@@ -43,6 +44,7 @@ from server.auth.saas_user_auth import SaasUserAuth
from server.auth.token_manager import TokenManager
from server.constants import WEB_HOST
from server.services.automation_event_service import AutomationEventService
+from storage.jira_dc_integration_store import workspace_visible_to_org
from storage.redis import get_redis_client
from openhands.app_server.config import depends_jwt_service
@@ -191,6 +193,14 @@ class JiraDcValidateWorkspaceResponse(BaseModel):
message: str
+class JiraDcInstanceStatusResponse(BaseModel):
+ # Whether the install's Jira DC connection is set up, and the host to link
+ # to. Lets a not-yet-linked member see "link your account" vs "ask an admin
+ # to set it up".
+ configured: bool
+ host: str | None = None
+
+
jira_dc_integration_router = APIRouter(prefix='/integration/jira-dc')
token_manager = TokenManager()
jira_dc_manager = JiraDcManager(token_manager)
@@ -565,9 +575,16 @@ def _resolve_submitted_service_account(
@jira_dc_integration_router.post('/workspaces')
async def create_jira_dc_workspace(
- request: Request, workspace_data: JiraDcWorkspaceCreate
+ request: Request,
+ workspace_data: JiraDcWorkspaceCreate,
+ _: str = Depends(require_permission(Permission.MANAGE_INTEGRATION_PROVIDERS)),
):
- """Create a new Jira DC workspace registration."""
+ """Create a new Jira DC workspace registration.
+
+ Setting up the instance connection (server, service account, webhook) is an
+ admin/owner action; ordinary members link their own account via
+ ``POST /workspaces/link`` instead.
+ """
try:
service_account_config_error = get_jira_dc_service_account_config_error()
if service_account_config_error:
@@ -1120,6 +1137,26 @@ async def jira_dc_callback(request: Request, code: str, state: str):
raise HTTPException(status_code=400, detail='Invalid operation type')
+@jira_dc_integration_router.get('/workspaces/status')
+async def get_jira_dc_instance_status(
+ request: Request,
+) -> JiraDcInstanceStatusResponse:
+ """Whether the install's Jira DC connection is set up, and its host.
+
+ Lets the settings UI tell a not-yet-linked member "the integration exists,
+ link your account" (vs "ask an admin to set it up") and supplies the host
+ the per-user link call needs. Scoped to the caller's org so a user in one org
+ can't see or link another org's Jira DC connection (install-wide workspaces
+ -- no org, or personal-org-stamped -- stay visible to everyone).
+ """
+ user_auth = cast(SaasUserAuth, await get_user_auth(request))
+ effective_org_id = await user_auth.get_effective_org_id()
+ workspace = await jira_dc_manager.integration_store.get_active_workspace()
+ if workspace and workspace_visible_to_org(workspace, effective_org_id):
+ return JiraDcInstanceStatusResponse(configured=True, host=workspace.name)
+ return JiraDcInstanceStatusResponse(configured=False, host=None)
+
+
@jira_dc_integration_router.get(
'/workspaces/link',
response_model=JiraDcUserResponse,
diff --git a/enterprise/storage/jira_dc_integration_store.py b/enterprise/storage/jira_dc_integration_store.py
index 0c072d8c2e..1b44ae96a5 100644
--- a/enterprise/storage/jira_dc_integration_store.py
+++ b/enterprise/storage/jira_dc_integration_store.py
@@ -14,6 +14,24 @@ from storage.jira_dc_workspace import JiraDcWorkspace
from openhands.app_server.utils.logger import openhands_logger as logger
+def workspace_visible_to_org(
+ workspace: JiraDcWorkspace, effective_org_id: UUID | None
+) -> bool:
+ """Whether an active Jira DC workspace should be visible to a user in the
+ given org. Install-wide when it has no org or is stamped with its creator's
+ personal org (org_id == admin_user_id); otherwise scoped to that org. Mirrors
+ the enricher's ``_workspace_matches_context`` so status/hint and per-user
+ token injection agree on who can see/link an org's Jira DC connection.
+ """
+ org_id = getattr(workspace, 'org_id', None)
+ if org_id is None:
+ return True
+ admin_user_id = getattr(workspace, 'admin_user_id', None)
+ if admin_user_id is not None and str(org_id) == str(admin_user_id):
+ return True
+ return effective_org_id is not None and str(org_id) == str(effective_org_id)
+
+
@dataclass
class JiraDcIntegrationStore:
async def create_workspace(
@@ -129,6 +147,22 @@ class JiraDcIntegrationStore:
)
return result.scalar_one_or_none()
+ async def get_active_workspace(self) -> Optional[JiraDcWorkspace]:
+ """Return the install's active Jira DC workspace, if any.
+
+ Jira DC is single-server, so there is at most one active workspace; this
+ lets a not-yet-linked user discover that the integration is set up (and
+ which host to link to) without knowing its exact name.
+ """
+ async with a_session_maker() as session:
+ result = await session.execute(
+ select(JiraDcWorkspace)
+ .where(JiraDcWorkspace.status == 'active')
+ .order_by(JiraDcWorkspace.id)
+ .limit(1)
+ )
+ return result.scalar_one_or_none()
+
async def get_user_by_active_workspace(
self, keycloak_user_id: str
) -> Optional[JiraDcUser]:
diff --git a/enterprise/tests/unit/integrations/jira_dc/test_jira_dc_conversation_secret_enricher.py b/enterprise/tests/unit/integrations/jira_dc/test_jira_dc_conversation_secret_enricher.py
index 82f5927eea..21a75d5e6e 100644
--- a/enterprise/tests/unit/integrations/jira_dc/test_jira_dc_conversation_secret_enricher.py
+++ b/enterprise/tests/unit/integrations/jira_dc/test_jira_dc_conversation_secret_enricher.py
@@ -308,3 +308,112 @@ async def test_enricher_injects_for_null_org_workspace():
)
assert 'JIRA_DC_TOKEN' in enrichment.secrets
+
+
+async def test_enricher_email_mode_hint_when_configured():
+ # Email mode: no token, but a set-up connection => tell the agent how to
+ # point the user at enabling live access (OAuth / Secret / MCP).
+ store = MagicMock()
+ store.get_active_workspace = AsyncMock(
+ return_value=SimpleNamespace(
+ id=1, name='jira.example.com', status='active', org_id=None
+ )
+ )
+ with (
+ patch(
+ 'integrations.jira_dc.jira_dc_conversation_secret_enricher.JIRA_DC_ENABLE_OAUTH',
+ False,
+ ),
+ patch(
+ 'integrations.jira_dc.jira_dc_conversation_secret_enricher.JiraDcIntegrationStore.get_instance',
+ return_value=store,
+ ),
+ ):
+ enrichment = await JiraDcConversationSecretEnricher().enrich(
+ user_context=FakeUserContext(),
+ user=MagicMock(id='kc-user'),
+ trigger=ConversationTrigger.SLACK,
+ system_message_suffix='Existing instructions.',
+ web_url=None,
+ jwt_service=MagicMock(),
+ access_token_hard_timeout=timedelta(minutes=5),
+ )
+
+ assert enrichment.secrets == {}
+ suffix = enrichment.system_message_suffix or ''
+ assert 'Existing instructions.' in suffix
+ # Host comes from the active workspace, not the (email-mode-empty) env var.
+ assert 'jira.example.com' in suffix
+ # Hedged: use a token/MCP tools if available, otherwise list the options.
+ assert 'available Jira token' in suffix
+ assert 'Jira MCP tools' in suffix
+ assert 'OAuth mode' in suffix
+ assert 'as a Secret' in suffix
+ assert 'MCP server' in suffix
+
+
+async def test_enricher_email_mode_no_hint_for_other_org():
+ # Active workspace belongs to a different team org => not visible here.
+ store = MagicMock()
+ store.get_active_workspace = AsyncMock(
+ return_value=SimpleNamespace(
+ id=1,
+ name='jira.example.com',
+ status='active',
+ org_id=OTHER_ORG_ID,
+ admin_user_id='some-other-admin',
+ )
+ )
+ with (
+ patch(
+ 'integrations.jira_dc.jira_dc_conversation_secret_enricher.JIRA_DC_ENABLE_OAUTH',
+ False,
+ ),
+ patch(
+ 'integrations.jira_dc.jira_dc_conversation_secret_enricher.JiraDcIntegrationStore.get_instance',
+ return_value=store,
+ ),
+ ):
+ enrichment = await JiraDcConversationSecretEnricher().enrich(
+ user_context=FakeUserContext(org_id=ORG_ID),
+ user=MagicMock(id='kc-user'),
+ trigger=ConversationTrigger.SLACK,
+ system_message_suffix='Existing instructions.',
+ web_url=None,
+ jwt_service=MagicMock(),
+ access_token_hard_timeout=timedelta(minutes=5),
+ )
+
+ assert enrichment.secrets == {}
+ assert enrichment.system_message_suffix == 'Existing instructions.'
+
+
+async def test_enricher_email_mode_no_hint_when_not_configured():
+ # Email mode with no active workspace => nothing set up, so no hint.
+ store = MagicMock()
+ store.get_active_workspace = AsyncMock(return_value=None)
+ with (
+ patch(
+ 'integrations.jira_dc.jira_dc_conversation_secret_enricher.JIRA_DC_ENABLE_OAUTH',
+ False,
+ ),
+ patch(
+ 'integrations.jira_dc.jira_dc_conversation_secret_enricher.JiraDcIntegrationStore.get_instance',
+ return_value=store,
+ ),
+ ):
+ enrichment = await JiraDcConversationSecretEnricher().enrich(
+ user_context=FakeUserContext(),
+ user=MagicMock(id='kc-user'),
+ trigger=ConversationTrigger.SLACK,
+ system_message_suffix='Existing instructions.',
+ web_url=None,
+ jwt_service=MagicMock(),
+ access_token_hard_timeout=timedelta(minutes=5),
+ )
+
+ assert enrichment.secrets == {}
+ assert enrichment.system_message_suffix == 'Existing instructions.'
diff --git a/enterprise/tests/unit/server/routes/test_jira_dc_integration_routes.py b/enterprise/tests/unit/server/routes/test_jira_dc_integration_routes.py
index 66aa2eb326..455bfb5177 100644
--- a/enterprise/tests/unit/server/routes/test_jira_dc_integration_routes.py
+++ b/enterprise/tests/unit/server/routes/test_jira_dc_integration_routes.py
@@ -22,6 +22,7 @@ from server.routes.integration.jira_dc import (
create_jira_dc_workspace,
create_workspace_link,
get_current_workspace_link,
+ get_jira_dc_instance_status,
get_jira_dc_secret_token,
jira_dc_callback,
jira_dc_connection_events,
@@ -2216,3 +2217,56 @@ async def test_callback_workspace_link_persists_tokens(
assert kwargs['keycloak_user_id'] == 'user2'
assert kwargs['workspace_id'] == 9
assert kwargs['encrypted_access_token'] == 'enc(at)'
+
+
+@patch('server.routes.integration.jira_dc.get_user_auth')
+@patch('server.routes.integration.jira_dc.jira_dc_manager', new_callable=AsyncMock)
+async def test_get_jira_dc_instance_status_configured(
+ mock_manager, mock_get_auth, mock_request, mock_user_auth
+):
+ mock_get_auth.return_value = mock_user_auth
+ # org_id=None => install-wide, visible to everyone.
+ mock_workspace = MagicMock(status='active', org_id=None)
+ mock_workspace.name = 'jira.example.com'
+ mock_manager.integration_store.get_active_workspace.return_value = mock_workspace
+
+ response = await get_jira_dc_instance_status(mock_request)
+ assert response.configured is True
+ assert response.host == 'jira.example.com'
+
+
+@patch('server.routes.integration.jira_dc.get_user_auth')
+@patch('server.routes.integration.jira_dc.jira_dc_manager', new_callable=AsyncMock)
+async def test_get_jira_dc_instance_status_hidden_for_other_org(
+ mock_manager, mock_get_auth, mock_request, mock_user_auth
+):
+ # A workspace stamped with a different team org must not leak to this user
+ # (mock_user_auth's effective org is ...123).
+ mock_get_auth.return_value = mock_user_auth
+ mock_workspace = MagicMock(
+ status='active',
+ org_id=uuid.UUID('00000000-0000-0000-0000-000000000999'),
+ admin_user_id='some-other-admin',
+ )
+ mock_workspace.name = 'jira.other-org.com'
+ mock_manager.integration_store.get_active_workspace.return_value = mock_workspace
+
+ response = await get_jira_dc_instance_status(mock_request)
+ assert response.configured is False
+ assert response.host is None
+
+
+@patch('server.routes.integration.jira_dc.get_user_auth')
+@patch('server.routes.integration.jira_dc.jira_dc_manager', new_callable=AsyncMock)
+async def test_get_jira_dc_instance_status_not_configured(
+ mock_manager, mock_get_auth, mock_request, mock_user_auth
+):
+ mock_get_auth.return_value = mock_user_auth
+ mock_manager.integration_store.get_active_workspace.return_value = None
+
+ response = await get_jira_dc_instance_status(mock_request)
+ assert response.configured is False
+ assert response.host is None
diff --git a/enterprise/tests/unit/test_authorization.py b/enterprise/tests/unit/test_authorization.py
index 78e04ae5dd..8ff5075fdb 100644
--- a/enterprise/tests/unit/test_authorization.py
+++ b/enterprise/tests/unit/test_authorization.py
@@ -41,6 +41,10 @@ class TestPermission:
assert Permission.MANAGE_SECRETS.value == 'manage_secrets'
assert Permission.MANAGE_MCP.value == 'manage_mcp'
assert Permission.MANAGE_INTEGRATIONS.value == 'manage_integrations'
+ assert (
+ Permission.MANAGE_INTEGRATION_PROVIDERS.value
+ == 'manage_integration_providers'
+ )
assert (
Permission.MANAGE_APPLICATION_SETTINGS.value
== 'manage_application_settings'
@@ -151,6 +155,7 @@ class TestRolePermissions:
assert Permission.DELETE_ORGANIZATION in owner_perms
assert Permission.MANAGE_AUTOMATIONS in owner_perms
assert Permission.VIEW_ORG_CONVERSATIONS in owner_perms
+ assert Permission.MANAGE_INTEGRATION_PROVIDERS in owner_perms
def test_admin_has_admin_permissions(self):
"""
@@ -170,6 +175,7 @@ class TestRolePermissions:
assert Permission.CHANGE_USER_ROLE_ADMIN in admin_perms
assert Permission.MANAGE_AUTOMATIONS in admin_perms
assert Permission.VIEW_ORG_CONVERSATIONS in admin_perms
+ assert Permission.MANAGE_INTEGRATION_PROVIDERS in admin_perms
# Admin should NOT have owner-only permissions
assert Permission.CHANGE_USER_ROLE_OWNER not in admin_perms
assert Permission.CHANGE_ORGANIZATION_NAME not in admin_perms
@@ -193,6 +199,7 @@ class TestRolePermissions:
assert Permission.VIEW_ORG_SETTINGS in member_perms
# Member should NOT have admin/owner permissions
assert Permission.EDIT_LLM_SETTINGS not in member_perms
+ assert Permission.MANAGE_INTEGRATION_PROVIDERS not in member_perms
assert Permission.VIEW_BILLING not in member_perms
assert Permission.ADD_CREDITS not in member_perms
assert Permission.INVITE_USER_TO_ORGANIZATION not in member_perms
diff --git a/frontend/src/components/features/settings/project-management/jira-dc-integration-panel.tsx b/frontend/src/components/features/settings/project-management/jira-dc-integration-panel.tsx
index 207a37af3d..dfbe39abd0 100644
--- a/frontend/src/components/features/settings/project-management/jira-dc-integration-panel.tsx
+++ b/frontend/src/components/features/settings/project-management/jira-dc-integration-panel.tsx
@@ -17,6 +17,9 @@ import { useLinkIntegration } from "#/hooks/mutation/use-link-integration";
import { useUnlinkIntegration } from "#/hooks/mutation/use-unlink-integration";
import { useUpdateJiraDcWorkspaceStatus } from "#/hooks/mutation/use-update-jira-dc-workspace-status";
import { useValidateIntegration } from "#/hooks/mutation/use-validate-integration";
+import { useMe } from "#/hooks/query/use-me";
+import { usePermission } from "#/hooks/organizations/use-permissions";
+import { useJiraDcInstanceStatus } from "#/hooks/query/use-jira-dc-instance-status";
import { displaySuccessToast } from "#/utils/custom-toast-handlers";
import { CopyableValue, generateWebhookSecret } from "./configure-modal";
@@ -70,6 +73,24 @@ export function JiraDcIntegrationPanel() {
? existingWorkspace.status === "active"
: integrationData?.status === "active";
+ // Setting up the connection is admin/owner-only; members just link their own
+ // account. (In personal-org mode everyone is an owner, but that path is OAuth
+ // -- jira_dc_oauth_host set -- and never routes through the setup form.)
+ const { data: me } = useMe();
+ const { hasPermission } = usePermission(me?.role ?? "member");
+ const canConfigure = hasPermission("manage_integration_providers");
+
+ // A member (email mode, not linked) needs to know whether the connection is
+ // set up (and its host) to show "link your account" vs "ask an admin".
+ const memberNeedsStatus =
+ !existingWorkspace && !jiraDcOAuthHost && !canConfigure;
+ const { data: jiraDcInstanceStatus } =
+ useJiraDcInstanceStatus(memberNeedsStatus);
+ const memberStatusReady =
+ memberNeedsStatus && jiraDcInstanceStatus !== undefined;
+ const instanceConfigured = jiraDcInstanceStatus?.configured ?? false;
+ const instanceHost = jiraDcInstanceStatus?.host ?? null;
+
const configureMutation = useConfigureIntegration("jira-dc", {
onSettled: () => {},
});
@@ -181,11 +202,10 @@ export function JiraDcIntegrationPanel() {
statusMutation.isPending;
const handleInitialAction = () => {
+ // OAuth mode only: the Connect button starts the per-user OAuth link.
if (jiraDcOAuthHost) {
validateMutation.mutate(jiraDcOAuthHost);
- return;
}
- openEdit();
};
const handleEmailChange = (value: string) => {
@@ -567,13 +587,81 @@ export function JiraDcIntegrationPanel() {
</div>
);
+ // Entry action for a not-yet-linked user. OAuth mode -> Connect your own
+ // account. Email mode -> members do nothing (they auto-link on their first
+ // @openhands mention, and must never see the admin setup form -- FDE-87);
+ // admins set up / manage the connection, with a note on live Jira queries.
+ const renderEntryAction = () => {
+ if (jiraDcOAuthHost) {
+ return (
+ <div>
+ <BrandButton
+ variant="primary"
+ onClick={handleInitialAction}
+ testId="jira-dc-connect-button"
+ type="button"
+ isDisabled={isBusy}
+ >
+ {t(I18nKey.PROJECT_MANAGEMENT$CONNECT_BUTTON_LABEL)}
+ </BrandButton>
+ </div>
+ );
+ }
+ if (!canConfigure) {
+ // Member, email mode. Set up -> a bare "Link account" button (the subtitle
+ // carries the prompt). Not set up / still loading -> nothing (the subtitle
+ // says "ask an admin"); never the admin setup form (FDE-87).
+ if (instanceConfigured) {
+ return (
+ <div>
+ <BrandButton
+ variant="primary"
+ type="button"
+ onClick={() => instanceHost && linkMutation.mutate(instanceHost)}
+ testId="jira-dc-link-button"
+ isDisabled={isBusy}
+ >
+ {t(I18nKey.PROJECT_MANAGEMENT$JIRA_DC_LINK_BUTTON_LABEL)}
+ </BrandButton>
+ </div>
+ );
+ }
+ return null;
+ }
+ return (
+ <div>
+ <BrandButton
+ variant="primary"
+ onClick={openEdit}
+ testId="jira-dc-configure-button"
+ type="button"
+ isDisabled={isBusy}
+ >
+ {t(I18nKey.PROJECT_MANAGEMENT$CONFIGURE_BUTTON_LABEL)}
+ </BrandButton>
+ </div>
+ );
+ };
+
+ // Subtitle is state-aware for the not-linked entry: a member sees the link/
+ // ask-admin prompt in place of the generic line; an email-mode admin sees the
+ // generic line plus the live-query note (folded in, no separate box).
+ let subtitleKey = I18nKey.PROJECT_MANAGEMENT$JIRA_DC_PANEL_SUBTITLE;
+ if (memberStatusReady) {
+ subtitleKey = instanceConfigured
+ ? I18nKey.PROJECT_MANAGEMENT$JIRA_DC_MEMBER_LINK_PROMPT
+ : I18nKey.PROJECT_MANAGEMENT$JIRA_DC_ASK_ADMIN;
+ } else if (canConfigure && !jiraDcOAuthHost) {
+ subtitleKey = I18nKey.PROJECT_MANAGEMENT$JIRA_DC_ADMIN_SUBTITLE;
+ }
+
return (
<div className="flex flex-col gap-4" data-testid="jira-dc-panel">
<Typography.H3 className="text-lg font-medium text-white">
{t(I18nKey.PROJECT_MANAGEMENT$JIRA_DC_PLATFORM_NAME)}
</Typography.H3>
<Typography.Text className="text-sm text-gray-400">
- {t(I18nKey.PROJECT_MANAGEMENT$JIRA_DC_PANEL_SUBTITLE)}
+ {t(subtitleKey)}
</Typography.Text>
{existingWorkspace ? (
@@ -679,21 +767,7 @@ export function JiraDcIntegrationPanel() {
</table>
</div>
) : (
- <div>
- <BrandButton
- variant="primary"
- onClick={handleInitialAction}
- testId="jira-dc-configure-button"
- type="button"
- isDisabled={isBusy}
- >
- {t(
- jiraDcOAuthHost
- ? I18nKey.PROJECT_MANAGEMENT$CONNECT_BUTTON_LABEL
- : I18nKey.PROJECT_MANAGEMENT$CONFIGURE_BUTTON_LABEL,
- )}
- </BrandButton>
- </div>
+ renderEntryAction()
)}
{modalView === "edit" && (
diff --git a/frontend/src/hooks/query/use-jira-dc-instance-status.ts b/frontend/src/hooks/query/use-jira-dc-instance-status.ts
new file mode 100644
index 0000000000..d7555ec98b
--- /dev/null
+++ b/frontend/src/hooks/query/use-jira-dc-instance-status.ts
@@ -0,0 +1,27 @@
+import { useQuery } from "@tanstack/react-query";
+import { openHands } from "#/api/open-hands-axios";
+
+export interface JiraDcInstanceStatus {
+ /** Whether an admin has set up the install's Jira Data Center connection. */
+ configured: boolean;
+ /** Host to link to (drives the per-user link call); null when not configured. */
+ host: string | null;
+}
+
+/**
+ * Instance-level Jira DC status: whether the connection is set up and its host.
+ * Lets a not-yet-linked member see "link your account" vs "ask an admin to set
+ * it up". Only needed for a member in email mode — gate it via `enabled`.
+ */
+export function useJiraDcInstanceStatus(enabled = true) {
+ return useQuery<JiraDcInstanceStatus>({
+ queryKey: ["jira-dc-instance-status"],
+ enabled,
+ queryFn: async () => {
+ const response = await openHands.get(
+ "/integration/jira-dc/workspaces/status",
+ );
+ return response.data;
+ },
+ });
+}
diff --git a/frontend/src/i18n/declaration.ts b/frontend/src/i18n/declaration.ts
index 28b2dd4d15..4d4573498d 100644
--- a/frontend/src/i18n/declaration.ts
+++ b/frontend/src/i18n/declaration.ts
@@ -1602,6 +1602,10 @@ export enum I18nKey {
PROJECT_MANAGEMENT$JIRA_DC_PAUSE_HELP = "PROJECT_MANAGEMENT$JIRA_DC_PAUSE_HELP",
PROJECT_MANAGEMENT$ACTIVE_TOGGLE_HELP = "PROJECT_MANAGEMENT$ACTIVE_TOGGLE_HELP",
PROJECT_MANAGEMENT$JIRA_DC_PANEL_SUBTITLE = "PROJECT_MANAGEMENT$JIRA_DC_PANEL_SUBTITLE",
+ PROJECT_MANAGEMENT$JIRA_DC_ADMIN_SUBTITLE = "PROJECT_MANAGEMENT$JIRA_DC_ADMIN_SUBTITLE",
+ PROJECT_MANAGEMENT$JIRA_DC_MEMBER_LINK_PROMPT = "PROJECT_MANAGEMENT$JIRA_DC_MEMBER_LINK_PROMPT",
+ PROJECT_MANAGEMENT$JIRA_DC_ASK_ADMIN = "PROJECT_MANAGEMENT$JIRA_DC_ASK_ADMIN",
+ PROJECT_MANAGEMENT$JIRA_DC_LINK_BUTTON_LABEL = "PROJECT_MANAGEMENT$JIRA_DC_LINK_BUTTON_LABEL",
PROJECT_MANAGEMENT$JIRA_DC_SERVER_SECTION_LABEL = "PROJECT_MANAGEMENT$JIRA_DC_SERVER_SECTION_LABEL",
PROJECT_MANAGEMENT$JIRA_DC_STATUS_INACTIVE = "PROJECT_MANAGEMENT$JIRA_DC_STATUS_INACTIVE",
PROJECT_MANAGEMENT$JIRA_DC_STATUS_NOT_CONNECTED = "PROJECT_MANAGEMENT$JIRA_DC_STATUS_NOT_CONNECTED",
diff --git a/frontend/src/i18n/translation.json b/frontend/src/i18n/translation.json
index c6f0925dda..a87422318d 100644
--- a/frontend/src/i18n/translation.json
+++ b/frontend/src/i18n/translation.json
@@ -27233,6 +27233,74 @@
"tr": "OpenHands'in Jira Data Center sorunlarınızdaki @openhands bahsetmelerine yanıt vermesine izin verin.",
"uk": "Дозвольте OpenHands відповідати на згадки @openhands у задачах Jira Data Center."
},
+ "PROJECT_MANAGEMENT$JIRA_DC_ADMIN_SUBTITLE": {
+ "en": "Let OpenHands respond to @openhands mentions on your Jira Data Center issues. NOTE: To let agents read and query Jira mid-conversation, enable OAuth mode in the OHE Admin Config and redeploy or have users add a Jira token as a Secret.",
+ "ja": "OpenHands が Jira Data Center の課題での @openhands メンションに応答できるようにします。注意: 会話中にエージェントが Jira を読み取り・照会できるようにするには、OHE Admin Config で OAuth mode を有効にして再デプロイするか、ユーザーに Jira トークンを Secret として追加してもらってください。",
+ "zh-CN": "让 OpenHands 响应您 Jira Data Center 问题中的 @openhands 提及。注意:如需让智能体在对话过程中读取和查询 Jira,请在 OHE Admin Config 中启用 OAuth mode 并重新部署,或让用户将 Jira 令牌添加为 Secret。",
+ "zh-TW": "讓 OpenHands 回應您 Jira Data Center 問題中的 @openhands 提及。注意:若要讓代理程式在對話進行中讀取及查詢 Jira,請在 OHE Admin Config 中啟用 OAuth mode 並重新部署,或讓使用者將 Jira 權杖新增為 Secret。",
+ "ko-KR": "OpenHands가 Jira Data Center 이슈의 @openhands 멘션에 응답하도록 합니다. 참고: 에이전트가 대화 중에 Jira를 읽고 조회할 수 있도록 하려면 OHE Admin Config에서 OAuth mode를 활성화하고 다시 배포하거나, 사용자가 Jira 토큰을 Secret으로 추가하도록 하세요.",
+ "no": "La OpenHands svare på @openhands-omtaler i Jira Data Center-sakene dine. Merk: For at agenter skal kunne lese og spørre Jira underveis i en samtale, aktiver OAuth mode i OHE Admin Config og distribuer på nytt, eller la brukere legge til et Jira-token som en Secret.",
+ "ar": "اسمح لـ OpenHands بالرد على إشارات @openhands في مشكلات Jira Data Center الخاصة بك. ملاحظة: للسماح للوكلاء بقراءة Jira والاستعلام عنها أثناء المحادثة، فعّل OAuth mode في OHE Admin Config وأعد النشر، أو اطلب من المستخدمين إضافة رمز Jira كـ Secret.",
+ "de": "Lass OpenHands auf @openhands-Erwähnungen in deinen Jira Data Center-Vorgängen reagieren. Hinweis: Damit Agenten Jira mitten in einer Unterhaltung lesen und abfragen können, aktiviere OAuth mode in der OHE Admin Config und deploye neu, oder lass Nutzer ein Jira-Token als Secret hinzufügen.",
+ "fr": "Permettez à OpenHands de répondre aux mentions @openhands sur vos tickets Jira Data Center. Remarque : pour permettre aux agents de lire et d'interroger Jira en cours de conversation, activez le OAuth mode dans OHE Admin Config et redéployez, ou demandez aux utilisateurs d'ajouter un jeton Jira en tant que Secret.",
+ "it": "Consenti a OpenHands di rispondere alle menzioni @openhands negli issue di Jira Data Center. Nota: per consentire agli agenti di leggere e interrogare Jira durante una conversazione, abilita OAuth mode in OHE Admin Config ed esegui nuovamente il deploy, oppure chiedi agli utenti di aggiungere un token Jira come Secret.",
+ "pt": "Permita que o OpenHands responda a menções @openhands nas suas issues do Jira Data Center. Observação: para permitir que os agentes leiam e consultem o Jira durante a conversa, ative o OAuth mode na OHE Admin Config e reimplante, ou peça aos usuários que adicionem um token do Jira como um Secret.",
+ "es": "Permite que OpenHands responda a las menciones de @openhands en tus incidencias de Jira Data Center. Nota: Para que los agentes puedan leer y consultar Jira durante una conversación, habilita OAuth mode en OHE Admin Config y vuelve a desplegar, o pide a los usuarios que añadan un token de Jira como Secret.",
+ "ca": "Permet que OpenHands respongui a les mencions de @openhands a les teves incidències de Jira Data Center. Nota: perquè els agents puguin llegir i consultar Jira durant una conversa, activa OAuth mode a l'OHE Admin Config i torna a desplegar, o fes que els usuaris afegeixin un token de Jira com a Secret.",
+ "tr": "OpenHands'in Jira Data Center sorunlarınızda @openhands'ten bahsedildiğinde yanıt vermesini sağlayın. Not: Aracıların konuşma sırasında Jira'yı okuyup sorgulayabilmesi için OHE Admin Config içinde OAuth mode'u etkinleştirip yeniden dağıtın ya da kullanıcıların bir Jira token'ını Secret olarak eklemesini sağlayın.",
+ "uk": "Дозвольте OpenHands відповідати на згадки @openhands у ваших задачах Jira Data Center. Примітка: щоб агенти могли читати та запитувати дані Jira під час розмови, увімкніть OAuth mode в OHE Admin Config і повторно розгорніть застосунок або попросіть користувачів додати токен Jira як Secret."
+ },
+ "PROJECT_MANAGEMENT$JIRA_DC_MEMBER_LINK_PROMPT": {
+ "en": "To connect, mention @openhands on any Jira Data Center issue, or link your account now.",
+ "ja": "接続するには、Jira Data Center の任意の課題で @openhands にメンションするか、今すぐアカウントをリンクしてください。",
+ "zh-CN": "如需连接,请在任意 Jira Data Center 问题中提及 @openhands,或立即关联您的账户。",
+ "zh-TW": "若要連接,請在任何 Jira Data Center 問題上提及 @openhands,或立即連結您的帳戶。",
+ "ko-KR": "연결하려면 Jira Data Center 이슈에서 @openhands를 멘션하거나 지금 계정을 연결하세요.",
+ "no": "For å koble til, nevn @openhands i en hvilken som helst Jira Data Center-sak, eller koble til kontoen din nå.",
+ "ar": "للربط، اذكر @openhands في أي مشكلة على Jira Data Center، أو اربط حسابك الآن.",
+ "de": "Erwähne zum Verbinden @openhands in einem beliebigen Jira Data Center-Vorgang oder verknüpfe jetzt dein Konto.",
+ "fr": "Pour vous connecter, mentionnez @openhands sur n'importe quel ticket Jira Data Center, ou liez votre compte maintenant.",
+ "it": "Per connetterti, menziona @openhands in qualsiasi issue di Jira Data Center oppure collega subito il tuo account.",
+ "pt": "Para conectar, mencione @openhands em qualquer issue do Jira Data Center ou vincule sua conta agora.",
+ "es": "Para conectar, menciona a @openhands en cualquier incidencia de Jira Data Center, o vincula tu cuenta ahora.",
+ "ca": "Per connectar-te, menciona @openhands en qualsevol incidència de Jira Data Center o enllaça el teu compte ara.",
+ "tr": "Bağlanmak için herhangi bir Jira Data Center sorununda @openhands'ten bahsedin ya da hesabınızı şimdi bağlayın.",
+ "uk": "Щоб підключитися, згадайте @openhands у будь-якій задачі Jira Data Center або прив'яжіть свій акаунт зараз."
+ },
+ "PROJECT_MANAGEMENT$JIRA_DC_ASK_ADMIN": {
+ "en": "Ask an admin to configure Jira Data Center.",
+ "ja": "管理者に Jira Data Center の設定を依頼してください。",
+ "zh-CN": "请联系管理员配置 Jira Data Center。",
+ "zh-TW": "請管理員設定 Jira Data Center。",
+ "ko-KR": "관리자에게 Jira Data Center 설정을 요청하세요.",
+ "no": "Be en administrator om å konfigurere Jira Data Center.",
+ "ar": "اطلب من أحد المسؤولين إعداد Jira Data Center.",
+ "de": "Bitte einen Administrator, Jira Data Center zu konfigurieren.",
+ "fr": "Demandez à un administrateur de configurer Jira Data Center.",
+ "it": "Chiedi a un amministratore di configurare Jira Data Center.",
+ "pt": "Peça a um administrador para configurar o Jira Data Center.",
+ "es": "Pide a un administrador que configure Jira Data Center.",
+ "ca": "Demana a un administrador que configuri Jira Data Center.",
+ "tr": "Bir yöneticiden Jira Data Center'ı yapılandırmasını isteyin.",
+ "uk": "Попросіть адміністратора налаштувати Jira Data Center."
+ },
+ "PROJECT_MANAGEMENT$JIRA_DC_LINK_BUTTON_LABEL": {
+ "en": "Link account",
+ "ja": "アカウントをリンク",
+ "zh-CN": "关联账户",
+ "zh-TW": "連結帳戶",
+ "ko-KR": "계정 연결",
+ "no": "Koble til konto",
+ "ar": "ربط الحساب",
+ "de": "Konto verknüpfen",
+ "fr": "Lier le compte",
+ "it": "Collega account",
+ "pt": "Vincular conta",
+ "es": "Vincular cuenta",
+ "ca": "Enllaça el compte",
+ "tr": "Hesabı bağla",
+ "uk": "Прив'язати акаунт"
+ },
"PROJECT_MANAGEMENT$JIRA_DC_SERVER_SECTION_LABEL": {
"en": "Server",
"ja": "サーバー",
diff --git a/frontend/src/utils/org/permissions.ts b/frontend/src/utils/org/permissions.ts
index 25f65b6e3c..8a2b2dcc83 100644
--- a/frontend/src/utils/org/permissions.ts
+++ b/frontend/src/utils/org/permissions.ts
@@ -12,6 +12,7 @@ type ViewBillingPermission = "view_billing";
type ManageSecretsPermission = "manage_secrets";
type ManageMCPPermission = "manage_mcp";
type ManageIntegrationsPermission = "manage_integrations";
+type ManageIntegrationProvidersPermission = "manage_integration_providers";
type ManageApplicationSettingsPermission = "manage_application_settings";
type ManageAPIKeysPermission = "manage_api_keys";
@@ -31,6 +32,7 @@ export type PermissionKey =
| ManageSecretsPermission
| ManageMCPPermission
| ManageIntegrationsPermission
+ | ManageIntegrationProvidersPermission
| ManageApplicationSettingsPermission
| ManageAPIKeysPermission
| ViewLLMSettingsPermission
@@ -48,6 +50,7 @@ const memberPerms: PermissionKey[] = [
];
const adminOnly: PermissionKey[] = [
+ "manage_integration_providers",
"edit_llm_settings",
"view_billing",
"add_credits",