Merge pull request #2272 from alipgoldberg/setup-channel-back-nav-pr3-slack
setup: add ← Back option to Slack channel flow
This commit is contained in:
@@ -464,7 +464,7 @@ async function main(): Promise<void> {
|
|||||||
} else if (channelChoice === 'teams') {
|
} else if (channelChoice === 'teams') {
|
||||||
await runTeamsChannel(displayName!);
|
await runTeamsChannel(displayName!);
|
||||||
} else if (channelChoice === 'slack') {
|
} else if (channelChoice === 'slack') {
|
||||||
await runSlackChannel(displayName!);
|
result = await runSlackChannel(displayName!);
|
||||||
} else if (channelChoice === 'imessage') {
|
} else if (channelChoice === 'imessage') {
|
||||||
result = await runIMessageChannel(displayName!);
|
result = await runIMessageChannel(displayName!);
|
||||||
} else if (channelChoice === 'other') {
|
} else if (channelChoice === 'other') {
|
||||||
|
|||||||
@@ -25,7 +25,10 @@ import * as p from '@clack/prompts';
|
|||||||
import k from 'kleur';
|
import k from 'kleur';
|
||||||
|
|
||||||
import * as setupLog from '../logs.js';
|
import * as setupLog from '../logs.js';
|
||||||
import { confirmThenOpen, formatNoteLink } from '../lib/browser.js';
|
import { BACK_TO_CHANNEL_SELECTION, type ChannelFlowResult } from '../lib/back-nav.js';
|
||||||
|
import { brightSelect } from '../lib/bright-select.js';
|
||||||
|
import { formatNoteLink, openUrl } from '../lib/browser.js';
|
||||||
|
import { isHeadless } from '../platform.js';
|
||||||
import { askOperatorRole } from '../lib/role-prompt.js';
|
import { askOperatorRole } from '../lib/role-prompt.js';
|
||||||
import { ensureAnswer, fail, runQuietChild } from '../lib/runner.js';
|
import { ensureAnswer, fail, runQuietChild } from '../lib/runner.js';
|
||||||
import { readEnvKey } from '../environment.js';
|
import { readEnvKey } from '../environment.js';
|
||||||
@@ -42,8 +45,9 @@ interface WorkspaceInfo {
|
|||||||
botUserId: string;
|
botUserId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runSlackChannel(displayName: string): Promise<void> {
|
export async function runSlackChannel(displayName: string): Promise<ChannelFlowResult> {
|
||||||
await walkThroughAppCreation();
|
const intro = await walkThroughAppCreation();
|
||||||
|
if (intro === 'back') return BACK_TO_CHANNEL_SELECTION;
|
||||||
|
|
||||||
const token = await collectBotToken();
|
const token = await collectBotToken();
|
||||||
const signingSecret = await collectSigningSecret();
|
const signingSecret = await collectSigningSecret();
|
||||||
@@ -121,7 +125,7 @@ export async function runSlackChannel(displayName: string): Promise<void> {
|
|||||||
showPostInstallChecklist(info);
|
showPostInstallChecklist(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function walkThroughAppCreation(): Promise<void> {
|
async function walkThroughAppCreation(): Promise<'continue' | 'back'> {
|
||||||
note(
|
note(
|
||||||
[
|
[
|
||||||
"You'll create a Slack app that the assistant talks through.",
|
"You'll create a Slack app that the assistant talks through.",
|
||||||
@@ -140,7 +144,20 @@ async function walkThroughAppCreation(): Promise<void> {
|
|||||||
].filter((line): line is string => line !== null).join('\n'),
|
].filter((line): line is string => line !== null).join('\n'),
|
||||||
'Create a Slack app',
|
'Create a Slack app',
|
||||||
);
|
);
|
||||||
await confirmThenOpen(SLACK_APPS_URL, 'Press Enter to open Slack app settings');
|
|
||||||
|
// Back-aware gate replacing the old `confirmThenOpen` "Press Enter to open
|
||||||
|
// Slack app settings" so users can bail out of Slack before we open the
|
||||||
|
// browser or ask for tokens.
|
||||||
|
const choice = ensureAnswer(await brightSelect<'open' | 'back'>({
|
||||||
|
message: 'Open Slack app settings in your browser?',
|
||||||
|
options: [
|
||||||
|
{ value: 'open', label: 'Open Slack app settings' },
|
||||||
|
{ value: 'back', label: '← Back to channel selection' },
|
||||||
|
],
|
||||||
|
initialValue: 'open',
|
||||||
|
}));
|
||||||
|
if (choice === 'back') return 'back';
|
||||||
|
if (!isHeadless()) openUrl(SLACK_APPS_URL);
|
||||||
|
|
||||||
ensureAnswer(
|
ensureAnswer(
|
||||||
await p.confirm({
|
await p.confirm({
|
||||||
@@ -148,6 +165,7 @@ async function walkThroughAppCreation(): Promise<void> {
|
|||||||
initialValue: true,
|
initialValue: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
return 'continue';
|
||||||
}
|
}
|
||||||
|
|
||||||
async function collectBotToken(): Promise<string> {
|
async function collectBotToken(): Promise<string> {
|
||||||
|
|||||||
Reference in New Issue
Block a user