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

[Regression] Fix integrations message example #14111

Merged
merged 2 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/integrations/client/views/integrationsIncoming.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</div>
</div>
<div class="input-line message-example">
{{#nrr nrrargs 'message' example}}{{/nrr}}
{{#nrr nrrargs 'message' msg=exampleMsg settings=exampleSettings u=exampleUser}}{{/nrr}}
</div>
</div>
</div>
Expand Down
33 changes: 4 additions & 29 deletions app/integrations/client/views/integrationsIncoming.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Random } from 'meteor/random';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { hasAtLeastOnePermission, hasAllPermission } from '../../../authorization';
import { modal } from '../../../ui-utils';
import { t, handleError } from '../../../utils';
import { ChatIntegrations } from '../collections';
import { exampleMsg, exampleSettings, exampleUser } from './messageExample';
import hljs from 'highlight.js';
import toastr from 'toastr';

Expand All @@ -18,6 +18,9 @@ Template.integrationsIncoming.onCreated(function _incomingIntegrationsOnCreated(
});

Template.integrationsIncoming.helpers({
exampleMsg,
exampleUser,
exampleSettings,
hasPermission() {
return hasAtLeastOnePermission(['manage-integrations', 'manage-own-integrations']);
},
Expand All @@ -44,34 +47,6 @@ Template.integrationsIncoming.helpers({

return Template.instance().record.curValue;
},

example() {
const record = Template.instance().record.get();
return {
_id: Random.id(),
alias: record.alias,
emoji: record.emoji,
avatar: record.avatar,
msg: 'Example message',
bot: {
i: Random.id(),
},
groupable: false,
attachments: [{
title: 'Rocket.Chat',
title_link: 'https://rocket.chat',
text: 'Rocket.Chat, the best open source chat',
image_url: '/images/integration-attachment-example.png',
color: '#764FA5',
}],
ts: new Date(),
u: {
_id: Random.id(),
username: record.username,
},
};
},

exampleJson() {
const record = Template.instance().record.get();
const data = {
Expand Down
2 changes: 1 addition & 1 deletion app/integrations/client/views/integrationsOutgoing.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
</div>
</div>
<div class="input-line message-example">
{{#nrr nrrargs 'message' example}}{{/nrr}}
{{#nrr nrrargs 'message' msg=exampleMsg settings=exampleSettings u=exampleUser}}{{/nrr}}
</div>
{{/if}}
</div>
Expand Down
32 changes: 4 additions & 28 deletions app/integrations/client/views/integrationsOutgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ChatIntegrations } from '../collections';
import { integrations } from '../../lib/rocketchat';
import hljs from 'highlight.js';
import toastr from 'toastr';
import { exampleMsg, exampleSettings, exampleUser } from './messageExample';

Template.integrationsOutgoing.onCreated(function _integrationsOutgoingOnCreated() {
this.record = new ReactiveVar({
Expand Down Expand Up @@ -72,6 +73,9 @@ Template.integrationsOutgoing.onCreated(function _integrationsOutgoingOnCreated(
});

Template.integrationsOutgoing.helpers({
exampleMsg,
exampleUser,
exampleSettings,
join(arr, sep) {
if (!arr || !arr.join) {
return arr;
Expand Down Expand Up @@ -124,34 +128,6 @@ Template.integrationsOutgoing.helpers({
return typeof record.event === 'string' && integrations.outgoingEvents[record.event].use.targetRoom;
},

example() {
const record = Template.instance().record.get();

return {
_id: Random.id(),
alias: record.alias,
emoji: record.emoji,
avatar: record.avatar,
msg: 'Response text',
bot: {
i: Random.id(),
},
groupable: false,
attachments: [{
title: 'Rocket.Chat',
title_link: 'https://rocket.chat',
text: 'Rocket.Chat, the best open source chat',
image_url: '/images/integration-attachment-example.png',
color: '#764FA5',
}],
ts: new Date(),
u: {
_id: Random.id(),
username: record.username,
},
};
},

exampleJson() {
const record = Template.instance().record.get();
const data = {
Expand Down
39 changes: 39 additions & 0 deletions app/integrations/client/views/messageExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Template } from 'meteor/templating';
import { Random } from 'meteor/random';

export const exampleMsg = () => {
const record = Template.instance().record.get();
return {
_id: Random.id(),
alias: record.alias,
emoji: record.emoji,
avatar: record.avatar,
msg: 'Example message',
bot: {
i: Random.id(),
},
groupable: false,
attachments: [{
title: 'Rocket.Chat',
title_link: 'https://rocket.chat',
text: 'Rocket.Chat, the best open source chat',
image_url: '/images/integration-attachment-example.png',
color: '#764FA5',
}],
ts: new Date(),
u: {
_id: Random.id(),
username: record.username,
},
};
};

export const exampleUser = () => ({
u: {
_id: Random.id(),
},
});

export const exampleSettings = () => ({
settings: {},
});