import { WorkItem, WorkItemField, WorkItemRelation, WorkItemRelationType } from "./WorkItemTracking"; import { IdentityRef } from "../WebApi"; /** * Contribution ids of Azure Boards services which can be obtained from DevOps.getService */ export declare enum WorkItemTrackingServiceIds { /** * Host service for opening the work item form */ WorkItemFormNavigationService = "ms.vss-work-web.work-item-form-navigation-service", /** * Host service for interacting with the currently active work item form (work item currently displayed in the UI). * Form service depends on the current active work item context. Will throw an error when there is no open work item. */ WorkItemFormService = "ms.vss-work-web.work-item-form" } /** * Options for getting the values of a work item */ export interface WorkItemOptions { /** * Returns the original instead of updated value for the field */ returnOriginalValue: boolean; } /** * Host service for opening the work item form */ export interface IWorkItemFormNavigationService { /** * Opens the specified work item. The host page will display the work item in a dialog, * or it may update the current page view, depending on the current page. * * @param {number} workItemId The id of the work item to open * @param {boolean} openInNewTab (Optional) If true, opens the work item in a new tab. Default is false * @returns {Promise} A promise that returns a work item when the work item dialog is closed. If openInNewTab is true, the promise will return null */ openWorkItem(workItemId: number, openInNewTab?: boolean): Promise; /** * Opens a new work item of the specified type. The host page will display the new work item in a dialog, * or it may update the current page view, depending on the current page. * * @param {string} workItemTypeName The name of the work item type to open * @param {{ [fieldName: string]: Object }} initialValues (Optional) A dictionary of any initial field values to set after opening the new work item. * @returns {Promise} A promise that returns a work item when the work item dialog is closed. If the workitem was not saved before closing the dialog, the promise will return null */ openNewWorkItem(workItemTypeName: string, initialValues?: { [fieldName: string]: Object; }): Promise; } /** * Host service for interacting with the currently active work item form (work item currently displayed in the UI). * Form service depends on the current active work item context. Will throw an error when there is no open work item. */ export interface IWorkItemFormService { /** * Gets id of active work item. * * @returns {Promise} A promise that returns the active work item id. */ getId(): Promise; /** * Gets active work item's latest revision. * * @returns {Promise} A promise that returns the active work item's latest revision id. */ getRevision(): Promise; /** * Gets active work item fields. * * @returns {Promise} A promise that returns an array of work item field. */ getFields(): Promise; /** * Gets field value of the active work item. * * @deprecated Please use options instead of returnOriginalValue * * @param {string} fieldReferenceName Field reference name * @param {boolean} returnOriginalValue (Optional) If false, gets unsaved field values. Default is false. * @returns {Promise} A promise that returns the value of the work item field. */ getFieldValue(fieldReferenceName: string, returnOriginalValue?: boolean): Promise; /** * Gets field value of the active work item. * * @param {string} fieldReferenceName Field reference name * @param {WorkItemOptions} options work item options * @returns {Promise} A promise that returns the value of the work item field. */ getFieldValue(fieldReferenceName: string, options?: WorkItemOptions): Promise; /** * Gets identity field value of the active work item. * * @param {string} fieldReferenceName Field reference name * @param {WorkItemOptions} options work item options * @returns {Promise} A promise that returns the value of the work item field. */ getIdentityFieldValue(fieldReferenceName: string, options?: WorkItemOptions): Promise; /** * Gets field values of the active work item. * * @deprecated Please use options instead of returnOriginalValue * * @param {string[]} fieldReferenceNames An arrary of field reference names * @param {boolean} returnOriginalValue (Optional) If false, gets unsaved field values. Default is false. * @returns {Promise<{ [fieldName: string]: Object }>} A promise that returns a dictionary of work item field values (refName to values pairs). */ getFieldValues(fieldReferenceNames: string[], returnOriginalValue?: boolean): Promise<{ [fieldName: string]: Object; }>; /** * Gets field values of the active work item. * * @param {string[]} fieldReferenceNames An arrary of field reference names * @param {WorkItemOptions} options work item options * @returns {Promise<{ [fieldName: string]: Object }>} A promise that returns a dictionary of work item field values (refName to values pairs). */ getFieldValues(fieldReferenceNames: string[], options?: WorkItemOptions): Promise<{ [fieldName: string]: Object; }>; /** * Sets field value of the active work item. * * @param {string} fieldReferenceName Field reference name * @param {Object} value Field value * @returns {Promise} A promise that returns a boolean value indicates whether the function completed successfully. */ setFieldValue(fieldReferenceName: string, value: Object): Promise; /** * Sets field values of the active work item. * * @param {{ [fieldName: string]: Object }} fields A dictionary of field refName/values * @returns {Promise<{ [fieldName: string]: boolean }>} A promise that returns a dictionary of field value update results (refName to results pairs). */ setFieldValues(fields: { [fieldName: string]: Object; }): Promise<{ [fieldName: string]: boolean; }>; /** * Gets the allowed values for the field on the active work item. * * @param {string} fieldReferenceName Field reference name * @returns {Promise} A promise that returns an array of allowed values. */ getAllowedFieldValues(fieldReferenceName: string): Promise; /** * Returns true if the active work item is dirty. * * @returns {Promise} A promise that returns a boolean value indicates whether the active work item is dirty. */ isDirty(): Promise; /** * Returns true if the active work item is new. * * @returns {Promise} A promise that returns a boolean value indicates whether the active work item is new. */ isNew(): Promise; /** * Returns true if the active work item fields are all valid. * * @returns {Promise} A promise that returns a boolean value indicates whether all field values are valid. */ isValid(): Promise; /** * Marks the work item as invalid and disable saving the work item on the form. * * @param {string} errorMessage A custom error message that would be shown on top of the work item form. */ setError(errorMessage: string): Promise; /** * Clears the error set by setError method and unblocks saving of the work item in the form. */ clearError(): Promise; /** * Saves the active work item. * * @returns {Promise} A promise that is resolved if the work item is saved successfully and rejected if it fails. */ save(): Promise; /** * Refreshes the active work item. Will prompt the user if the work item is dirty. */ refresh(): Promise; /** * Reset any changes in the active work item. Will prompt the user to confirm. */ reset(): Promise; /** * Gets fields who are in an invalid state according to the work item rules. These fields need to be changed before the work item can be saved. * * @returns {Promise} A promise that returns an array of invalid work item fields. */ getInvalidFields(): Promise; /** * Gets fields that have been changed either by user or by a work item rule and are in a dirty state. * * @param {boolean} includeSystemChanges A boolean value indicating if the result should include changes set by work item rules. * @returns {Promise} A promise that returns an array of dirty work item fields. */ getDirtyFields(includeSystemChanges?: boolean): Promise; /** * Adds links of another work items or artifacts (e.g. commits, hyperlinks) to the work item. Attachment is currently not supported by this function. * * @param {WorkItemRelation[]} workItemRelations Work item links to add. * @returns {Promise} An empty promise. */ addWorkItemRelations(workItemRelations: WorkItemRelation[]): Promise; /** * Removes links to another work items or artifacts (e.g. commits, hyperlinks) from the work item. Attachment is currently not supported by this function. * * @param {WorkItemRelation[]} workItemRelations Work item links to remove. * @returns {Promise} An empty promise. */ removeWorkItemRelations(workItemRelations: WorkItemRelation[]): Promise; /** * Returns an array of work item links to other work items or artifacts (e.g. commits, hyperlinks). Attachment is currently not supported by this function. * * @returns {Promise} A promise that returns an array of work item relations of active work item. */ getWorkItemRelations(): Promise; /** * Returns the REST API url of the specified work item resource. * * @param {number} workItemId Id of the work item that the resource url is requested for. * @returns {Promise} A promise that returns the requested resource url of the work item. */ getWorkItemResourceUrl(workItemId: number): Promise; /** * Returns an array of work item relation types. * * @returns {Promise} A promise that returns an array of work item relation types. */ getWorkItemRelationTypes(): Promise; /** * Returns true if the active work item available. * * @returns {Promise} A promise that returns a boolean value indicates whether the active work item is available. */ hasActiveWorkItem(): Promise; /** * @deprecated: Please use save */ beginSaveWorkItem(successCallback: () => void, errorCallback: () => void): Promise; } /** * Interface defining the arguments for notifications sent by the ActiveWorkItemService */ export interface IWorkItemChangedArgs { /** * Id of the work item. */ id: number; } /** * Interface defining the arguments for the 'onLoaded' notification sent by the ActiveWorkItemService */ export interface IWorkItemLoadedArgs extends IWorkItemChangedArgs { /** * 'true' if the work item is a 'new', unsaved work item, 'false' otherwise. */ isNew: boolean; /** * 'true' write rest apis are disabled. All controls should be rendered as readonly */ isReadOnly: boolean; } /** * Interface defining the arguments for the 'onFieldChanged' notification sent by the ActiveWorkItemService */ export interface IWorkItemFieldChangedArgs extends IWorkItemChangedArgs { /** * Set of fields that have been changed. 'key' is the field reference name. */ changedFields: { [key: string]: any; }; } /** * Interface defining notifications provided by the ActiveWorkItemService */ export interface IWorkItemNotificationListener { /** * Called when an extension is loaded * * @param workItemLoadedArgs Information about the work item that was loaded. */ onLoaded(workItemLoadedArgs: IWorkItemLoadedArgs): void; /** * Called when a field is modified * * @param fieldChangedArgs Information about the work item that was modified and the fields that were changed. */ onFieldChanged(fieldChangedArgs: IWorkItemFieldChangedArgs): void; /** * Called when a work item is saved * * @param savedEventArgs Information about the work item that was saved. */ onSaved(savedEventArgs: IWorkItemChangedArgs): void; /** * Called when a work item is refreshed * * @param refreshEventArgs Information about the work item that was refreshed. */ onRefreshed(refreshEventArgs: IWorkItemChangedArgs): void; /** * Called when a work item is reset (undo back to unchanged state) * * @param undoEventArgs Information about the work item that was reset. */ onReset(undoEventArgs: IWorkItemChangedArgs): void; /** * Called when a work item is unloaded * * @param unloadedEventArgs Information about the work item that was saved. */ onUnloaded(unloadedEventArgs: IWorkItemChangedArgs): void; }