@@ -35,6 +35,7 @@ import EdiText, { EdiTextType } from 'react-editext';
3535import { v4 } from 'uuid' ;
3636
3737import { DetailedSiteInfo , emptySiteInfo } from '../../../atlclients/authInfo' ;
38+ import { ProjectsPagination } from '../../../constants' ;
3839import { OpenJiraIssueAction } from '../../../ipc/issueActions' ;
3940import {
4041 CreatedSelectOption ,
@@ -61,6 +62,7 @@ import JiraIssueTextAreaEditor from './common/JiraIssueTextArea';
6162import { EditRenderedTextArea } from './EditRenderedTextArea' ;
6263import InlineIssueLinksEditor from './InlineIssueLinkEditor' ;
6364import InlineSubtaskEditor from './InlineSubtaskEditor' ;
65+ import { LazyLoadingSelect } from './LazyLoadingSelect' ;
6466import { ParticipantList } from './ParticipantList' ;
6567import { TextAreaEditor } from './TextAreaEditor' ;
6668
@@ -93,6 +95,12 @@ export interface CommonEditorViewState extends Message {
9395 isGeneratingSuggestions ?: boolean ;
9496 summaryKey : string ;
9597 isAtlaskitEditorEnabled : boolean ;
98+ projectPagination ?: {
99+ total : number ;
100+ loaded : number ;
101+ hasMore : boolean ;
102+ isLoadingMore : boolean ;
103+ } ;
96104}
97105
98106export const emptyCommonEditorState : CommonEditorViewState = {
@@ -1297,6 +1305,55 @@ export abstract class AbstractIssueEditorPage<
12971305 if ( fieldArgs . error === 'EMPTY' ) {
12981306 errDiv = < ErrorMessage > { field . name } is required</ ErrorMessage > ;
12991307 }
1308+ if ( field . valueType === ValueType . Project ) {
1309+ return (
1310+ < React . Fragment >
1311+ < LazyLoadingSelect
1312+ { ...fieldArgs . fieldProps }
1313+ { ...commonProps }
1314+ value = { defVal }
1315+ className = "ac-form-select-container"
1316+ classNamePrefix = "ac-form-select"
1317+ placeholder = "Type to search"
1318+ noOptionsMessage = { ( ) => 'Type to search' }
1319+ isClearable = { this . isClearableSelect ( selectField ) }
1320+ options = { this . state . selectFieldOptions [ field . key ] }
1321+ isDisabled = {
1322+ this . state . isSomethingLoading &&
1323+ this . state . loadingField !== field . key
1324+ }
1325+ isLoading = { this . state . loadingField === field . key }
1326+ hasMore = { this . state . projectPagination ?. hasMore || false }
1327+ isLoadingMore = { this . state . projectPagination ?. isLoadingMore || false }
1328+ totalCount = { this . state . projectPagination ?. total || 0 }
1329+ loadedCount = { this . state . projectPagination ?. loaded || 0 }
1330+ onLoadMore = { this . handleLoadMoreProjects }
1331+ loadOptions = { async ( input : any ) =>
1332+ await this . loadSelectOptionsForField (
1333+ field as SelectFieldUI ,
1334+ input ,
1335+ )
1336+ }
1337+ onChange = { FieldValidators . chain (
1338+ fieldArgs . fieldProps . onChange ,
1339+ ( selected : any ) => {
1340+ this . handleSelectChange ( selectField , selected ) ;
1341+ } ,
1342+ ) }
1343+ onMenuClose = { ( ) => {
1344+ if ( this . state . loadingField === field . key ) {
1345+ this . setState ( {
1346+ isSomethingLoading : false ,
1347+ loadingField : '' ,
1348+ } ) ;
1349+ }
1350+ } }
1351+ />
1352+ { errDiv }
1353+ </ React . Fragment >
1354+ ) ;
1355+ }
1356+
13001357 return (
13011358 < React . Fragment >
13021359 < AsyncSelect
@@ -2073,4 +2130,22 @@ export abstract class AbstractIssueEditorPage<
20732130 return 'text' ;
20742131 }
20752132 }
2133+
2134+ protected handleLoadMoreProjects = ( startAt : number ) => {
2135+ if ( this . state . projectPagination ) {
2136+ this . setState ( {
2137+ projectPagination : {
2138+ ...this . state . projectPagination ,
2139+ isLoadingMore : true ,
2140+ } ,
2141+ } ) ;
2142+ }
2143+
2144+ this . postMessage ( {
2145+ action : 'loadMoreProjects' ,
2146+ maxResults : ProjectsPagination . pageSize ,
2147+ startAt : startAt ,
2148+ nonce : v4 ( ) ,
2149+ } ) ;
2150+ } ;
20762151}
0 commit comments