Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Allow global Jira Server integration provider #9796

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/server/graphql/mutations/addIntegrationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ const addIntegrationProvider = {
context: GQLContext
) => {
const {authToken, dataLoader, socketId: mutatorId} = context
const {teamId} = input
const {teamId, scope} = input
const operationId = dataLoader.share()
const subOptions = {mutatorId, operationId}

// AUTH
if (!isTeamMember(authToken, teamId) && !isSuperUser(authToken)) {
if (scope === 'global') {
if (!isSuperUser(authToken)) {
return {error: {message: 'Global scope requires su'}}
}
if (teamId !== 'aGhostTeam') {
return {error: {message: 'Global scope requires teamId to be aGhostTeam'}}
}
} else if (!isTeamMember(authToken, teamId) && !isSuperUser(authToken)) {
return {error: {message: 'Must be on the team for which the provider is created'}}
}

Expand Down
1 change: 1 addition & 0 deletions packages/server/graphql/public/typeDefs/_legacy.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8631,6 +8631,7 @@ The scope this provider was created on by a user (excluding global scope)
enum IntegrationProviderEditableScopeEnum {
org
team
global
}

"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {GraphQLEnumType} from 'graphql'

export type TIntegrationProviderEditableScopeEnum = 'org' | 'team'
export type TIntegrationProviderEditableScopeEnum = 'org' | 'team' | 'global'

const IntegrationProviderEditableScopeEnum = new GraphQLEnumType({
name: 'IntegrationProviderEditableScopeEnum',
description: 'The scope this provider was created on by a user (excluding global scope)',
values: {
org: {},
team: {}
team: {},
global: {}
}
})

Expand Down
8 changes: 5 additions & 3 deletions packages/server/graphql/types/JiraServerIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ const JiraServerIntegration = new GraphQLObjectType<{teamId: string; userId: str
const orgTeams = await dataLoader.get('teamsByOrgIds').load(orgId)
const orgTeamIds = orgTeams.map(({id}) => id)

const providers = await dataLoader
.get('sharedIntegrationProviders')
.load({service: 'jiraServer', orgTeamIds, teamIds: [teamId]})
const providers = await dataLoader.get('sharedIntegrationProviders').load({
service: 'jiraServer',
orgTeamIds: [...orgTeamIds, 'aGhostTeam'],
teamIds: [teamId]
})
return providers
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Client} from 'pg'
import getPgConfig from '../getPgConfig'

export async function up() {
const client = new Client(getPgConfig())
await client.connect()
await client.query(`
DO $$
BEGIN
ALTER TABLE "IntegrationProvider"
DROP CONSTRAINT global_provider_must_be_oauth2;
END $$;
`)
await client.end()
}

export async function down() {
//noop, the constraint was a leftover and served no purpose
}
Loading