I am updating slack modal view but it doesn't maintain selected dropdown values, on every update modal is getting reinitialized.
I want to select dropdown one and based on selection looking to populate dropdown two and on update all selected values should be maintain in the modal view.
Seeking assistance to make interactive modal view.
await client.views.update({
token: process.env.SLACK_BOT_TOKEN,
hash: view.hash,
view_id: view.id,
view: await moduleBlocks()
});
moduleBlocks (){
const modal = {
"callback_id": "create-incident-modal",
"type": "modal",
"title": {
"type": "plain_text",
"text": "Create Incident"
},
"submit": {
"type": "plain_text",
"text": "Submit"
},
"blocks": [
{
"type": "input",
"dispatch_action": true,
"element": {
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "*option 1*",
"emoji": true
},
"value": "value-0"
},
{
"text": {
"type": "plain_text",
"text": "*option 2*",
"emoji": true
},
"value": "value-1"
},
{
"text": {
"type": "plain_text",
"text": "*option 3*",
"emoji": true
},
"value": "value-2"
}
],
"action_id": "static_select-1"
},
"label": {
"type": "plain_text",
"text": "Label",
"emoji": true
}
},
{
"type": "input",
"dispatch_action": true,
"element": {
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "*option2 1*",
"emoji": true
},
"value": "value-0"
},
{
"text": {
"type": "plain_text",
"text": "*option2 2*",
"emoji": true
},
"value": "value-1"
},
{
"text": {
"type": "plain_text",
"text": "*option3 3*",
"emoji": true
},
"value": "value-2"
}
],
"action_id": "static_select-2"
},
"label": {
"type": "plain_text",
"text": "Label",
"emoji": true
}
}
]
}
return JSON.stringify(modal);
}
Your blocks need a set block_id to maintain the same values. When you don't provide a block_id, a block_id is generated for you. When slack sees the block_id change, it resets the values.
"type": "input",
"dispatch_action": true,
"block_id": "test_id"
"element": {
When you update the each time, keep block_id the same except for the block you want to update.
Here is some info on blocks & block_id: https://api.slack.com/reference/block-kit/blocks
Related
As the title mentions, I'm trying to replicate a Input Transformer using RuleTargetInputProperties but i can't seem to find any examples or get the correct format to input.
The template i'm trying to replicate is the following:
InputTemplate: |
{
"sourceVersion": <sourceVersion>,
"artifactsOverride": {"type": "NO_ARTIFACTS"},
"environmentVariablesOverride": [
{
"name": "PULL_REQUEST_ID",
"value": <pullRequestId>,
"type": "PLAINTEXT"
},
{
"name": "REPOSITORY_NAME",
"value": <repositoryName>,
"type": "PLAINTEXT"
},
{
"name": "SOURCE_COMMIT",
"value": <sourceCommit>,
"type": "PLAINTEXT"
},
{
"name": "DESTINATION_COMMIT",
"value": <destinationCommit>,
"type": "PLAINTEXT"
},
{
"name" : "REVISION_ID",
"value": <revisionId>,
"type": "PLAINTEXT"
}
]
}
InputPathsMap:
sourceVersion: "$.detail.sourceCommit"
pullRequestId: "$.detail.pullRequestId"
repositoryName: "$.detail.repositoryNames[0]"
sourceCommit: "$.detail.sourceCommit"
destinationCommit: "$.detail.destinationCommit"
revisionId: "$.detail.revisionId"
I've tried with RuleTargetInput, but this doesn't give me the correct template
on_pr_rule = repo.on_pull_request_state_change("PR",
target=targets.CodeBuildProject(project,
dead_letter_queue=dead_letter_queue,
event=events.RuleTargetInput.from_object({
"sourceVersion": events.EventField.from_path("$.detail.sourceCommit"),
"pullRequestId": events.EventField.from_path("$.detail.pullRequestId"),
"repositoryName": events.EventField.from_path("$.detail.repositoryNames[0]"),
"sourceCommit": events.EventField.from_path("$.detail.sourceCommit"),
"destinationCommit": events.EventField.from_path("$.detail.destinationCommit"),
"revisionId": events.EventField.from_path("$.detail.revisionId")
})
)
)
InputTransformer:
InputPathsMap:
detail-sourceCommit: $.detail.sourceCommit
detail-pullRequestId: $.detail.pullRequestId
detail-repositoryNames-0-: $.detail.repositoryNames[0]
detail-destinationCommit: $.detail.destinationCommit
detail-revisionId: $.detail.revisionId
InputTemplate: '{"sourceVersion":<detail-sourceCommit>,"pullRequestId":<detail-pullRequestId>,"repositoryName":<detail-repositoryNames-0->,"sourceCommit":<detail-sourceCommit>,"destinationCommit":<detail-destinationCommit>,"revisionId":<detail-revisionId>}'
Has anyone had any experience with adding a template as such using RuleTargetInputProperties?
From the input, I am guessing you are working on the PR workflow. This is what I ended up with .
_pr_build_events_input = events.RuleTargetInput.from_object({
"sourceVersion": events.EventField.from_path("$.detail.sourceCommit"),
"artifactsOverride": {"type": "NO_ARTIFACTS"},
"environmentVariablesOverride": [
{
"name": 'pullRequestId',
"value": EventField.from_path('$.detail.pullRequestId'),
"type": 'PLAINTEXT',
},
{
"name": 'repositoryName',
"value": EventField.from_path('$.detail.repositoryNames[0]'),
"type": 'PLAINTEXT',
},
{
"name": 'sourceCommit',
"value": EventField.from_path('$.detail.sourceCommit'),
"type": 'PLAINTEXT',
},
{
"name": 'destinationCommit',
"value": EventField.from_path('$.detail.destinationCommit'),
"type": 'PLAINTEXT',
},
{
"name": 'revisionId',
"value": EventField.from_path('$.detail.revisionId'),
"type": 'PLAINTEXT',
},
],
})
I have created a modal in slack which gets invoked upon certain command. When I submit the modal an HTTP Post request is sent to the specified URL in interactive components, but an HTTP Post request is also sent each time when I edit the assetname input column. How to stop it?
Below is the JSON which I created and also the request is not sent when making changes in any other field of the modal.
{
"type": "modal",
"title": {
"type": "plain_text",
"text": "Asset Details",
"emoji": true
},
"submit": {
"type": "plain_text",
"text": "Create Record",
"emoji": true
},
"close": {
"type": "plain_text",
"text": "Cancel",
"emoji": true
},
"blocks": [
{
"type": "divider"
},
{
"block_id": "assetname",
"type": "input",
"element": {
"type": "plain_text_input",
"action_id": "asset_name"
},
"label": {
"type": "plain_text",
"text": "Asset Name",
"emoji": true
}
},
{
"type": "input",
"block_id": "relatedguild",
"element": {
"type": "static_select",
"action_id": "guild",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "B2B Marketing Automation",
"emoji": true
},
"value": "B2B Marketing Automation"
},
{
"text": {
"type": "plain_text",
"text": "B2C Marketing Automation",
"emoji": true
},
"value": "B2C Marketing Automation"
},
{
"text": {
"type": "plain_text",
"text": "Community Cloud",
"emoji": true
},
"value": "Community Cloud"
},
{
"text": {
"type": "plain_text",
"text": "CPQ",
"emoji": true
},
"value": "CPQ"
},
{
"text": {
"type": "plain_text",
"text": "Data Analytics",
"emoji": true
},
"value": "Data Analytics"
},
{
"text": {
"type": "plain_text",
"text": "Data Core",
"emoji": true
},
"value": "Data Core"
},
{
"text": {
"type": "plain_text",
"text": "Declarative Core",
"emoji": true
},
"value": "Declarative Core"
},
{
"text": {
"type": "plain_text",
"text": "Development Process",
"emoji": true
},
"value": "Development Process"
},
{
"text": {
"type": "plain_text",
"text": "Full Stack",
"emoji": true
},
"value": "Full Stack"
},
{
"text": {
"type": "plain_text",
"text": "Non-Profit Industry",
"emoji": true
},
"value": "Non-Profit Industry"
},
{
"text": {
"type": "plain_text",
"text": "Project Management",
"emoji": true
},
"value": "Project Management"
},
{
"text": {
"type": "plain_text",
"text": "Service Cloud",
"emoji": true
},
"value": "Service Cloud"
}
]
},
"label": {
"type": "plain_text",
"text": "Related Guild",
"emoji": true
}
},
{
"type": "input",
"block_id": "cloudsImpacted",
"element": {
"type": "static_select",
"action_id": "clouds",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "None",
"emoji": true
},
"value": "None"
},
{
"text": {
"type": "plain_text",
"text": "Sales",
"emoji": true
},
"value": "Sales"
},
{
"text": {
"type": "plain_text",
"text": "Service",
"emoji": true
},
"value": "Service"
},
{
"text": {
"type": "plain_text",
"text": "Community",
"emoji": true
},
"value": "Community"
},
{
"text": {
"type": "plain_text",
"text": "Marketing",
"emoji": true
},
"value": "Marketing"
},
{
"text": {
"type": "plain_text",
"text": "Field Service",
"emoji": true
},
"value": "Field Service"
}
]
},
"label": {
"type": "plain_text",
"text": "Clouds Impacted",
"emoji": true
}
},
{
"block_id": "description",
"type": "input",
"element": {
"action_id": "descact",
"type": "plain_text_input",
"multiline": true
},
"label": {
"type": "plain_text",
"text": "Description",
"emoji": true
}
}
]
}
I'm trying to add padding to my adaptive card view so that it's contents are inset from the edge of the card. I'd like to not adjust the padding of any of the internal card elements. I'm trying to use the following host config, which parses without error but seems to have no effect on the card.
Host config JSON:
{
"spacing": {
"small": 3,
"default": 8,
"medium": 20,
"large": 30,
"extraLarge": 40,
"padding": 100
},
"adaptiveCard": {
"allowCustomStyle": true,
"spacing": {
"padding": 100
}
}
}
Resulting card:
As you can see, there is certainly not 100px of padding being added to the card. I've used sample host configs and tweak other settings like colors so I know the config is being applied, but nothing I do seems to affect the card padding. Thanks in advance!
Card JSON:
{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Publish Adaptive Card schema"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "Image",
"style": "Person",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"size": "Small"
}
],
"width": "auto"
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"weight": "Bolder",
"text": "Matt Hidinger",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "None",
"text": "Created {{DATE(2017-02-14T06:08:39Z,SHORT)}}",
"isSubtle": true,
"wrap": true
}
],
"width": "stretch"
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
"wrap": true
},
{
"type": "FactSet",
"facts": [
{
"title": "Board:",
"value": "Adaptive Card"
},
{
"title": "List:",
"value": "Backlog"
},
{
"title": "Assigned to:",
"value": "Matt Hidinger"
},
{
"title": "Due date:",
"value": "Not set"
}
]
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Date",
"id": "dueDate"
},
{
"type": "Input.Text",
"id": "comment",
"placeholder": "Add a comment",
"isMultiline": true
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "OK",
"url": "http://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.OpenUrl",
"title": "View",
"url": "http://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
I have the below json file.
1) I renamed it as mytest.environment.json and I am trying to import the same in postman client app. I am getting an error - format not recognized. (all values are null intentionally)
2) I am not able to connect https://api.getpostman.com/environments to create an environment.
3) If this can not be done, how can I tie an environment name to a request inside test script? For e.g, I have a collection, which needs to run against multiple environments . I could not find any API which logs environment.name. When I do console.log(environment), it just prints that its an object.
{
"environment": {
"name": "Test Environment",
"US_DC": [{
"enabled": true,
"key": "oauth_server",
"value": "",
"type": "text"
},
{
"enabled": true,
"key": "oauth_secret",
"value": "",
"type": "text"
},
{
"enabled": true,
"key": "grant_type",
"value": "",
"type": "text"
},
{
"enabled": true,
"key": "api_gateway",
"value": "",
"type": "text"
}
],
"EU_DC": [{
"enabled": true,
"key": "oauth_server",
"value": "",
"type": "text"
},
{
"enabled": true,
"key": "oauth_secret",
"value": "",
"type": "text"
},
{
"enabled": true,
"key": "grant_type",
"value": "",
"type": "text"
},
{
"enabled": true,
"key": "api_gateway",
"value": "",
"type": "text"
}
]
}
}
Swagger file is working as expected with warnig.
{
'swagger': "2.0",
"info": {
"version": "3.0",
"title": "Sample Service",
},
"schemes": [ "http" ],
"host": "sampleservice.azurewebsites.net",
"paths": {
"/": {
"post": {
"summary": "Sample service",
"description": "sample service",
"parameters": [
{
"name": "Input",
"in": "body",
"description": "valid input",
"schema": {
"type": "object",
"properties": {
"MainAttr-1": {
"required": [ "Attr-1" ],
"type": "object",
"properties": {
"Attr-1": {
"description": "Attr-1",
"required": true,
"type": "string"
},
"Attr-2": {
"description": "Attr-2",
"required": false,
"type": "string"
},
"Attr-3": {
"description": "Attr-3",
"required": false,
"type": "boolean"
},
"Attr-4": {
"description": "Attr-4",
"required": false,
"type": "boolean"
},
"Attr-5": {
"description": "Attr-5",
"required": false,
"type": "string"
}
}
},
"MainAttr-2": {
"type": "array",
"items": {
"type": "object",
"required": [ "Attr-1", "Attr-3", "Attr-5", "Attr-8" ],
"properties": {
"Attr-1": {
"description": "Attr-1",
"required": true,
"type": "string"
},
"Attr-2": {
"description": "Attr-2",
"required": false,
"type": "string"
},
"Attr-3": {
"description": "Attr-3",
"required": true,
"type": "boolean"
},
"Attr-4": {
"description": "Attr-4",
"required": false,
"type": "boolean"
},
"Attr-5": {
"description": "Attr-5",
"required": true,
"type": "string"
},
"Attr-6": {
"description": "Attr-6",
"required": false,
"type": "string"
},
"Attr-7": {
"description": "Attr-7",
"required": false,
"type": "string"
},
"Attr-8": {
"description": "Attr-8",
"required": true,
"type": "string"
}
}
}
}
}
}
}
],
"responses": {
"200": {
"description": "success"
}
}
}
}
}
}
Issue-1) Warning should be removed
Issue-2) Attr-3 in "MainAttr-2" is boolean type attribute and it is required. But when i am selecting 'false' from the dropdown, it is treating as invalid input. It treats only 'true' as valid input. (Any Boolean attribute which is required behaving like this)
Due this warning i am unable to deliver the code.
Thanks in advance.
In the beginning, change 'swagger' to "swagger". JSON requires double quotes around strings.
Remove extra comma at the end of:
"title": "Sample Service",
Remove the required attribute from ALL property definitions (Attr-1 to Attr-8) and use the required list at the object level instead (under MainAttr-1 and MainAttr-2).
"MainAttr-1": {
"required": [ "Attr-1" ], <-- list the required properties in this array
"type": "object",
"properties": {
"Attr-1": {
"description": "Attr-1",
"required": true, <-- remove this
"type": "string"
},
Other than that your spec is fine.