Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding type for plain_text_input action elements #706

Merged
merged 2 commits into from
Mar 17, 2021

Conversation

br-tim-ray
Copy link
Contributor

Summary

Related to #349

Getting Typescript errors when using a plain_text_input with dispatch_action: true.

Adding definition to resolve those errors.

Requirements (place an x in each [ ])

@gitwave gitwave bot added the untriaged label Dec 9, 2020
@CLAassistant
Copy link

CLAassistant commented Dec 9, 2020

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Dec 9, 2020

Codecov Report

Merging #706 (7b43205) into main (3ed08fc) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #706   +/-   ##
=======================================
  Coverage   65.89%   65.89%           
=======================================
  Files          13       13           
  Lines        1173     1173           
  Branches      343      343           
=======================================
  Hits          773      773           
  Misses        334      334           
  Partials       66       66           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ed08fc...7b43205. Read the comment docs.

@stevengill
Copy link
Member

stevengill commented Dec 9, 2020

Hey @br-dr-strangecode,

Can you provide a sample of the code you are writing that you are encountering this error with? I just want to reproduce it locally.

@stevengill stevengill added needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info and removed untriaged labels Dec 9, 2020
@stevengill stevengill self-assigned this Dec 9, 2020
@br-tim-ray
Copy link
Contributor Author

Sure thing

code:

export const configureUserSearchDetails = (bolt: App): void => {
  bolt.action({ type: "block_actions", action_id: /^user_details(.*)/ }, async ({ ack, body, client }) => {
    await ack();
    const username = body.actions[0].value;
    try {
      await client.views.push({
        trigger_id: body.trigger_id,
        view: UserDetailsView(username),
      });
      await client.chat.postMessage({
        channel: logging_channel,
        text: `${body.user.name} clicked on ${username}`,
      });
      console.log(`${body.user.name} searched for ${username}`);
    } catch (error) {
      console.error(error);
    }
  });
};

error:

  Property 'value' does not exist on type 'BlockElementAction'.
  Property 'value' does not exist on type 'UsersSelectAction'.

sample of the response I'm trying to take an action on:

{
  "type": "block_actions",
  "user": {
    "id": "U01CPTM7TJ8",
    "username": "tim.ray",
    "name": "tim.ray",
    "team_id": "T01CB1CPE06"
  },
  "api_app_id": "A01CJ0MSTMH",
  "token": "M6qNFFa5SaLvBzInXAwcYVZP",
  "container": {
    "type": "view",
    "view_id": "V01GFNMRD5G"
  },
  "trigger_id": "1559976302643.1419046796006.9cff3ebe62cded18e8206f7d87e8f6eb",
  "team": {
    "id": "T01CB1CPE06",
    "domain": "trslackbotdev"
  },
  "enterprise": null,
  "is_enterprise_install": false,
  "view": {
    "id": "V01GFNMRD5G",
    "team_id": "T01CB1CPE06",
    "type": "modal",
    "blocks": [
      {
        "type": "input",
        "block_id": "user_search_block",
        "label": {
          "type": "plain_text",
          "text": "Search",
          "emoji": true
        },
        "optional": false,
        "dispatch_action": true,
        "element": {
          "type": "plain_text_input",
          "action_id": "user_search_input",
          "placeholder": {
            "type": "plain_text",
            "text": "name, username, phone",
            "emoji": true
          },
          "dispatch_action_config": {
            "trigger_actions_on": [
              "on_enter_pressed"
            ]
          }
        }
      }
    ],
    "private_metadata": "",
    "callback_id": "",
    "state": {
      "values": {
        "user_search_block": {
          "user_search_input": {
            "type": "plain_text_input",
            "value": "test"
          }
        }
      }
    },
    "hash": "1607466819.LAqne3A8",
    "title": {
      "type": "plain_text",
      "text": "User Search",
      "emoji": true
    },
    "clear_on_close": false,
    "notify_on_close": false,
    "close": {
      "type": "plain_text",
      "text": "Done",
      "emoji": true
    },
    "submit": null,
    "previous_view_id": null,
    "root_view_id": "V01GFNMRD5G",
    "app_id": "A01CJ0MSTMH",
    "external_id": "",
    "app_installed_team_id": "T01CB1CPE06",
    "bot_id": "B01C3417TEK"
  },
  "actions": [
    {
      "type": "plain_text_input",
      "block_id": "user_search_block",
      "action_id": "user_search_input",
      "value": "test",
      "action_ts": "1607466824.040714"
    }
  ]
}

Let me know if this is sufficient or if you need more of the code.

@br-tim-ray
Copy link
Contributor Author

I should have pointed out that the error occurs on this line:

const username = body.actions[0].value;

@seratch seratch added enhancement M-T: A feature request for new functionality TypeScript-specific and removed needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info labels Mar 17, 2021
@seratch
Copy link
Member

seratch commented Mar 17, 2021

Sorry for our slow response here. The change looks great to me. Thanks for your contribution!

@seratch seratch merged commit 1968af4 into slackapi:main Mar 17, 2021
@seratch seratch added this to the 3.4.0 milestone Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality TypeScript-specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants