forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into improvements/more-streams
- Loading branch information
Showing
40 changed files
with
1,710 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ jparker:[email protected] | |
[email protected] | ||
kadira:[email protected] | ||
kadira:[email protected] | ||
kenton:accounts-sandstorm@0.3.0 | ||
kenton:accounts-sandstorm@0.4.0 | ||
konecty:[email protected] | ||
konecty:[email protected] | ||
konecty:[email protected] | ||
|
@@ -129,6 +129,7 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
|
@@ -172,6 +173,7 @@ rocketchat:[email protected] | |
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
RocketChat Action Links | ||
============ | ||
|
||
Action Links are a way to add custom javascript functions to RocketChat messages. The links appear as a horizontal list below the message they correspond to, and by clicking the link will run a function you define server-side. | ||
|
||
Usage | ||
------------ | ||
|
||
Add 'actionLinks' to any message object as in the example below. It should be an array of object, each containing a 'label' (this will be the text printed to click on), a method_id (this is the name of the method that will be run), and params (this is the parameters passed to the method_id function). | ||
|
||
~~~ | ||
message.actionLinks = [{ label: "Another Option", method_id: "anotherFunction", params: "stuff"}, { label: "An Option", method_id: "functOne", params: ""}]; | ||
~~~ | ||
|
||
|
||
|
||
|
||
|
||
The functions to be run need to be added to the actionLinkFuncts namespace. This is done by calling the RocketChat.actionLinks.register method. Your custom functions should take two parameters: the original message from the database, and the 'params' object given for that function. | ||
~~~ | ||
RocketChat.actionLinks.register('functOne', function (origDbMsg, params) { | ||
console.log("I did some stuff!"); | ||
}); | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Template.room.events({ | ||
'click .action-link'(event) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
const data = Blaze.getData(event.currentTarget); | ||
|
||
if (data && data._arguments && data._arguments[1] && data._arguments[1]._id) { | ||
Meteor.call('actionLinkHandler', event.currentTarget.childNodes[1].name, data._arguments[1]._id, (err) => { | ||
if (err) { | ||
handleError(err); | ||
} | ||
}); | ||
} | ||
} | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/rocketchat-action-links/client/stylesheets/actionLinks.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.message { | ||
.actionLinks { | ||
padding: 0; | ||
margin-top: 4px; | ||
text-align: center; | ||
li { | ||
cursor: pointer; | ||
position: relative; | ||
padding-right: 2px; | ||
color: #036; | ||
|
||
list-style: none; | ||
display: inline; | ||
|
||
|
||
&:hover { | ||
color: #369; | ||
} | ||
} | ||
|
||
li:after { content: " \25CF"; } | ||
li:last-child:after { content: none; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RocketChat.theme.addPackageAsset(function() { | ||
return Assets.getText('client/stylesheets/actionLinks.less'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Package.describe({ | ||
name: 'rocketchat:action-links', | ||
version: '0.0.1', | ||
summary: 'Add custom actions that call functions', | ||
git: '', | ||
}); | ||
|
||
Package.onUse(function(api) { | ||
api.versionsFrom('1.0'); | ||
|
||
api.use('ecmascript'); | ||
api.use('templating'); | ||
api.use('rocketchat:lib'); | ||
api.use('rocketchat:theme'); | ||
api.use('rocketchat:ui'); | ||
|
||
api.addFiles('client/init.js', 'client'); | ||
api.addAssets('client/stylesheets/actionLinks.less', 'server'); | ||
api.addFiles('loadStylesheets.js', 'server'); | ||
|
||
api.addFiles('server/registerActionLinkFuncts.js', 'server'); | ||
api.addFiles('server/actionLinkHandler.js', 'server'); | ||
|
||
}); |
25 changes: 25 additions & 0 deletions
25
packages/rocketchat-action-links/server/actionLinkHandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//Action Links Handler. This method will be called off the client. | ||
|
||
Meteor.methods({ | ||
actionLinkHandler(name, messageId) { | ||
if (!Meteor.userId()) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'actionLinkHandler' }); | ||
} | ||
|
||
var message = RocketChat.models.Messages.findOneById(messageId); | ||
if (!message) { | ||
throw new Meteor.Error('error-invalid-message', 'Invalid message', { method: 'actionLinkHandler' }); | ||
} | ||
|
||
var actionLink = message.actionLinks[name]; | ||
if (!message.actionLinks || !actionLink || !RocketChat.actionLinks || !RocketChat.actionLinks[actionLink.method_id]) { | ||
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link', { method: 'actionLinkHandler' }); | ||
} | ||
|
||
if (!Meteor.call('canAccessRoom', message.rid, Meteor.userId())) { | ||
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'actionLinkHandler' }); | ||
} | ||
|
||
RocketChat.actionLinks[actionLink.method_id](message, actionLink.params); | ||
} | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/rocketchat-action-links/server/registerActionLinkFuncts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//Action Links namespace creation. | ||
|
||
RocketChat.actionLinks = { | ||
register : function(name, funct) { | ||
RocketChat.actionLinks[name] = funct; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.