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

feat: release AzureDevOps integration #9531

Merged
merged 3 commits into from
Mar 25, 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
9 changes: 1 addition & 8 deletions packages/client/components/ScopePhaseArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,18 @@ const ScopePhaseArea = (props: Props) => {
}
}
}
user {
featureFlags {
azureDevOps
}
}
}
}
`,
meetingRef
)
const isDesktop = useBreakpoint(Breakpoint.SIDEBAR_LEFT)
const {viewerMeetingMember} = meeting
const featureFlags = viewerMeetingMember?.user.featureFlags
const gitlabIntegration = viewerMeetingMember?.teamMember.integrations.gitlab
const jiraServerIntegration = viewerMeetingMember?.teamMember.integrations.jiraServer
const azureDevOpsIntegration = viewerMeetingMember?.teamMember.integrations.azureDevOps
const allowAzureDevOps =
(!!azureDevOpsIntegration?.sharedProviders.length || !!azureDevOpsIntegration?.cloudProvider) &&
featureFlags?.azureDevOps
!!azureDevOpsIntegration?.sharedProviders.length || !!azureDevOpsIntegration?.cloudProvider
const isGitLabProviderAvailable = !!(
gitlabIntegration?.cloudProvider?.clientId || gitlabIntegration?.sharedProviders.length
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ const query = graphql`
}
}
}
featureFlags {
azureDevOps
}
}
}
`
Expand All @@ -118,10 +115,6 @@ const ProviderList = (props: Props) => {
const {queryRef, retry, teamId} = props
const data = usePreloadedQuery<ProviderListQuery>(query, queryRef)
const {viewer} = data
const {
featureFlags: {azureDevOps: allowAzureDevOps}
} = viewer

const integrations = viewer.teamMember?.integrations

const allIntegrations = [
Expand Down Expand Up @@ -159,8 +152,7 @@ const ProviderList = (props: Props) => {
{
name: 'Azure DevOps',
connected: !!integrations?.azureDevOps.auth?.accessToken,
component: <AzureDevOpsProviderRow teamId={teamId} viewerRef={viewer} />,
hidden: !allowAzureDevOps
component: <AzureDevOpsProviderRow teamId={teamId} viewerRef={viewer} />
},
{
name: 'MS Teams',
Expand All @@ -175,12 +167,12 @@ const ProviderList = (props: Props) => {
]

const connectedIntegrations = allIntegrations
.filter((integration) => integration.connected && !integration.hidden)
.filter((integration) => integration.connected)
.sort((a, b) => a.name.localeCompare(b.name))
.map((integration) => integration.component)

const availableIntegrations = allIntegrations
.filter((integration) => !integration.connected && !integration.hidden)
.filter((integration) => !integration.connected)
.sort((a, b) => a.name.localeCompare(b.name))
.map((integration) => integration.component)

Expand Down
4 changes: 2 additions & 2 deletions packages/client/utils/AzureDevOpsClientManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class AzureDevOpsClientManager {
const providerState = Math.random().toString(36).substring(5)
const verifier = AzureDevOpsClientManager.generateVerifier()
const code = await AzureDevOpsClientManager.generateCodeChallenge(verifier)
const redirect = makeHref('/auth/ado')
const scope = '499b84ac-1321-427f-aa17-267ca6975798/.default'
const redirect = makeHref('/auth/ado2')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched our app to be a "web" app rather than "spa" so our access token gets a longer life-span. Because the redirects are not compatible, I just appended the 2 for now so it works straight after deploying.

const scope = '499b84ac-1321-427f-aa17-267ca6975798/.default offline_access'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional scope to still get a refresh token.

const url = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/authorize?client_id=${clientId}&response_type=code&redirect_uri=${redirect}&response_mode=query&scope=${scope}&state=${providerState}&code_challenge=${code}&code_challenge_method=S256`

// Open synchronously because of Safari
Expand Down
10 changes: 5 additions & 5 deletions packages/server/__tests__/updateFeatureFlag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const UPDATE_FEATURE_FLAG = `
users {
id
featureFlags {
azureDevOps
noAISummary
}
}
}
Expand All @@ -27,7 +27,7 @@ test('Add feature flag by email', async () => {
query: UPDATE_FEATURE_FLAG,
variables: {
emails: [email],
flag: 'azureDevOps',
flag: 'noAISummary',
addFlag: true
},
authToken
Expand All @@ -41,7 +41,7 @@ test('Add feature flag by email', async () => {
{
id: userId,
featureFlags: {
azureDevOps: true
noAISummary: true
}
}
]
Expand All @@ -58,7 +58,7 @@ test('Remove feature flag by email', async () => {
query: UPDATE_FEATURE_FLAG,
variables: {
emails: [email],
flag: 'azureDevOps',
flag: 'noAISummary',
addFlag: false
},
authToken
Expand All @@ -72,7 +72,7 @@ test('Remove feature flag by email', async () => {
{
id: userId,
featureFlags: {
azureDevOps: false
noAISummary: false
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ A flag to give an individual user super powers
"""
enum UserFlagEnum {
standups
azureDevOps
insights
recurrence
noAISummary
Expand All @@ -19,7 +18,6 @@ The types of flags that give an individual user super powers
"""
type UserFeatureFlags {
standups: Boolean!
azureDevOps: Boolean!
insights: Boolean!
recurrence: Boolean!
noAISummary: Boolean!
Expand Down
1 change: 0 additions & 1 deletion packages/server/graphql/public/types/UserFeatureFlags.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {UserFeatureFlagsResolvers} from '../resolverTypes'

const UserFeatureFlags: UserFeatureFlagsResolvers = {
azureDevOps: ({azureDevOps}) => !!azureDevOps,
insights: ({insights}) => !!insights,
noAISummary: ({noAISummary}) => !!noAISummary,
noMeetingHistoryLimit: ({noMeetingHistoryLimit}) => !!noMeetingHistoryLimit,
Expand Down

This file was deleted.

10 changes: 4 additions & 6 deletions packages/server/utils/AzureDevOpsServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class AzureDevOpsServerManager implements TaskIntegrationManager {
grant_type: 'authorization_code',
code: code,
code_verifier: codeVerifier,
redirect_uri: makeAppURL(appOrigin, 'auth/ado')
redirect_uri: makeAppURL(appOrigin, 'auth/ado2')
})
}

Expand Down Expand Up @@ -702,16 +702,14 @@ class AzureDevOpsServerManager implements TaskIntegrationManager {

const body = {
...params,
client_id: this.provider.clientId
client_id: this.provider.clientId,
client_secret: this.provider.clientSecret
}

const additonalHeaders = {
Origin: appOrigin
}
const tenantId = this.provider.tenantId
const authUrl = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`
const contentType = 'application/x-www-form-urlencoded'
const oAuthRes = await authorizeOAuth2({authUrl, body, additonalHeaders, contentType})
const oAuthRes = await authorizeOAuth2({authUrl, body, contentType})
if (!isError(oAuthRes)) {
this.accessToken = oAuthRes.accessToken
}
Expand Down
Loading