@@ -23,7 +23,7 @@ import type { createReviewSession } from './review-session'
2323interface ResolvedIssueControlOptions {
2424 disabled : boolean
2525 required : boolean
26- issue : Issue
26+ issue ? : Issue
2727 issueId : string
2828 childToggleIds ?: string [ ]
2929 label : string
@@ -32,7 +32,12 @@ interface ResolvedIssueControlOptions {
3232
3333export type ResolvedIssueControl = ResolvedIssueControlOptions &
3434 (
35- | { type : 'toggle' ; id ?: string ; issueListLabel ?: string ; issueListGroup ?: string }
35+ | {
36+ type : 'toggle'
37+ id ?: string
38+ issueListLabel ?: string
39+ issueListGroup ?: string
40+ }
3641 | {
3742 type : 'markdown' | 'text' | 'textarea'
3843 key : string
@@ -168,7 +173,10 @@ export function createReviewPanels(
168173 | 'organizationMembers'
169174 | 'wasReviewed'
170175 | 'permissions'
171- > & { previousLinks : ReadonlyMap < string , string > ; previousIssueIds ?: readonly string [ ] }
176+ > & {
177+ previousLinks : ReadonlyMap < string , string >
178+ previousIssueIds ?: readonly string [ ]
179+ }
172180 > ,
173181 definitions : Record < string , PanelRegistration > = reviewPanels ,
174182) {
@@ -277,6 +285,15 @@ export function createReviewPanels(
277285 return result
278286 }
279287
288+ function contextSelectValues ( projectId : string , issueId : string , key : string ) : string [ ] {
289+ const values = session . read ( projectId , 'issue-select' ) [ issueId ]
290+ const scope =
291+ values && typeof values === 'object' && ! ( values instanceof Set ) && key in values
292+ ? issueId
293+ : ''
294+ return readSelectValues ( projectId , scope , key )
295+ }
296+
280297 const selectedIssueIds = computed ( ( ) => {
281298 const projectId = project . value ?. id
282299 if ( ! projectId ) return [ ]
@@ -299,13 +316,12 @@ export function createReviewPanels(
299316 const context : ReviewContext = {
300317 projectV3,
301318 ...reviewData . value ,
302- getTextValue : ( id , issueId ) => ( issueId ? ( textValues ( projectV3 . id , issueId ) [ id ] ?? '' ) : '' ) ,
303- getSelectValue : ( id , issueId ) =>
304- issueId ? ( readSelectValues ( projectV3 . id , issueId , id ) [ 0 ] ?? '' ) : '' ,
305- getSelectValues : ( id , issueId ) =>
306- issueId ? readSelectValues ( projectV3 . id , issueId , id ) : [ ] ,
307- getMarkdownValue : ( id , issueId ) =>
308- issueId ? ( textValues ( projectV3 . id , issueId ) [ id ] ?? '' ) : '' ,
319+ getTextValue : ( id , issueId = '' ) =>
320+ textValues ( projectV3 . id , issueId ) [ id ] ?? textValues ( projectV3 . id , '' ) [ id ] ?? '' ,
321+ getSelectValue : ( id , issueId = '' ) => contextSelectValues ( projectV3 . id , issueId , id ) [ 0 ] ?? '' ,
322+ getSelectValues : ( id , issueId = '' ) => contextSelectValues ( projectV3 . id , issueId , id ) ,
323+ getMarkdownValue : ( id , issueId = '' ) =>
324+ textValues ( projectV3 . id , issueId ) [ id ] ?? textValues ( projectV3 . id , '' ) [ id ] ?? '' ,
309325 selected : {
310326 items : { } ,
311327 issueIds : selectedIssueIds . value ,
@@ -347,19 +363,23 @@ export function createReviewPanels(
347363 sections . push ( ...resolveNodes ( node . children , resolveWithContext ( node . label , context ) ) )
348364 continue
349365 }
350- const issue = itemIssues . get ( node . issue . id ) ?? node . issue
351- const issueId = issue . id
366+ const issue = node . issue ? ( itemIssues . get ( node . issue . id ) ?? node . issue ) : undefined
367+ const issueId = issue ? .id ?? ''
352368 const issueContext : ReviewContext = {
353369 ...context ,
354- getMarkdownValue : ( id , scope = issueId ) => textValues ( projectV3 . id , scope ) [ id ] ?? '' ,
355- getTextValue : ( id , scope = issueId ) => textValues ( projectV3 . id , scope ) [ id ] ?? '' ,
370+ getMarkdownValue : ( id , scope = issueId ) =>
371+ textValues ( projectV3 . id , scope ) [ id ] ?? textValues ( projectV3 . id , '' ) [ id ] ?? '' ,
372+ getTextValue : ( id , scope = issueId ) =>
373+ textValues ( projectV3 . id , scope ) [ id ] ?? textValues ( projectV3 . id , '' ) [ id ] ?? '' ,
356374 getSelectValue : ( id , scope = issueId ) =>
357- readSelectValues ( projectV3 . id , scope , id ) [ 0 ] ?? '' ,
358- getSelectValues : ( id , scope = issueId ) => readSelectValues ( projectV3 . id , scope , id ) ,
375+ contextSelectValues ( projectV3 . id , scope , id ) [ 0 ] ?? '' ,
376+ getSelectValues : ( id , scope = issueId ) => contextSelectValues ( projectV3 . id , scope , id ) ,
359377 selected : {
360378 items : { } ,
361379 issueIds : selectedIssueIds . value ,
362- toggleIds : [ ...selectedToggleIds ( projectV3 . id , issueId ) ] ,
380+ toggleIds : issue
381+ ? [ ...selectedToggleIds ( projectV3 . id , issueId ) ]
382+ : context . selected . toggleIds ,
363383 } ,
364384 }
365385 if ( resolveWithContext ( node . shown , issueContext ) === false ) continue
@@ -609,7 +629,7 @@ export function createReviewPanels(
609629 for ( const binding of panels . value . values ( ) ) {
610630 for ( const section of binding . panel . sections ) {
611631 for ( const control of section . controls ) {
612- if ( control . childToggleIds ) continue
632+ if ( control . childToggleIds || ! control . issue ) continue
613633 const issue : ReviewIssue = issues . get ( control . issueId ) ?? {
614634 id : control . issueId ,
615635 title : control . issue . title ,
@@ -716,6 +736,10 @@ export function createReviewPanels(
716736 const projectV3 = project . value
717737 if ( ! projectV3 ) return [ ]
718738 const issues = new Map < string , IssueSelection > ( )
739+ const sharedInputs = {
740+ textValues : { } as Record < string , string > ,
741+ selectValues : { } as Record < string , string [ ] > ,
742+ }
719743 for ( const entry of availableIssues . value ) {
720744 if ( session . read ( projectV3 . id , 'issue-active' ) [ entry . id ] !== true ) continue
721745 issues . set ( entry . id , {
@@ -733,7 +757,7 @@ export function createReviewPanels(
733757 : [ ] ,
734758 ) ,
735759 }
736- : entry . controls [ 0 ] . control . issue ,
760+ : entry . controls [ 0 ] . control . issue ! ,
737761 active : true ,
738762 keys : new Set ( ) ,
739763 textValues : { } ,
@@ -744,6 +768,14 @@ export function createReviewPanels(
744768 for ( const binding of panels . value . values ( ) ) {
745769 for ( const section of binding . panel . sections ) {
746770 for ( const control of section . controls ) {
771+ if ( ! control . issue ) {
772+ if ( control . disabled ) continue
773+ if ( control . type === 'select' )
774+ sharedInputs . selectValues [ control . key ] = selectValues ( binding , control )
775+ else if ( control . type !== 'toggle' )
776+ sharedInputs . textValues [ control . key ] = textValue ( binding , control )
777+ continue
778+ }
747779 if (
748780 control . childToggleIds ||
749781 control . disabled ||
@@ -791,10 +823,14 @@ export function createReviewPanels(
791823 issueIds : selectedIssueIds . value ,
792824 toggleIds : [ ...keys ] ,
793825 } ,
794- getMarkdownValue : ( key , scope = id ) => issues . get ( scope ) ?. textValues [ key ] ?? '' ,
795- getTextValue : ( key , scope = id ) => issues . get ( scope ) ?. textValues [ key ] ?? '' ,
796- getSelectValue : ( key , scope = id ) => issues . get ( scope ) ?. selectValues [ key ] ?. [ 0 ] ?? '' ,
797- getSelectValues : ( key , scope = id ) => issues . get ( scope ) ?. selectValues [ key ] ?? [ ] ,
826+ getMarkdownValue : ( key , scope = id ) =>
827+ issues . get ( scope ) ?. textValues [ key ] ?? sharedInputs . textValues [ key ] ?? '' ,
828+ getTextValue : ( key , scope = id ) =>
829+ issues . get ( scope ) ?. textValues [ key ] ?? sharedInputs . textValues [ key ] ?? '' ,
830+ getSelectValue : ( key , scope = id ) =>
831+ ( issues . get ( scope ) ?. selectValues [ key ] ?? sharedInputs . selectValues [ key ] ) ?. [ 0 ] ?? '' ,
832+ getSelectValues : ( key , scope = id ) =>
833+ issues . get ( scope ) ?. selectValues [ key ] ?? sharedInputs . selectValues [ key ] ?? [ ] ,
798834 }
799835 const controls = availableIssues . value . find ( ( entry ) => entry . id === id ) ?. controls ?? [ ]
800836 if (
@@ -829,11 +865,20 @@ export function createReviewPanels(
829865 } )
830866 } )
831867
832- const validationErrors = computed ( ( ) =>
833- activeIssues . value
868+ const validationErrors = computed ( ( ) => [
869+ ... activeIssues . value
834870 . filter ( ( { id } ) => ! isRestoredIssue ( id ) )
835871 . flatMap ( ( { id, missing } ) => missing . map ( ( key ) => ( { issueId : id , key } ) ) ) ,
836- )
872+ ...[ ...panels . value . values ( ) ] . flatMap ( ( binding ) =>
873+ binding . panel . sections . flatMap ( ( section ) =>
874+ section . controls . flatMap ( ( control ) =>
875+ ! control . issue && control . type !== 'toggle' && missing ( binding , control )
876+ ? [ { issueId : '' , key : control . key } ]
877+ : [ ] ,
878+ ) ,
879+ ) ,
880+ ) ,
881+ ] )
837882
838883 return {
839884 previousLinks : computed ( ( ) => reviewData . value . previousLinks ) ,
0 commit comments