Skip to content

Commit

Permalink
✨ Add inChannel() method to Message object (Issue 7)
Browse files Browse the repository at this point in the history
✨ Add inChannel() method to Message object (Issue 7)
  • Loading branch information
raycharius authored Jun 12, 2020
2 parents e02cdee + 4e65992 commit d1fb2cc
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 11 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Change Log

## v0.1.2 - 2020-06-12

* Add `inChannel()` method to `Message` object.

## v0.1.1 - 2020-06-10

* Fix issue where strings passed to the 'fields()' method of a Section object would be mutated into plain text objects instead of markdown text objects.
* Fix issue where strings passed to the 'elements()' method of a Context object would be mutated into plain text objects instead of markdown text objects.
* Fix type in JSDoc for TextInput Element object (intiialValue => initialValue).
* Update tests to accommodate for these changes.
* Update description and keywords in package.json.
* Update README.md.
* Fix issue where strings passed to the `fields()` method of a `Section` object would be mutated into plain text objects instead of markdown text objects.
* Fix issue where strings passed to the `elements()` method of a `Context` object would be mutated into plain text objects instead of markdown text objects.
* Fix type in JSDoc for `TextInput` object (intiialValue => initialValue).

## v0.1.0 - 2020-06-09

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slack-block-builder",
"version": "0.1.1",
"version": "0.1.2",
"description": "Lightweight, zero-dependency library for creating Slack messages and modals, with a builder interface inspired by SwiftUI.",
"author": {
"name": "Ray East",
Expand Down
14 changes: 13 additions & 1 deletion src/surfaces/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Message extends Surface {
}

/**
* Sets the message to only visible by the user who invoked the action
* Sets the message to only be visible by the user who invoked the action
*
* {@link https://api.slack.com/messaging/composing|View in Slack API Documentation}
*
Expand All @@ -122,6 +122,18 @@ class Message extends Surface {
return this.set(enumValues.ephemeral, props.responseType);
}

/**
* Sets the message to visible to everyone in the channel
*
* {@link https://api.slack.com/messaging/composing|View in Slack API Documentation}
*
* @return {this} The instance on which the method is called
*/

inChannel() {
return this.set(enumValues.inChannel, props.responseType);
}

/**
* Sets a time for the message to be posted, as a scheduled message
*
Expand Down
1 change: 1 addition & 0 deletions src/utility/constants/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ module.exports = {
responseType: 'responseType',
postAt: 'postAt',
ephemeral: 'ephemeral',
inChannel: 'inChannel',
};
1 change: 1 addition & 0 deletions src/utility/constants/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
danger: 'danger',
primary: 'primary',
ephemeral: 'ephemeral',
inChannel: 'in_channel',
};
2 changes: 1 addition & 1 deletion src/utility/validators/type-validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
}),

isResponseTypeEnum: new Validator({
condition: (value) => value === enumValues.ephemeral,
condition: (value) => [enumValues.ephemeral, enumValues.inChannel].includes(value),
message: 'String with value of \'ephemeral\'',
}),

Expand Down
1 change: 1 addition & 0 deletions tests/mocks/data-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ module.exports = {
globallyInvalid: [0, 1, 2, 3, 4, 5],
timestamp: 1355517523,
ephemeral: 'ephemeral',
inChannel: 'in_channel',
};
3 changes: 2 additions & 1 deletion tests/mocks/invalid-prop-data-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ module.exports = {
deleteOriginal: types.globallyInvalid,
responseType: types.globallyInvalid,
postAt: types.globallyInvalid,
ephemeral: types.string,
ephemeral: types.globallyInvalid,
inChannel: types.globallyInvalid,
};
2 changes: 1 addition & 1 deletion tests/mocks/non-primitive-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ module.exports = {
OptionGroup,
ConfirmationDialog,
MarkdownObject,
};
};
1 change: 1 addition & 0 deletions tests/mocks/valid-prop-data-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ module.exports = {
responseType: types.ephemeral,
postAt: types.timestamp,
ephemeral: types.ephemeral,
inChannel: types.inChannel,
};
20 changes: 20 additions & 0 deletions tests/props/in-channel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { props, paramMap } = require('../../src/utility/constants');
const valid = require('../mocks/valid-prop-data-mapping');
const invalid = require('../mocks/invalid-prop-data-mapping');
const checks = require('../checks');

module.exports = (params) => {
const config = {
...params,
valid: valid.inChannel,
invalid: invalid.inChannel,
method: props.inChannel,
property: props.responseType,
param: paramMap.responseType,
};

return [
checks.settableProperty(config),
checks.literalBuild(config),
];
};
2 changes: 2 additions & 0 deletions tests/props/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const fields = require('./fields');
const filter = require('./filter');
const hint = require('./hint');
const imageUrl = require('./image-url');
const inChannel = require('./in-channel');
const initialChannel = require('./initial-channel');
const initialChannels = require('./initial-channels');
const initialConversation = require('./initial-conversation');
Expand Down Expand Up @@ -87,6 +88,7 @@ module.exports = {
filter,
hint,
imageUrl,
inChannel,
initialChannel,
initialChannels,
initialConversation,
Expand Down
1 change: 1 addition & 0 deletions tests/surfaces/message.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const properties = [
props.replaceOriginal,
props.deleteOriginal,
props.ephemeral,
props.inChannel,
props.postAt,
];

Expand Down

0 comments on commit d1fb2cc

Please sign in to comment.