-
Notifications
You must be signed in to change notification settings - Fork 85
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
Bump azure-devops-extension-sdk from 2.0.11 to 4.0.2 in /src/frontend #1103
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,12 +1,12 @@ | ||||||||
import React from 'react'; | ||||||||
import { getService } from 'azure-devops-extension-sdk'; | ||||||||
import { WorkItem, WorkItemType } from 'azure-devops-extension-api/WorkItemTracking/WorkItemTracking'; | ||||||||
import { DocumentCard, DocumentCardTitle, DocumentCardType } from 'office-ui-fabric-react/lib/DocumentCard'; | ||||||||
import { Image } from 'office-ui-fabric-react/lib/Image'; | ||||||||
import { WorkItemTrackingServiceIds, IWorkItemFormNavigationService } from 'azure-devops-extension-api/WorkItemTracking'; | ||||||||
import { DetailsList, DetailsListLayoutMode, SelectionMode, IColumn } from 'office-ui-fabric-react/lib/DetailsList'; | ||||||||
import { withAITracking } from '@microsoft/applicationinsights-react-js'; | ||||||||
import { reactPlugin } from '../utilities/telemetryClient'; | ||||||||
import { SDKContext } from '../dal/azureDevOpsContextProvider'; | ||||||||
|
||||||||
export interface IBoardSummaryProps { | ||||||||
actionItems: WorkItem[]; | ||||||||
|
@@ -180,7 +180,8 @@ class BoardSummary extends React.Component<IBoardSummaryProps, IBoardSummaryStat | |||||||
priority: workItem.fields['Microsoft.VSTS.Common.Priority'], | ||||||||
id: workItem.id, | ||||||||
onActionItemClick: async (id: number) => { | ||||||||
const workItemNavSvc = await getService<IWorkItemFormNavigationService>(WorkItemTrackingServiceIds.WorkItemFormNavigationService); | ||||||||
const { SDK } = React.useContext(SDKContext); | ||||||||
const workItemNavSvc = await SDK.getService<IWorkItemFormNavigationService>(WorkItemTrackingServiceIds.WorkItemFormNavigationService); | ||||||||
await workItemNavSvc.openWorkItem(id); | ||||||||
} | ||||||||
}; | ||||||||
|
@@ -217,7 +218,8 @@ class BoardSummary extends React.Component<IBoardSummaryProps, IBoardSummaryStat | |||||||
} | ||||||||
|
||||||||
private readonly onItemInvoked = async (item: { id: number }) => { | ||||||||
const workItemNavSvc = await getService<IWorkItemFormNavigationService>(WorkItemTrackingServiceIds.WorkItemFormNavigationService); | ||||||||
const { SDK } = React.useContext(SDKContext); | ||||||||
const workItemNavSvc = await SDK.getService<IWorkItemFormNavigationService>(WorkItemTrackingServiceIds.WorkItemFormNavigationService); | ||||||||
Comment on lines
+221
to
+222
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using React.useContext inside this event handler might violate hook rules if it isn’t within a proper React component context. Consider refactoring to retrieve context once within the component.
Suggested change
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||||||||
await workItemNavSvc.openWorkItem(item.id); | ||||||||
} | ||||||||
|
||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -42,8 +42,8 @@ import copyToClipboard from 'copy-to-clipboard'; | |||||
import { getColumnsByTemplateId } from '../utilities/boardColumnsHelper'; | ||||||
import { FeedbackBoardPermissionOption } from './feedbackBoardMetadataFormPermissions'; | ||||||
import { CommonServiceIds, IHostNavigationService } from 'azure-devops-extension-api/Common/CommonServices'; | ||||||
import { getService } from 'azure-devops-extension-sdk'; | ||||||
import { FontIcon } from 'office-ui-fabric-react'; | ||||||
import { SDKContext } from '../dal/azureDevOpsContextProvider'; | ||||||
|
||||||
export interface FeedbackBoardContainerProps { | ||||||
isHostedAzureDevOps: boolean; | ||||||
|
@@ -252,13 +252,15 @@ class FeedbackBoardContainer extends React.Component<FeedbackBoardContainerProps | |||||
} | ||||||
|
||||||
private async updateUrlWithBoardAndTeamInformation(teamId: string, boardId: string) { | ||||||
getService<IHostNavigationService>(CommonServiceIds.HostNavigationService).then(service => { | ||||||
const { SDK } = React.useContext(SDKContext); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While integrating SDKContext in a component, ensure that React.useContext is used within the render flow. Verify that this usage adheres to hook rules given the function’s context. Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||||||
SDK.getService<IHostNavigationService>(CommonServiceIds.HostNavigationService).then(service => { | ||||||
service.setHash(`teamId=${teamId}&boardId=${boardId}`); | ||||||
}); | ||||||
} | ||||||
|
||||||
private async parseUrlForBoardAndTeamInformation(): Promise<{ teamId: string, boardId: string }> { | ||||||
const service = await getService<IHostNavigationService>(CommonServiceIds.HostNavigationService); | ||||||
const { SDK } = React.useContext(SDKContext); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repeated use of React.useContext in the same component should be consolidated if possible. Consider retrieving the SDK context once and reusing it to avoid potential misuse of hooks.
Suggested change
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||||||
const service = await SDK.getService<IHostNavigationService>(CommonServiceIds.HostNavigationService); | ||||||
let hash = await service.getHash(); | ||||||
if (hash.startsWith('#')) { | ||||||
hash = hash.substring(1); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as SDK from 'azure-devops-extension-sdk'; | ||
import React from 'react'; | ||
|
||
type SDKContextProps = { | ||
SDK: typeof SDK; | ||
}; | ||
|
||
export const SDKContext = React.createContext<SDKContextProps>({} as SDKContextProps); | ||
|
||
export const SDKProvider: React.FC = (props) => { | ||
const context: SDKContextProps = { | ||
SDK | ||
}; | ||
|
||
const initSDK = async () => { | ||
await SDK.init(); | ||
}; | ||
|
||
React.useEffect(() => { | ||
initSDK(); | ||
}, []); | ||
|
||
return ( | ||
<SDKContext.Provider value={context}>{props.children}</SDKContext.Provider> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { getAccessToken, getExtensionContext, getService } from 'azure-devops-extension-sdk'; | ||
import { CommonServiceIds, IExtensionDataManager, IExtensionDataService } from 'azure-devops-extension-api'; | ||
import { appInsights } from '../utilities/telemetryClient'; | ||
import { SDKContext } from './azureDevOpsContextProvider'; | ||
import React from 'react'; | ||
|
||
let extensionDataManager: IExtensionDataManager; | ||
|
||
async function getDataService(): Promise<IExtensionDataManager> { | ||
if (!extensionDataManager) { | ||
const accessToken = await getAccessToken(); | ||
const extensionDataService = await getService<IExtensionDataService>(CommonServiceIds.ExtensionDataService); | ||
extensionDataManager = await extensionDataService.getExtensionDataManager(getExtensionContext().id, accessToken); | ||
const { SDK } = React.useContext(SDKContext); | ||
const accessToken = await SDK.getAccessToken(); | ||
Comment on lines
8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Directly using React.useContext in this utility function may breach React Hook rules. Refactor to use a custom hook or pass the SDK context from a parent component. Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||
const extensionDataService = await SDK.getService<IExtensionDataService>(CommonServiceIds.ExtensionDataService); | ||
extensionDataManager = await extensionDataService.getExtensionDataManager(SDK.getExtensionContext().id, accessToken); | ||
} | ||
|
||
return extensionDataManager; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import React from 'react'; | ||
import { HubConnection, HubConnectionBuilder, LogLevel } from '@microsoft/signalr'; | ||
import moment from 'moment'; | ||
import { getAppToken } from 'azure-devops-extension-sdk'; | ||
|
||
import { config } from '../config/config'; | ||
import { decodeJwt } from '../utilities/tokenHelper'; | ||
import { isHostedAzureDevOps } from '../utilities/azureDevOpsContextHelper'; | ||
import { appInsights } from '../utilities/telemetryClient'; | ||
import { IExceptionTelemetry } from '@microsoft/applicationinsights-web'; | ||
import { SDKContext } from './azureDevOpsContextProvider'; | ||
|
||
const enum ReflectBackendSignals { | ||
JoinReflectBoardGroup = 'joinReflectBoardGroup', | ||
|
@@ -81,7 +82,9 @@ class ReflectBackendService { | |
return that._appToken; | ||
} | ||
|
||
return Promise.resolve(getAppToken().then((appToken) => { | ||
const { SDK } = React.useContext(SDKContext); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invoking React.useContext in a non-component function could violate hook rules. Consider refactoring this logic into a custom hook or ensuring it’s used within a valid React component. Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||
|
||
return Promise.resolve(SDK.getAppToken().then((appToken) => { | ||
that._appToken = appToken; | ||
|
||
const tokenData = decodeJwt(that._appToken); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,5 @@ | ||||||
import { getHost } from 'azure-devops-extension-sdk'; | ||||||
import React from 'react'; | ||||||
import { SDKContext } from '../dal/azureDevOpsContextProvider'; | ||||||
import { getHostAuthority } from '../utilities/servicesHelper'; | ||||||
|
||||||
const internalOrgNames = [ | ||||||
|
@@ -15,7 +16,8 @@ const internalOrgNames = [ | |||||
* Returns whether the current org in VSTS context is a recognized internal org. | ||||||
*/ | ||||||
export const isInternalOrg = () => { | ||||||
const host = getHost(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using React.useContext in a non-component function may result in unexpected behavior due to hook rules. Refactor this access to occur within a functional component or custom hook.
Suggested change
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||||||
const { SDK } = React.useContext(SDKContext); | ||||||
const host = SDK.getHost(); | ||||||
return internalOrgNames.indexOf(host.name.toLowerCase().trim()) !== -1; | ||||||
}; | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,12 +1,14 @@ | ||||||
import { getService } from 'azure-devops-extension-sdk'; | ||||||
import { CommonServiceIds, IProjectPageService, IProjectInfo, ILocationService } from 'azure-devops-extension-api'; | ||||||
import { CoreRestClient } from 'azure-devops-extension-api/Core'; | ||||||
import React from 'react'; | ||||||
import { SDKContext } from '../dal/azureDevOpsContextProvider'; | ||||||
|
||||||
/** | ||||||
* Get the project info | ||||||
*/ | ||||||
const getProjectInfo = async (): Promise<IProjectInfo> => { | ||||||
const projectPageService = await getService<IProjectPageService>(CommonServiceIds.ProjectPageService); | ||||||
const { SDK } = React.useContext(SDKContext); | ||||||
const projectPageService = await SDK.getService<IProjectPageService>(CommonServiceIds.ProjectPageService); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using React.useContext in a utility function (outside of a React component) can lead to hook rule violations. Consider moving this logic into a custom hook or passing the context as an argument.
Suggested change
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||||||
|
||||||
return projectPageService.getProject(); | ||||||
} | ||||||
|
@@ -33,7 +35,8 @@ export const getProjectId = async (): Promise<string> => { | |||||
* Get the host base URL | ||||||
*/ | ||||||
export const getHostBaseUrl = async (): Promise<string> => { | ||||||
const locationService = await getService<ILocationService>(CommonServiceIds.LocationService); | ||||||
const { SDK } = React.useContext(SDKContext); | ||||||
const locationService = await SDK.getService<ILocationService>(CommonServiceIds.LocationService); | ||||||
const hostBaseUrl = await locationService.getResourceAreaLocation( | ||||||
CoreRestClient.RESOURCE_AREA_ID | ||||||
); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import React from 'react'; | ||
import { IdentityRef } from 'azure-devops-extension-api/WebApi'; | ||
import { IUserContext, getUser } from 'azure-devops-extension-sdk'; | ||
import { SDKContext } from '../dal/azureDevOpsContextProvider'; | ||
|
||
let userIdentity: IdentityRef; | ||
|
||
|
@@ -8,7 +9,8 @@ let userIdentity: IdentityRef; | |
*/ | ||
export const getUserIdentity = (): IdentityRef => { | ||
if (!userIdentity){ | ||
const currentUser: IUserContext = getUser(); | ||
const { SDK } = React.useContext(SDKContext); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using React.useContext inside a non-component function may violate React Hooks rules. Consider refactoring this utility to a custom hook or ensuring it’s only called within a functional component. Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||
const currentUser = SDK.getUser(); | ||
|
||
userIdentity = { | ||
id: currentUser.id, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that using React.useContext within this callback complies with the Rules of Hooks. If this function is not a React component or custom hook, refactor accordingly.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.