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

[NEW] Add icon art in Tokenpass channel title #8626

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,7 @@
"Token_Access": "Token Access",
"Token_Controlled_Access": "Token Controlled Access",
"Token_required": "Token required",
"Tokenpass_Channel_Label": "Tokenpass Channel",
"Tokenpass_Channels": "Tokenpass Channels",
"Tokens_Minimum_Needed_Balance": "Minimum needed token balance",
"Tokens_Minimum_Needed_Balance_Description": "Set minimum needed balance on each token. Blank or \"0\" for not limit.",
Expand Down
12 changes: 12 additions & 0 deletions packages/rocketchat-tokenpass/client/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.icon-tokenpass {
display: inline-block;

width: 24px;
height: 0.8em;

margin-bottom: -1px;

background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MzIgMzgxLjUiPjxkZWZzPjxzdHlsZT4uY2xzLTF7ZmlsbDojNDE3MGEwO308L3N0eWxlPjwvZGVmcz48dGl0bGU+VG9rZW5seV9JY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iTGF5ZXJfMS0yIiBkYXRhLW5hbWU9IkxheWVyIDEiPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTQyOC4zMSwxNzcsMzM0LjA3LDEzLjc2QTI3LjUyLDI3LjUyLDAsMCwwLDMxMC4yNCwwaC03OS40VjEzMy44OWg3NFYxMTIuODRoMTcuNzJsMTguMTMsMzEuNGExMi41MiwxMi41MiwwLDAsMSwwLDEyLjcxLDEyLjc1LDEyLjc1LDAsMCwxLTExLjIyLDYuNTRIMTAyLjU2YTEyLjc1LDEyLjc1LDAsMCwxLTExLjIyLTYuNTQsMTIuNTIsMTIuNTIsMCwwLDEsMC0xMi43MWwxOC4xMy0zMS40aDE3LjcydjIxLjA1aDc0VjBoLTc5LjRBMjcuNTIsMjcuNTIsMCwwLDAsOTcuOTMsMTMuNzZMMy42OSwxNzdhMjcuNTIsMjcuNTIsMCwwLDAsMCwyNy41Mkw5Ny45MywzNjcuNzRhMjcuNTIsMjcuNTIsMCwwLDAsMjMuODQsMTMuNzZoNzkuNFYyNDcuNjFoLTc0djIxLjA2SDEwOS40N2wtMTguMTMtMzEuNGExMi41MiwxMi41MiwwLDAsMSwwLTEyLjcxQTEyLjc1LDEyLjc1LDAsMCwxLDEwMi41NiwyMThIMzI5LjQ0YTEyLjc1LDEyLjc1LDAsMCwxLDExLjIyLDYuNTQsMTIuNTIsMTIuNTIsMCwwLDEsMCwxMi43MWwtMTguMTMsMzEuNEgzMDQuODFWMjQ3LjYxaC03NFYzODEuNWg3OS40YTI3LjUyLDI3LjUyLDAsMCwwLDIzLjg0LTEzLjc2bDk0LjI0LTE2My4yM0EyNy41MiwyNy41MiwwLDAsMCw0MjguMzEsMTc3WiIvPjwvZz48L2c+PC9zdmc+);
background-repeat: no-repeat;
background-position: center center;
}
2 changes: 2 additions & 0 deletions packages/rocketchat-tokenpass/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Package.onUse(function(api) {

api.addFiles('client/login-button.css', 'client');
api.addFiles('client/channelSettings.css', 'client');
api.addFiles('client/styles.css', 'client');

api.addFiles('client/startup.js', 'client');
api.addFiles('client/roomType.js', 'client');
Expand All @@ -42,6 +43,7 @@ Package.onUse(function(api) {
api.addFiles('server/models/Users.js', 'server');

api.addFiles('server/methods/findTokenChannels.js', 'server');
api.addFiles('server/methods/getChannelTokenpass.js', 'server');

api.addFiles('server/cronRemoveUsers.js', 'server');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Meteor.methods({
getChannelTokenpass(rid) {
check(rid, String);

if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getChannelTokenpass' });
}

const room = RocketChat.models.Rooms.findOneById(rid);

if (!room) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'getChannelTokenpass' });
}

return room.tokenpass;
}
});
4 changes: 4 additions & 0 deletions packages/rocketchat-ui/client/views/app/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ <h2>
<a href="#favorite" class="toggle-favorite"><i class="{{favorite}}" aria-label="{{_ favoriteLabel}}"></i></a>
{{/if}}

{{#if tokenAccessChannel}}
<i class="icon-tokenpass" aria-label="{{_ "Tokenpass_Channel_Label"}}"></i>
{{/if}}

{{> icon block="room-icon" icon=roomIcon classes=userStatus}}

<span class="room-title">{{roomName}}</span>
Expand Down
14 changes: 14 additions & 0 deletions packages/rocketchat-ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ Template.room.helpers({
return roomIcon;
},

tokenAccessChannel() {
return Template.instance().hasTokenpass.get();
},

userStatus() {
const roomData = Session.get(`roomData${ this._id }`);
return RocketChat.roomTypes.getUserStatus(roomData.t, this._id) || 'offline';
Expand Down Expand Up @@ -768,6 +772,16 @@ Template.room.onCreated(function() {
return this.userDetail.set(null);
};

this.hasTokenpass = new ReactiveVar(false);

if (RocketChat.settings.get('API_Tokenpass_URL') !== '') {
Meteor.call('getChannelTokenpass', this.data._id, (error, result) => {
if (!error) {
this.hasTokenpass.set(!!(result && result.tokens && result.tokens.length > 0));
}
});
}

Meteor.call('getRoomRoles', this.data._id, function(error, results) {
if (error) {
return handleError(error);
Expand Down