I have this block of code which is responsible for selecting the namespace:
@appmand("/enable_worker")
def enable_worker(ack, body, say):
ack()
blocks = [
{
"type": "section",
"block_id": "section678",
"text": {
"type": "mrkdwn",
"text": ":one: Select the environment you want to setup:"
},
"accessory": {
"action_id": "environment_selector",
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Select an environment"
},
"options": []
}
}
]
services = get_services()
for namespace, service in services.items():
ns_data = {
"text": {
"type": "plain_text",
"text": f"{namespace}"
},
"value": f"{namespace}"
}
blocks[0]["accessory"]["options"].append(ns_data)
say(blocks=blocks)
And this handler for environment_selector
:
@app.action("environment_selector")
def environment_selector(ack, body, say):
ack()
workers_in_ns = get_services(body["actions"][0]["selected_option"]["value"])
workers = workers_in_ns[body["actions"][0]["selected_option"]["value"]]
blocks = [
{
"type": "section",
"block_id": "section678",
"text": {
"type": "mrkdwn",
"text": ":two: Select the worker in this environment you want to update:"
},
"accessory": {
"action_id": "worker_selector",
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Select a worker"
},
"options": []
}
}
]
for worker in workers:
w_data = {
"text": {
"type": "plain_text",
"text": f"{worker[0]}"
},
"value": f"{worker[0]}"
}
blocks[0]["accessory"]["options"].append(w_data)
say(blocks=blocks, metadata={"namespace": body["actions"][0]["selected_option"]["value"]})
And I want to pass the namespace
to the handler of worker_selector
:
@app.action("worker_selector")
def worker_selector(ack, body, say):
ack()
print(body)
But the output of body
here has no element metadata
, how can I pass this variable to the handler?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744228751a4564139.html
评论列表(0条)