@@ -572,8 +572,8 @@ class Views extends TableView {
572572 // Remove focus after action to follow UX best practices
573573 e . currentTarget . blur ( ) ;
574574 } }
575- aria-label = { `Open all pointers in ${ name } column in new tabs ` }
576- title = "Open all pointers in new tabs "
575+ aria-label = { `Filter to show all pointers from ${ name } column` }
576+ title = "Filter to show all pointers from this column "
577577 >
578578 < Icon
579579 name = "right-outline"
@@ -870,59 +870,48 @@ class Views extends TableView {
870870 . map ( row => row [ columnName ] )
871871 . filter ( value => value && value . __type === 'Pointer' && value . className && value . objectId ) ;
872872
873- // Open each unique pointer in a new tab
874- const uniquePointers = new Map ( ) ;
873+ if ( pointers . length === 0 ) {
874+ this . showNote ( 'No pointers found in this column' , true ) ;
875+ return ;
876+ }
877+
878+ // Group pointers by target class
879+ const pointersByClass = new Map ( ) ;
875880 pointers . forEach ( pointer => {
876- // Use a more collision-proof key format with explicit separators
877- const key = `className:${ pointer . className } |objectId:${ pointer . objectId } ` ;
878- if ( ! uniquePointers . has ( key ) ) {
879- uniquePointers . set ( key , pointer ) ;
881+ if ( ! pointersByClass . has ( pointer . className ) ) {
882+ pointersByClass . set ( pointer . className , new Set ( ) ) ;
880883 }
884+ pointersByClass . get ( pointer . className ) . add ( pointer . objectId ) ;
881885 } ) ;
882886
883- if ( uniquePointers . size === 0 ) {
884- this . showNote ( 'No pointers found in this column' , true ) ;
887+ // If multiple target classes, show error
888+ if ( pointersByClass . size > 1 ) {
889+ const classNames = Array . from ( pointersByClass . keys ( ) ) . join ( ', ' ) ;
890+ this . showNote ( `Cannot filter pointers from multiple classes: ${ classNames } . Please use this feature on columns with pointers to a single class.` , true ) ;
885891 return ;
886892 }
887893
888- const pointersArray = Array . from ( uniquePointers . values ( ) ) ;
894+ // Get the single target class and unique object IDs
895+ const targetClassName = Array . from ( pointersByClass . keys ( ) ) [ 0 ] ;
896+ const uniqueObjectIds = Array . from ( pointersByClass . get ( targetClassName ) ) ;
889897
890- // Confirm for large numbers of tabs to prevent overwhelming the user
891- if ( pointersArray . length > 10 ) {
892- const confirmMessage = `This will open ${ pointersArray . length } new tabs. This might overwhelm your browser. Continue?` ;
893- if ( ! confirm ( confirmMessage ) ) {
894- return ;
895- }
896- }
898+ // Navigate to the target class with containedIn filter
899+ const filters = JSON . stringify ( [ {
900+ field : 'objectId' ,
901+ constraint : 'containedIn' ,
902+ compareTo : uniqueObjectIds
903+ } ] ) ;
897904
898- // Open all tabs immediately to maintain user activation context
899- let errorCount = 0 ;
905+ const path = generatePath (
906+ this . context ,
907+ `browser/${ targetClassName } ?filters=${ encodeURIComponent ( filters ) } ` ,
908+ true
909+ ) ;
900910
901- pointersArray . forEach ( ( pointer ) => {
902- try {
903- const filters = JSON . stringify ( [ { field : 'objectId' , constraint : 'eq' , compareTo : pointer . objectId } ] ) ;
904- const url = generatePath (
905- this . context ,
906- `browser/${ pointer . className } ?filters=${ encodeURIComponent ( filters ) } ` ,
907- true
908- ) ;
909- window . open ( url , '_blank' , 'noopener,noreferrer' ) ;
910- // Note: window.open with security attributes may return null even when successful,
911- // so we assume success unless an exception is thrown
912- } catch ( error ) {
913- console . error ( 'Failed to open tab for pointer:' , pointer , error ) ;
914- errorCount ++ ;
915- }
916- } ) ;
911+ window . open ( path , '_blank' , 'noopener,noreferrer' ) ;
917912
918- // Show result notification
919- if ( errorCount === 0 ) {
920- this . showNote ( `Opened ${ pointersArray . length } pointer${ pointersArray . length > 1 ? 's' : '' } in new tab${ pointersArray . length > 1 ? 's' : '' } ` , false ) ;
921- } else if ( errorCount < pointersArray . length ) {
922- this . showNote ( `Opened ${ pointersArray . length - errorCount } of ${ pointersArray . length } tabs. ${ errorCount } failed to open.` , true ) ;
923- } else {
924- this . showNote ( 'Unable to open tabs. Please allow popups for this site and try again.' , true ) ;
925- }
913+ // Show success notification
914+ this . showNote ( `Applied filter to show ${ uniqueObjectIds . length } pointer${ uniqueObjectIds . length > 1 ? 's' : '' } from ${ targetClassName } ` , false ) ;
926915 }
927916
928917 showNote ( message , isError ) {
0 commit comments