Skip to content

Commit

Permalink
[FIX] Manage apps layout (#10882)
Browse files Browse the repository at this point in the history
Fix: Manage apps layout was a bit confuse
  • Loading branch information
gdelavald authored and rodrigok committed May 26, 2018
1 parent ebd915a commit 0bcc966
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
8 changes: 8 additions & 0 deletions packages/rocketchat-apps/assets/stylesheets/apps.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ div.apps-error {
width: 100%;
font-size: 45px;
}

.preferences-page--apps .rc-table-tr {
opacity: 0.5;
}

.preferences-page--apps .rc-table-tr.active {
opacity: 1;
}
3 changes: 3 additions & 0 deletions packages/rocketchat-apps/client/admin/appManage.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
<span class="rc-switch__text">
{{_ "Activate"}}
</span>
</label>
</div>

Expand Down
14 changes: 12 additions & 2 deletions packages/rocketchat-apps/client/admin/apps.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
<!-- TODO: fix this class -->
<section class="preferences-page preferences-page--apps">
{{#header sectionName="Manage_Apps" hideHelp=true fixedHeight=true}}
<button class="rc-button rc-button--small rc-button--primary rc-directory-plus rc-tooltip rc-tooltip--down" data-button="install" aria-label="{{_ 'Install_package'}}">{{> icon icon="plus"}}</button>
<div class="rc-directory-header">
<div class="rc-input rc-input--small rc-directory-search">
<label class="rc-input__label">
<div class="rc-input__wrapper">
{{> icon icon="magnifier" block="rc-input__icon" }}
<input type="text" class="rc-input__element rc-input__element--small js-search" name="app-filter" id="app-filter" placeholder={{_ "Search"}} autocomplete="off">
</div>
</label>
</div>
<button class="rc-button rc-button--small rc-button--primary rc-directory-plus rc-tooltip rc-tooltip--down" data-button="install" aria-label="{{_ 'Install_package'}}">{{> icon icon="plus"}}</button>
</div>
{{/header}}
<div class="rc-directory-content">
{{#requiresPermission 'manage-apps'}}
Expand All @@ -17,7 +27,7 @@
</thead>
<tbody class="rc-table-body">
{{#each apps}}
<tr class="rc-table-tr" data-name="{{name}}">
<tr class="rc-table-tr {{activeClass status}}" data-name="{{name}}">
<td class="rc-table-td rc-table-td--name">
<div class="rc-directory-channel-wrapper">
<div class="rc-directory-channel-avatar" style="background-image:url({{iconFileContent}})"></div>
Expand Down
23 changes: 21 additions & 2 deletions packages/rocketchat-apps/client/admin/apps.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { AppEvents } from '../communication';
const ENABLED_STATUS = ['auto_enabled', 'manually_enabled'];
const enabled = ({status}) => ENABLED_STATUS.includes(status);
const sortByStatus = (a, b) => {
if (enabled(a)) {
if (enabled(b)) {
return a.name > b.name;
}
return -1;
}
return 1;
};

Template.apps.onCreated(function() {
const instance = this;
this.ready = new ReactiveVar(false);
this.apps = new ReactiveVar([]);
this.filter = new ReactiveVar('');

RocketChat.API.get('apps').then((result) => {
instance.apps.set(result.apps);
Expand Down Expand Up @@ -53,10 +65,15 @@ Template.apps.helpers({
return false;
},
apps() {
return Template.instance().apps.get();
const instance = Template.instance();
const filter = instance.filter.get().toLowerCase();
return instance.apps.get().filter(({name}) => name.toLowerCase().includes(filter)).sort(sortByStatus);
},
parseStatus(status) {
return t(`App_status_${ status }`);
},
activeClass(status) {
return enabled({status}) ? 'active' : '';
}
});

Expand All @@ -70,8 +87,10 @@ Template.apps.events({
// show an error ? I don't think this should ever happen
}
},

'click [data-button="install"]'() {
FlowRouter.go('/admin/app/install');
},
'keyup #app-filter'(e, t) {
t.filter.set(e.currentTarget.value);
}
});

0 comments on commit 0bcc966

Please sign in to comment.