11import { BookOpen , ClipboardList , File , Table , Users } from '@sim/emcn/icons'
22import { GoogleTranslateIcon , GreptileIcon , SlackIcon } from '@/components/icons'
3- import { isSlackExtendedScopesEnabled } from '@/lib/core/config/env-flags'
43import { getScopesForService } from '@/lib/oauth/utils'
54import type { BlockConfig , BlockMeta , SubBlockConfig } from '@/blocks/types'
65import { AuthMode , IntegrationType } from '@/blocks/types'
@@ -16,18 +15,6 @@ import { getTrigger } from '@/triggers'
1615/** The operations that offer a channel/DM switch, and so honour it. */
1716const DESTINATION_SWITCH_OPERATIONS = [ 'send' , 'read' , 'schedule_message' ] as const
1817
19- const SLACK_EXTENDED_SCOPE_OPERATION_IDS = new Set ( [
20- 'set_status' ,
21- 'set_title' ,
22- 'set_suggested_prompts' ,
23- ] )
24-
25- const SLACK_EXTENDED_SCOPE_TOOL_IDS = new Set ( [
26- 'slack_set_status' ,
27- 'slack_set_title' ,
28- 'slack_set_suggested_prompts' ,
29- ] )
30-
3118const CHANNEL_FIELD = [ 'channel' , 'manualChannel' ] as const
3219
3320/**
@@ -2934,16 +2921,8 @@ const SLACK_WEBHOOK_TRIGGER_SUBBLOCK_IDS = new Set(
29342921 * Adapts a v1 subblock for slack_v2's merged credential picker: fields gated on
29352922 * the removed `authMethod` dropdown now depend on the single `credential` field.
29362923 */
2937- function adaptSubBlockForV2 ( sb : SubBlockConfig , extendedScopesEnabled : boolean ) : SubBlockConfig {
2924+ function adaptSubBlockForV2 ( sb : SubBlockConfig ) : SubBlockConfig {
29382925 const { dependsOn, condition, ...rest } = sb
2939- if ( sb . id === 'operation' && ! extendedScopesEnabled ) {
2940- const options = typeof sb . options === 'function' ? sb . options ( ) : sb . options
2941- if ( ! options ) throw new Error ( 'Slack operation subblock must define options' )
2942- return {
2943- ...sb ,
2944- options : options . filter ( ( option ) => ! SLACK_EXTENDED_SCOPE_OPERATION_IDS . has ( option . id ) ) ,
2945- }
2946- }
29472926 if ( sb . id === 'credential' ) {
29482927 return {
29492928 ...rest ,
@@ -2966,31 +2945,24 @@ function adaptSubBlockForV2(sb: SubBlockConfig, extendedScopesEnabled: boolean):
29662945 return sb
29672946}
29682947
2969- export function getSlackV2ActionSubBlocks ( extendedScopesEnabled : boolean ) : SubBlockConfig [ ] {
2948+ export function getSlackV2ActionSubBlocks ( ) : SubBlockConfig [ ] {
29702949 return SlackBlock . subBlocks . flatMap ( ( sb ) => {
29712950 if ( SLACK_WEBHOOK_TRIGGER_SUBBLOCK_IDS . has ( sb . id ) ) return [ ]
29722951 if ( sb . id === 'authMethod' ) return [ ]
2973- return [ adaptSubBlockForV2 ( sb , extendedScopesEnabled ) ]
2952+ return [ adaptSubBlockForV2 ( sb ) ]
29742953 } )
29752954}
29762955
2977- export function getSlackV2ToolAccess ( extendedScopesEnabled : boolean ) : string [ ] {
2978- if ( extendedScopesEnabled ) return [ ...SlackBlock . tools . access ]
2979- return SlackBlock . tools . access . filter ( ( toolId ) => ! SLACK_EXTENDED_SCOPE_TOOL_IDS . has ( toolId ) )
2956+ export function getSlackV2ToolAccess ( ) : string [ ] {
2957+ return [ ...SlackBlock . tools . access ]
29802958}
29812959
2982- export function getSlackV2OperationSentences ( extendedScopesEnabled : boolean ) {
2960+ export function getSlackV2OperationSentences ( ) {
29832961 const operationSentences = SlackBlock . canvasPresentation ?. sentences ?. byOperation
29842962 if ( ! operationSentences ) {
29852963 throw new Error ( 'Slack action sentences must be defined before building slack_v2' )
29862964 }
2987- if ( extendedScopesEnabled ) return { ...operationSentences }
2988-
2989- const scopedSentences = { ...operationSentences }
2990- for ( const operationId of SLACK_EXTENDED_SCOPE_OPERATION_IDS ) {
2991- delete scopedSentences [ operationId ]
2992- }
2993- return scopedSentences
2965+ return { ...operationSentences }
29942966}
29952967
29962968const {
@@ -3017,7 +2989,7 @@ export const SlackV2Block: BlockConfig<SlackResponse> = {
30172989 defaultTitle : 'Slack' ,
30182990 sentences : {
30192991 ...SlackBlock . canvasPresentation ?. sentences ,
3020- byOperation : getSlackV2OperationSentences ( isSlackExtendedScopesEnabled ) ,
2992+ byOperation : getSlackV2OperationSentences ( ) ,
30212993 } ,
30222994 /*
30232995 * Unlike v1, this trigger picks one event and scopes it, so the card names
@@ -3038,13 +3010,10 @@ export const SlackV2Block: BlockConfig<SlackResponse> = {
30383010 ] ,
30393011 } ,
30403012 } ,
3041- subBlocks : [
3042- ...getSlackV2ActionSubBlocks ( isSlackExtendedScopesEnabled ) ,
3043- ...getTrigger ( 'slack_oauth' ) . subBlocks ,
3044- ] ,
3013+ subBlocks : [ ...getSlackV2ActionSubBlocks ( ) , ...getTrigger ( 'slack_oauth' ) . subBlocks ] ,
30453014 tools : {
30463015 ...SlackBlock . tools ,
3047- access : getSlackV2ToolAccess ( isSlackExtendedScopesEnabled ) ,
3016+ access : getSlackV2ToolAccess ( ) ,
30483017 } ,
30493018 inputs : {
30503019 ...slackV2Inputs ,
0 commit comments