@@ -18,7 +18,11 @@ import { SlackIcon } from '@/components/icons'
1818import { SlackAppManifest } from '@/components/integrations/slack-app-manifest'
1919import { resourceScopeFields , resourceScopeFromOwner } from '@/lib/core/resource-scope'
2020import { getBaseUrl } from '@/lib/core/utils/urls'
21- import { buildSlackAppCreationUrl , getSlackAppNameError } from '@/lib/integrations/slack-manifest'
21+ import {
22+ buildSlackAppCreationUrl ,
23+ getSlackAppNameError ,
24+ SLACK_APP_CREATION_URL_MAX_LENGTH ,
25+ } from '@/lib/integrations/slack-manifest'
2226import { SLACK_CUSTOM_BOT_PROVIDER_ID } from '@/lib/oauth/types'
2327import {
2428 useCreateScopedCredential ,
@@ -205,6 +209,12 @@ export function ConnectSlackBotModal({
205209 searchOnly ,
206210 ] )
207211
212+ const createAppUrl = buildSlackAppCreationUrl ( manifestJson )
213+ const creationUrlError =
214+ createAppUrl . length > SLACK_APP_CREATION_URL_MAX_LENGTH
215+ ? 'This app configuration is too large to open in Slack. Shorten or remove slash commands.'
216+ : null
217+
208218 const capabilityIds = [ ...selected ]
209219 const setCapabilityIds = ( next : string [ ] ) => setSelected ( new Set ( next ) )
210220
@@ -271,7 +281,12 @@ export function ConnectSlackBotModal({
271281 fallback, which collides for a second bot in the same workspace. */ }
272282 < Wizard . Step
273283 title = { searchOnly ? 'Name your Slack app' : 'Configure your bot' }
274- canAdvance = { appName . trim ( ) . length > 0 && ! nameError && ! manifestConfigurationError }
284+ canAdvance = {
285+ appName . trim ( ) . length > 0 &&
286+ ! nameError &&
287+ ! manifestConfigurationError &&
288+ ! creationUrlError
289+ }
275290 >
276291 < StepConfigure
277292 searchOnly = { searchOnly }
@@ -284,13 +299,17 @@ export function ConnectSlackBotModal({
284299 descriptionError = { descriptionError }
285300 slashCommands = { slashCommands }
286301 onSlashCommandsChange = { setSlashCommands }
287- slashCommandsError = { slashCommandsError }
302+ slashCommandsError = { slashCommandsError ?? creationUrlError }
288303 capabilityIds = { capabilityIds }
289304 onCapabilityIdsChange = { setCapabilityIds }
290305 />
291306 </ Wizard . Step >
292307 < Wizard . Step title = { isReconnect ? 'Open your app in Slack' : 'Create the app in Slack' } >
293- < StepCreate manifestJson = { manifestJson } reconnect = { isReconnect } />
308+ < StepCreate
309+ manifestJson = { manifestJson }
310+ createAppUrl = { createAppUrl }
311+ reconnect = { isReconnect }
312+ />
294313 </ Wizard . Step >
295314 < Wizard . Step title = 'Install and paste your Bot Token' canAdvance = { botToken . trim ( ) . length > 0 } >
296315 < StepToken value = { botToken } onChange = { setBotToken } reconnect = { isReconnect } />
@@ -496,9 +515,10 @@ function SlashCommandsEditor({ commands, onChange, error }: SlashCommandsEditorP
496515
497516interface StepCreateProps {
498517 manifestJson : string
518+ createAppUrl : string
499519 reconnect : boolean
500520}
501- function StepCreate ( { manifestJson, reconnect } : StepCreateProps ) {
521+ function StepCreate ( { manifestJson, createAppUrl , reconnect } : StepCreateProps ) {
502522 if ( reconnect ) {
503523 return (
504524 < SubStepList >
@@ -528,10 +548,7 @@ function StepCreate({ manifestJson, reconnect }: StepCreateProps) {
528548 < SubStep n = { 1 } >
529549 < div > Open Slack with the manifest for your selected permissions already filled in:</ div >
530550 < div className = 'mt-2' >
531- < SlackAppManifest
532- manifest = { manifestJson }
533- createAppUrl = { buildSlackAppCreationUrl ( manifestJson ) }
534- />
551+ < SlackAppManifest manifest = { manifestJson } createAppUrl = { createAppUrl } />
535552 </ div >
536553 </ SubStep >
537554 < SubStep n = { 2 } >
0 commit comments