@@ -5,24 +5,37 @@ import {ProjectAvatar} from '@sentry/scraps/avatar';
55
66import { CMDKAction } from 'sentry/components/commandPalette/ui/cmdk' ;
77import { CommandPaletteSlot } from 'sentry/components/commandPalette/ui/commandPaletteSlot' ;
8+ import { IconCode , IconProject , IconStack } from 'sentry/icons' ;
89import type { Organization } from 'sentry/types/organization' ;
910import type { Project } from 'sentry/types/project' ;
1011import { replaceRouterParams } from 'sentry/utils/replaceRouterParams' ;
1112import { getNavigationConfiguration } from 'sentry/views/settings/project/navigationConfiguration' ;
1213import type { NavigationGroupProps , NavigationItem } from 'sentry/views/settings/types' ;
1314
14- type ProjectSettingsCommandPaletteAction = {
15+ type ProjectSettingsCommandPaletteEntry = {
1516 display : {
1617 label : string ;
1718 } ;
1819 keywords : string [ ] ;
1920 to : string ;
2021} ;
2122
23+ type ProjectSettingsCommandPaletteGroup = {
24+ items : Array < {
25+ display : {
26+ label : string ;
27+ } ;
28+ keywords : string [ ] ;
29+ to : string ;
30+ } > ;
31+ label : string ;
32+ icon ?: ReactNode ;
33+ } ;
34+
2235type ProjectSettingsCommandPaletteSection = {
23- icon : ReactNode ;
24- items : ProjectSettingsCommandPaletteAction [ ] ;
36+ items : Array < ProjectSettingsCommandPaletteEntry | ProjectSettingsCommandPaletteGroup > ;
2537 label : string ;
38+ icon ?: ReactNode ;
2639} ;
2740
2841function shouldShowItem (
@@ -50,29 +63,77 @@ export function getProjectSettingsCommandPaletteSections({
5063 organization,
5164 project,
5265 } ;
66+ const groupedSectionLabels = new Set ( [
67+ 'General' ,
68+ 'Processing' ,
69+ 'SDK setup' ,
70+ 'Legacy Integrations' ,
71+ ] ) ;
5372
54- return getNavigationConfiguration ( {
73+ const sections = getNavigationConfiguration ( {
5574 debugFilesNeedsReview : false ,
5675 organization,
5776 project,
5877 } )
59- . map ( section => ( {
60- icon : < ProjectAvatar project = { project } size = { 16 } /> ,
61- label : section . name ,
62- items : section . items
63- . filter ( item => shouldShowItem ( item , context , section ) )
64- . map ( item => ( {
65- display : {
66- label : item . title ,
67- } ,
68- keywords : [ section . name , 'project settings' , 'settings' ] ,
69- to : replaceRouterParams ( item . path , {
70- orgId : organization . slug ,
71- projectId : project . slug ,
72- } ) ,
73- } ) ) ,
74- } ) )
78+ . map ( section => {
79+ const label =
80+ section . name === 'Project'
81+ ? 'General'
82+ : section . name === 'SDK Setup'
83+ ? 'SDK setup'
84+ : section . name ;
85+
86+ return {
87+ icon : groupedSectionLabels . has ( label ) ? (
88+ label === 'General' ? (
89+ < IconProject />
90+ ) : label === 'Processing' ? (
91+ < IconStack />
92+ ) : label === 'SDK setup' ? (
93+ < IconCode />
94+ ) : undefined
95+ ) : (
96+ < ProjectAvatar project = { project } size = { 16 } />
97+ ) ,
98+ label,
99+ items : section . items
100+ . filter ( item => shouldShowItem ( item , context , section ) )
101+ . map ( item => ( {
102+ display : {
103+ label : item . title ,
104+ } ,
105+ keywords : [ section . name , 'project settings' , 'settings' ] ,
106+ to : replaceRouterParams ( item . path , {
107+ orgId : organization . slug ,
108+ projectId : project . slug ,
109+ } ) ,
110+ } ) ) ,
111+ } ;
112+ } )
75113 . filter ( section => section . items . length > 0 ) ;
114+ const groupedSections = sections . filter ( section =>
115+ groupedSectionLabels . has ( section . label )
116+ ) ;
117+ const ungroupedSections = sections . filter (
118+ section => ! groupedSectionLabels . has ( section . label )
119+ ) ;
120+
121+ if ( groupedSections . length === 0 ) {
122+ return ungroupedSections ;
123+ }
124+
125+ return [
126+ {
127+ icon : < ProjectAvatar project = { project } size = { 16 } /> ,
128+ label : 'Project Settings' ,
129+ items : groupedSections . map ( section =>
130+ section . label === 'Legacy Integrations' && section . items . length > 0
131+ ? section . items [ 0 ] !
132+ : section
133+ ) ,
134+ } ,
135+ ...ungroupedSections ,
136+ ] ;
76137}
77138
78139export function ProjectSettingsCommandPaletteActions ( {
@@ -86,15 +147,30 @@ export function ProjectSettingsCommandPaletteActions({
86147
87148 return (
88149 < Fragment >
89- { sections . map ( section => (
90- < CommandPaletteSlot key = { section . label } name = "page" >
91- < CMDKAction display = { { label : section . label , icon : section . icon } } >
92- { section . items . map ( item => (
93- < CMDKAction key = { item . to } { ...item } />
94- ) ) }
95- </ CMDKAction >
96- </ CommandPaletteSlot >
97- ) ) }
150+ { sections . map ( section => {
151+ return (
152+ < CommandPaletteSlot key = { section . label } name = "page" >
153+ < CMDKAction display = { { label : section . label , icon : section . icon } } >
154+ { section . items . map ( item => {
155+ if ( 'items' in item ) {
156+ return (
157+ < CMDKAction
158+ key = { item . label }
159+ display = { { label : item . label , icon : item . icon } }
160+ >
161+ { item . items . map ( action => (
162+ < CMDKAction key = { action . to } { ...action } />
163+ ) ) }
164+ </ CMDKAction >
165+ ) ;
166+ }
167+
168+ return < CMDKAction key = { item . to } { ...item } /> ;
169+ } ) }
170+ </ CMDKAction >
171+ </ CommandPaletteSlot >
172+ ) ;
173+ } ) }
98174 </ Fragment >
99175 ) ;
100176}
0 commit comments