@@ -9,7 +9,10 @@ import {
99 isAtomCommandInterrupted ,
1010 squashAtomCommandFailure ,
1111} from "@t3tools/client-runtime/state/runtime" ;
12- import { deriveProjectGroupLabel } from "@t3tools/client-runtime/state/project-grouping" ;
12+ import {
13+ deriveProjectGroupLabel ,
14+ type ProjectGroup ,
15+ } from "@t3tools/client-runtime/state/project-grouping" ;
1316import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell" ;
1417import { useNavigation } from "@react-navigation/native" ;
1518import { useRef , useState } from "react" ;
@@ -34,6 +37,7 @@ import { useAtomCommand } from "../../state/use-atom-command";
3437import { SettingsScreen } from "./components/SettingsScreen" ;
3538import { SettingsSection } from "./components/SettingsSection" ;
3639import { SettingsActionRow } from "./components/SettingsActionRow" ;
40+ import { SettingsSwitchRow } from "./components/SettingsSwitchRow" ;
3741import {
3842 AndroidSettingsEnvironmentFilter ,
3943 SettingsEnvironmentFilterHeader ,
@@ -59,6 +63,7 @@ export function SettingsProjectOverviewRouteScreen() {
5963 } ;
6064 const navigation = useNavigation ( ) ;
6165 const {
66+ availableTargets,
6267 selectedTargets,
6368 projectGroups,
6469 selectedProjectKey,
@@ -95,7 +100,7 @@ export function SettingsProjectOverviewRouteScreen() {
95100 < Text className = "px-2 text-base text-foreground-muted" >
96101 Choose a project with the filter above to manage its name, checkouts and removal.
97102 </ Text >
98- ) : members . length === 0 ? (
103+ ) : ! group || members . length === 0 ? (
99104 < Text className = "px-2 text-base text-foreground-muted" >
100105 This project has no checkout on the selected connected environments. Change the filter
101106 above.
@@ -104,6 +109,8 @@ export function SettingsProjectOverviewRouteScreen() {
104109 < ProjectOverviewContent
105110 key = { `${ selectedProjectKey } :${ members . map ( ( member ) => member . id ) . join ( "," ) } ` }
106111 members = { members }
112+ group = { group }
113+ connectedTargets = { availableTargets }
107114 environments = { selectedTargets }
108115 hasOtherMembers = { members . length < ( group ?. members . length ?? 0 ) }
109116 isRemoving = { isRemoving }
@@ -122,6 +129,9 @@ export function SettingsProjectOverviewRouteScreen() {
122129
123130function ProjectOverviewContent ( props : {
124131 readonly members : readonly EnvironmentProject [ ] ;
132+ /** Pin and archive belong to the whole project, even when the filter picks one machine. */
133+ readonly group : ProjectGroup ;
134+ readonly connectedTargets : readonly SettingsTarget [ ] ;
125135 readonly environments : readonly SettingsTarget [ ] ;
126136 readonly hasOtherMembers : boolean ;
127137 readonly isRemoving : boolean ;
@@ -149,6 +159,31 @@ function ProjectOverviewContent(props: {
149159 label : "project name update" ,
150160 reportFailure : true ,
151161 } ) ;
162+ const organizeProject = useAtomCommand ( projectEnvironment . update , {
163+ label : "project update" ,
164+ reportFailure : true ,
165+ } ) ;
166+ const [ isOrganizing , setIsOrganizing ] = useState ( false ) ;
167+ const allMembers = props . group . members . map ( ( member ) => member . project ) ;
168+ // Older servers drop pin and archive, so their projects do not offer them.
169+ const canOrganize =
170+ canRemoveGroup &&
171+ allMembers . every (
172+ ( member ) =>
173+ props . connectedTargets . find ( ( entry ) => entry . environmentId === member . environmentId )
174+ ?. serverConfig . environment . capabilities . projectOrganization === true ,
175+ ) ;
176+ const organize = ( input : { readonly pinned ?: boolean ; readonly archived ?: boolean } ) => {
177+ setIsOrganizing ( true ) ;
178+ void Promise . all (
179+ allMembers . map ( ( member ) =>
180+ organizeProject ( {
181+ environmentId : member . environmentId ,
182+ input : { projectId : member . id , ...input } ,
183+ } ) ,
184+ ) ,
185+ ) . finally ( ( ) => setIsOrganizing ( false ) ) ;
186+ } ;
152187 const nextName = ( draftName ?? displayName ) . trim ( ) ;
153188 const canSave = ! isSaving && nextName . length > 0 && nextName !== displayName ;
154189
@@ -295,6 +330,30 @@ function ProjectOverviewContent(props: {
295330 </ View >
296331 </ SettingsSection >
297332
333+ { canOrganize ? (
334+ < SettingsSection title = "Organize" >
335+ < SettingsSwitchRow
336+ icon = "pin"
337+ label = "Pin"
338+ subtitle = "Pinned projects come first in project pickers."
339+ value = { props . group . pinned }
340+ disabled = { isOrganizing }
341+ onValueChange = { ( pinned ) => organize ( { pinned } ) }
342+ />
343+ < SettingsActionRow
344+ icon = "archivebox"
345+ label = { props . group . archived ? "Unarchive project" : "Archive project" }
346+ description = {
347+ props . group . archived
348+ ? "Hidden from project pickers. Threads and files are kept."
349+ : "Hides the project from project pickers. Threads and files are kept."
350+ }
351+ disabled = { isOrganizing }
352+ onPress = { ( ) => organize ( { archived : ! props . group . archived } ) }
353+ />
354+ </ SettingsSection >
355+ ) : null }
356+
298357 < SettingsSection title = "Checkouts" >
299358 { props . members . map ( ( member , index ) => {
300359 const environment = props . environments . find (
0 commit comments