Skip to content

Commit c41f5f8

Browse files
authored
Merge pull request #5 from PostHog/tom/fix-permission-set-selector
Fix permission set selector
2 parents 65a0862 + 338e52b commit c41f5f8

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

src/slack_helpers.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def build(cls) -> View:
6868
type="modal",
6969
callback_id=cls.CALLBACK_ID,
7070
submit=PlainTextObject(text="Request"),
71+
submit_disabled=True,
7172
close=PlainTextObject(text="Cancel"),
7273
title=PlainTextObject(text="Request AWS Access"),
7374
blocks=[
@@ -90,16 +91,16 @@ def build(cls) -> View:
9091
multiline=True,
9192
),
9293
),
93-
DividerBlock(),
9494
SectionBlock(
95+
block_id=cls.LOADING_BLOCK_ID,
9596
text=MarkdownTextObject(
96-
text="All AWS API calls are logged for security compliance.",
97+
text=":hourglass: Loading available accounts and permission sets...",
9798
),
9899
),
100+
DividerBlock(),
99101
SectionBlock(
100-
block_id=cls.LOADING_BLOCK_ID,
101102
text=MarkdownTextObject(
102-
text=":hourglass: Loading available accounts and permission sets...",
103+
text="All AWS API calls are logged for security compliance.",
103104
),
104105
),
105106
],
@@ -115,6 +116,7 @@ def build_select_account_input_block(cls, accounts: list[entities.aws.Account])
115116
sorted_accounts = sorted(accounts, key=lambda account: account.name)
116117
return InputBlock(
117118
block_id=cls.ACCOUNT_BLOCK_ID,
119+
dispatch_action=True,
118120
label=PlainTextObject(text="AWS Account"),
119121
element=StaticSelectElement(
120122
action_id=cls.ACCOUNT_ACTION_ID,
@@ -141,6 +143,18 @@ def build_select_permission_set_input_block(cls, permission_sets: list[entities.
141143
),
142144
)
143145

146+
@classmethod
147+
def build_permission_set_placeholder_block(cls) -> InputBlock:
148+
return InputBlock(
149+
block_id=cls.PERMISSION_SET_PLACEHOLDER_BLOCK_ID,
150+
label=PlainTextObject(text="Permission set"),
151+
element=StaticSelectElement(
152+
action_id=cls.PERMISSION_SET_ACTION_ID + "_placeholder",
153+
placeholder=PlainTextObject(text="Select an account first"),
154+
options=[Option(text=PlainTextObject(text="—"), value="_disabled")],
155+
),
156+
)
157+
144158
@classmethod
145159
def update_with_accounts(cls, accounts: list[entities.aws.Account]) -> View:
146160
view = cls.build()
@@ -149,10 +163,7 @@ def update_with_accounts(cls, accounts: list[entities.aws.Account]) -> View:
149163
blocks=view.blocks,
150164
blocks_to_insert=[
151165
cls.build_select_account_input_block(accounts),
152-
SectionBlock(
153-
block_id=cls.PERMISSION_SET_PLACEHOLDER_BLOCK_ID,
154-
text=MarkdownTextObject(text="Select an account above to see available permission sets"),
155-
),
166+
cls.build_permission_set_placeholder_block(),
156167
],
157168
after_block_id=cls.REASON_BLOCK_ID,
158169
)
@@ -161,6 +172,7 @@ def update_with_accounts(cls, accounts: list[entities.aws.Account]) -> View:
161172
@classmethod
162173
def update_with_permission_sets(cls, view_blocks: list, permission_sets: list[entities.aws.PermissionSet]) -> View:
163174
view = cls.build()
175+
view.submit_disabled = False
164176
# Start from the current blocks, remove placeholder
165177
blocks = remove_blocks(view_blocks, block_ids=[cls.PERMISSION_SET_PLACEHOLDER_BLOCK_ID, cls.PERMISSION_SET_BLOCK_ID])
166178
# Insert permission set dropdown after account dropdown

0 commit comments

Comments
 (0)