4747 * A new commit's draft can become a `/feature` or `/bug` issue, as on the web
4848 * (see DraftsIssues).
4949 *
50+ * A guild's page opens it for a new commit on the guild's board, as the web's
51+ * guild page has its own composer (see composeInGuildSheet()): its own draft,
52+ * `guild:{handle}`, and no issue commands, as on the web. The commit goes to
53+ * the board, not to your log, and if devnull turns it down it goes back only
54+ * to that guild's page (see composerGuild()).
55+ *
5056 * A commit's page can open its reply in the same composer, for the photos and
5157 * the preview the reply bar has no room for (see replyInSheet()). The draft
5258 * is the reply bar's, and goes back to it when the sheet closes.
@@ -92,6 +98,11 @@ trait OpensCommitSheet
9298 */
9399 public string $ sheetView = 'report ' ;
94100
101+ /**
102+ * The guild whose board the new commit in the sheet goes to, or null for one that goes to your log.
103+ */
104+ public ?string $ sheetGuild = null ;
105+
95106 /**
96107 * The reason picked on the report form, or '' until one is.
97108 */
@@ -249,6 +260,18 @@ public function composeInSheet(): void
249260 $ this ->restoreSheetDraft ();
250261 }
251262
263+ /**
264+ * A new commit in the sheet for the board of the guild $handle, under its own draft.
265+ */
266+ protected function composeInGuildSheet (string $ handle ): void
267+ {
268+ $ this ->forgetCommitSheet ();
269+ $ this ->sheetView = 'compose ' ;
270+ $ this ->sheetGuild = $ handle ;
271+ $ this ->sheetOpen = true ;
272+ $ this ->restoreSheetDraft ();
273+ }
274+
252275 /**
253276 * The web's clock button, in a new commit's composer: it opens "Submit at" under the field, with no time picked,
254277 * or closes it, and the commit goes now again. Its photos or its poll go with it either way, as on the web.
@@ -335,6 +358,7 @@ public function commitFromSheet(): void
335358 'images ' => PendingWrite ::imagePayload ($ this ->sheetImages ),
336359 'stash ' => $ stashName ,
337360 'composer ' => $ this ->sheetView ,
361+ ...($ this ->sheetGuild === null ? [] : ['guild_handle ' => $ this ->sheetGuild ]),
338362 ]);
339363
340364 if ($ write === null ) {
@@ -432,7 +456,7 @@ protected function commitSheetGone(string $view): void
432456 */
433457 protected function reopenFailedCommit (PendingWrite $ write ): bool
434458 {
435- if ($ this ->sheetOpen || ($ write ->composer () === 'compose ' && ! $ this ->opensComposer ())) {
459+ if ($ this ->sheetOpen || ($ write ->composer () === 'compose ' && ( ! $ this ->opensComposer () || $ write -> guildHandle () !== $ this -> composerGuild () ))) {
436460 return false ;
437461 }
438462
@@ -448,14 +472,28 @@ protected function reopenFailedCommit(PendingWrite $write): bool
448472 /**
449473 * Edit, on the toast of a commit devnull turned down: its sheet, here if
450474 * the commit it quotes or replies to is showing, or the commit's own page.
451- * A new commit's sheet opens anywhere it can.
475+ * A new commit's sheet opens anywhere it can but a guild's page, which
476+ * sends it to the Log. One for a guild's board opens only on that guild's
477+ * page, which opens it.
452478 */
453479 protected function editFailedCommit (PendingWrite $ write ): void
454480 {
455481 if ($ this ->openFailedCommit ($ write )) {
456482 return ;
457483 }
458484
485+ if ($ write ->guildHandle () !== null ) {
486+ $ this ->openInTab ('/guilds/ ' .rawurlencode ($ write ->guildHandle ()), ['edit ' => $ write ->id ]);
487+
488+ return ;
489+ }
490+
491+ if ($ write ->composer () === 'compose ' ) {
492+ $ this ->composeInSheet ();
493+
494+ return ;
495+ }
496+
459497 $ for = $ write ->parentId () ?? $ write ->quotedCommitId ();
460498
461499 if ($ for !== null ) {
@@ -502,15 +540,30 @@ protected function opensComposer(): bool
502540 return false ;
503541 }
504542
543+ /**
544+ * The guild whose board this screen's composer posts to, or null when it posts to your log. A new commit devnull
545+ * turned down goes back only to a composer for the same place.
546+ */
547+ protected function composerGuild (): ?string
548+ {
549+ return null ;
550+ }
551+
505552 /**
506553 * Opens the sheet a commit devnull turned down was written in, with everything it had (see restoreSheetDraft()).
507554 */
508555 private function openFailedCommit (PendingWrite $ write ): bool
509556 {
510557 $ for = $ write ->parentId () ?? $ write ->quotedCommitId ();
511558
559+ $ guild = $ write ->guildHandle ();
560+
512561 match ($ write ->composer ()) {
513- 'compose ' => $ this ->composeInSheet (),
562+ 'compose ' => match (true ) {
563+ $ guild === null => $ this ->composerGuild () === null ? $ this ->composeInSheet () : null ,
564+ $ guild === $ this ->composerGuild () => $ this ->composeInGuildSheet ($ guild ),
565+ default => null ,
566+ },
514567 'quote ' => $ for === null ? null : $ this ->quoteCommit ($ for ),
515568 'reply ' => $ for === null ? null : $ this ->replyInSheet ($ for ),
516569 default => null ,
@@ -549,10 +602,11 @@ private function scheduleFromSheet(string $body, string $stashName): void
549602
550603 $ images = $ this ->sheetImages ;
551604 $ poll = $ this ->sheetPollPayload ();
605+ $ guild = $ this ->sheetGuild ;
552606 $ this ->sendingSchedule = true ;
553607 $ this ->sheetError = null ;
554608
555- $ this ->sendInBackground (fn (Client $ devnull ): SignedRequest => $ devnull ->signedScheduledCommit ($ body , $ at , $ images , $ poll ), function () use ($ me , $ stashName , $ images ): void {
609+ $ this ->sendInBackground (fn (Client $ devnull ): SignedRequest => $ devnull ->signedScheduledCommit ($ body , $ at , $ images , $ poll, $ guild ), function () use ($ me , $ stashName , $ images ): void {
556610 $ this ->sendingSchedule = false ;
557611 app (ResponseCache::class)->forget (Client::ScheduledCommitsPath);
558612 app (Stash::class)->put ($ me ->id , $ stashName , new StashedDraft );
@@ -571,6 +625,7 @@ private function forgetCommitSheet(): void
571625 $ this ->sheetOpen = false ;
572626 $ this ->sheetCommit = null ;
573627 $ this ->sheetView = 'report ' ;
628+ $ this ->sheetGuild = null ;
574629 $ this ->reportReason = '' ;
575630 $ this ->reportDetails = '' ;
576631 $ this ->sheetBody = '' ;
@@ -592,7 +647,7 @@ private function forgetCommitSheet(): void
592647 private function sheetStashName (): ?string
593648 {
594649 return match (true ) {
595- $ this ->sheetView === 'compose ' => 'commit ' ,
650+ $ this ->sheetView === 'compose ' => $ this -> sheetGuild === null ? 'commit ' : ' guild: ' . $ this -> sheetGuild ,
596651 $ this ->sheetView === 'quote ' && $ this ->sheetCommit !== null => 'quote- ' .$ this ->sheetCommit ->id ,
597652 $ this ->sheetView === 'reply ' && $ this ->sheetCommit !== null => 'reply- ' .$ this ->sheetCommit ->id ,
598653 default => null ,
0 commit comments