@@ -122,11 +122,26 @@ def handle_button_click(body: dict, client: WebClient, context: BoltContext) ->
122
122
cache_for_dublicate_requests ["permission_set_name" ] = payload .request .permission_set_name
123
123
124
124
if payload .action == entities .ApproverAction .Discard :
125
- slack_helpers .remove_buttons (payload , client , approver )
125
+ blocks = slack_helpers .HeaderSectionBlock .set_color_coding (
126
+ blocks = payload .message ["blocks" ],
127
+ color_coding_emoji = cfg .bad_result_emoji ,
128
+ )
129
+
130
+ blocks = slack_helpers .remove_blocks (blocks , block_ids = ["buttons" ])
131
+ blocks .append (slack_helpers .button_click_info_block (payload .action , approver .id ).to_dict ())
132
+
133
+ text = f"Request was discarded by<@{ approver .id } > "
134
+ client .chat_update (
135
+ channel = payload .channel_id ,
136
+ ts = payload .thread_ts ,
137
+ blocks = blocks ,
138
+ text = text ,
139
+ )
140
+
126
141
cache_for_dublicate_requests .clear ()
127
142
return client .chat_postMessage (
128
143
channel = payload .channel_id ,
129
- text = f"Request was discarded by<@ { approver . id } > " ,
144
+ text = text ,
130
145
thread_ts = payload .thread_ts ,
131
146
)
132
147
@@ -147,7 +162,21 @@ def handle_button_click(body: dict, client: WebClient, context: BoltContext) ->
147
162
text = f"<@{ approver .id } > you can not approve this request" ,
148
163
thread_ts = payload .thread_ts ,
149
164
)
150
- slack_helpers .remove_buttons (payload , client , approver )
165
+
166
+ text = f"Permissions granted to <@{ requester .id } > by <@{ approver .id } >."
167
+ blocks = slack_helpers .HeaderSectionBlock .set_color_coding (
168
+ blocks = payload .message ["blocks" ],
169
+ color_coding_emoji = cfg .good_result_emoji ,
170
+ )
171
+
172
+ blocks = slack_helpers .remove_blocks (blocks , block_ids = ["buttons" ])
173
+ blocks .append (slack_helpers .button_click_info_block (payload .action , approver .id ).to_dict ())
174
+ client .chat_update (
175
+ channel = payload .channel_id ,
176
+ ts = payload .thread_ts ,
177
+ blocks = blocks ,
178
+ text = text ,
179
+ )
151
180
152
181
access_control .execute_decision (
153
182
decision = decision ,
@@ -161,7 +190,7 @@ def handle_button_click(body: dict, client: WebClient, context: BoltContext) ->
161
190
cache_for_dublicate_requests .clear ()
162
191
return client .chat_postMessage (
163
192
channel = payload .channel_id ,
164
- text = f"Permissions granted to <@ { requester . id } > by <@ { approver . id } >." ,
193
+ text = text ,
165
194
thread_ts = payload .thread_ts ,
166
195
)
167
196
@@ -211,6 +240,7 @@ def handle_request_for_access_submittion(
211
240
reason = request .reason ,
212
241
permission_duration = request .permission_duration ,
213
242
show_buttons = show_buttons ,
243
+ color_coding_emoji = cfg .waiting_result_emoji ,
214
244
),
215
245
channel = cfg .slack_channel_id ,
216
246
text = f"Request for access to { account .name } account from { requester .real_name } " ,
@@ -236,19 +266,35 @@ def handle_request_for_access_submittion(
236
266
match decision .reason :
237
267
case access_control .DecisionReason .ApprovalNotRequired :
238
268
text = "Approval for this Permission Set & Account is not required. Request will be approved automatically."
269
+ color_coding_emoji = cfg .good_result_emoji
239
270
case access_control .DecisionReason .SelfApproval :
240
271
text = "Self approval is allowed and requester is an approver. Request will be approved automatically."
272
+ color_coding_emoji = cfg .good_result_emoji
241
273
case access_control .DecisionReason .RequiresApproval :
242
274
approvers = [slack_helpers .get_user_by_email (client , email ) for email in decision .approvers ]
243
275
mention_approvers = " " .join (f"<@{ approver .id } >" for approver in approvers )
244
276
text = f"{ mention_approvers } there is a request waiting for the approval."
277
+ color_coding_emoji = cfg .waiting_result_emoji
245
278
case access_control .DecisionReason .NoApprovers :
246
279
text = "Nobody can approve this request."
280
+ color_coding_emoji = cfg .bad_result_emoji
247
281
case access_control .DecisionReason .NoStatements :
248
282
text = "There are no statements for this Permission Set & Account."
283
+ color_coding_emoji = cfg .bad_result_emoji
249
284
250
285
client .chat_postMessage (text = text , thread_ts = slack_response ["ts" ], channel = cfg .slack_channel_id )
251
286
287
+ blocks = slack_helpers .HeaderSectionBlock .set_color_coding (
288
+ blocks = slack_response ["message" ]["blocks" ],
289
+ color_coding_emoji = color_coding_emoji ,
290
+ )
291
+ client .chat_update (
292
+ channel = cfg .slack_channel_id ,
293
+ ts = slack_response ["ts" ],
294
+ blocks = blocks ,
295
+ text = text ,
296
+ )
297
+
252
298
access_control .execute_decision (
253
299
decision = decision ,
254
300
permission_set_name = request .permission_set_name ,
0 commit comments