Skip to content

Commit

Permalink
Merge branch 'new/apps_rewrite' of github.com:RocketChat/Rocket.Chat …
Browse files Browse the repository at this point in the history
…into new/apps_rewrite_local

* 'new/apps_rewrite' of github.com:RocketChat/Rocket.Chat: (30 commits)
  Sort imports
  Move sidebar items registration
  Embed useMenuOptions into AppMenu
  Fix route redirection
  Fix lint errors
  Fix infinite loop in CodeSettingInput
  Fix spacing in What Is It page
  [IMPROVE] Performance editing Admin settings (#17916)
  [IMPROVE] React hooks lint rules (#17941)
  [FIX] StreamCast stream to server only streamers (#17942)
  [FIX] Profile save button not activates properly when changing the username field (#16541)
  [FIX] Outgoing webhook: Excessive spacing between trigger words (#17830)
  [FIX] Links being escaped twice leading to visible encoded characters (#16481)
  [NEW][API] New endpoints to manage User Custom Status `custom-user-status.create`, custom-user-status.delete` and `custom-user-status.update` (#16550)
  [FIX] Message action popup doesn't adjust itself on screen resize (#16508)
  [FIX] Not possible to translate the label of custom fields in user's Info (#15595)
  [FIX] Close the user info context panel does not navigate back to the user's list (#14085)
  [FIX] Missing pinned icon indicator for messages pinned (#16448)
  Chatpal: limit results to current room (#17718)
  Do not build Docker image for fork PRs (#17370)
  ...
  • Loading branch information
gabriellsh committed Jun 18, 2020
2 parents 230ba73 + b87b5fa commit cc80513
Show file tree
Hide file tree
Showing 235 changed files with 6,259 additions and 2,737 deletions.
42 changes: 29 additions & 13 deletions .docker-mongo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
FROM rocketchat/base:12.16.1
FROM node:12.16.1-buster-slim

LABEL maintainer="[email protected]"

# Install MongoDB and dependencies
RUN set -x \
&& apt-get update \
&& apt-get install -y wget \
&& wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | apt-key add - \
&& echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list \
&& apt-get update \
&& apt-get install -y pwgen mongodb-org \
&& apt-get clean my room
&& apt-get update \
&& apt-get install -y wget gnupg dirmngr pwgen \
&& wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - \
&& echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list \
&& apt-get update \
&& apt-get install -y mongodb-org fontconfig \
&& apt-get clean my room \
&& groupadd -g 65533 -r rocketchat \
&& useradd -u 65533 -r -g rocketchat rocketchat \
&& mkdir -p /app/uploads \
&& chown rocketchat:rocketchat /app/uploads

ADD . /app
ADD entrypoint.sh /app/bundle/

RUN set -x \
&& cd /app/bundle/programs/server \
&& npm install \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app
RUN aptMark="$(apt-mark showmanual)" \
&& apt-get install -y --no-install-recommends g++ make python ca-certificates \
&& cd /app/bundle/programs/server \
&& npm install \
&& apt-mark auto '.*' > /dev/null \
&& apt-mark manual $aptMark > /dev/null \
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app

VOLUME /app/uploads

Expand Down
2 changes: 1 addition & 1 deletion .docker-mongo/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ echo """
╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝
"""

mongod --smallfiles --storageEngine=mmapv1 --fork --replSet rs0 --config /etc/mongod.conf
mongod --fork --replSet rs0 --config /etc/mongod.conf

until mongo --eval "db" &> /dev/null; do
echo "MongoDB still not ready, sleeping"
Expand Down
35 changes: 27 additions & 8 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
FROM rocketchat/base:12.16.1

ADD . /app
FROM node:12.16.1-buster-slim

LABEL maintainer="[email protected]"

RUN set -x \
&& cd /app/bundle/programs/server \
&& npm install \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app
# dependencies
RUN groupadd -g 65533 -r rocketchat \
&& useradd -u 65533 -r -g rocketchat rocketchat \
&& mkdir -p /app/uploads \
&& chown rocketchat:rocketchat /app/uploads \
&& apt-get update \
&& apt-get install -y --no-install-recommends fontconfig

ADD . /app

RUN aptMark="$(apt-mark showmanual)" \
&& apt-get install -y --no-install-recommends g++ make python ca-certificates \
&& cd /app/bundle/programs/server \
&& npm install \
&& apt-mark auto '.*' > /dev/null \
&& apt-mark manual $aptMark > /dev/null \
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app

USER rocketchat

Expand Down
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"jscolor": false
},
"plugins": [
"react"
"react",
"react-hooks"
],
"rules": {
"jsx-quotes": [
Expand All @@ -24,7 +25,9 @@
"react/jsx-fragments": [
"error",
"syntax"
]
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
},
"settings": {
"import/resolver": {
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: Github Info
run: |
echo "GITHUB_ACTION: $GITHUB_ACTION"
Expand All @@ -34,7 +35,15 @@ jobs:
with:
node-version: "12.16.1"

- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: check package-lock
run: |
Expand Down Expand Up @@ -199,7 +208,7 @@ jobs:
docker exec mongo mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})'
docker exec mongo mongo --eval 'rs.status()'
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Cache cypress
id: cache-cypress
Expand Down Expand Up @@ -245,10 +254,10 @@ jobs:

build-image-pr:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
if: github.event.pull_request.head.repo.full_name == github.repository

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Free disk space
run: |
Expand Down Expand Up @@ -356,7 +365,7 @@ jobs:
needs: test

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Restore build
uses: actions/download-artifact@v1
Expand Down Expand Up @@ -409,7 +418,7 @@ jobs:
IMAGE: "rocketchat/rocket.chat"

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Restore build
uses: actions/download-artifact@v1
Expand Down
2 changes: 1 addition & 1 deletion .storybook/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const useAutoToggle = (initialValue = false, ms = 1000) => {
return () => {
clearInterval(timer);
};
}, []);
}, [ms]);

return value;
};
3 changes: 0 additions & 3 deletions app/accounts/README.md

This file was deleted.

24 changes: 0 additions & 24 deletions app/accounts/server/config.js

This file was deleted.

8 changes: 0 additions & 8 deletions app/accounts/server/index.js

This file was deleted.

3 changes: 1 addition & 2 deletions app/api/server/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ settings.addGroup('General', function() {
this.add('API_Enable_CORS', false, { type: 'boolean', public: false });
this.add('API_CORS_Origin', '*', { type: 'string', public: false, enableQuery: { _id: 'API_Enable_CORS', value: true } });

this.add('API_Use_REST_For_DDP_Calls', false, {
this.add('API_Use_REST_For_DDP_Calls', true, {
type: 'boolean',
public: true,
alert: 'API_Use_REST_For_DDP_Calls_Alert',
});
});
});
70 changes: 70 additions & 0 deletions app/api/server/v1/custom-user-status.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';

import { CustomUserStatus } from '../../../models';
import { API } from '../api';
import { findCustomUserStatus } from '../lib/custom-user-status';

Expand All @@ -16,3 +20,69 @@ API.v1.addRoute('custom-user-status.list', { authRequired: true }, {
})));
},
});

API.v1.addRoute('custom-user-status.create', { authRequired: true }, {
post() {
check(this.bodyParams, {
name: String,
statusType: Match.Maybe(String),
});

const userStatusData = {
name: this.bodyParams.name,
statusType: this.bodyParams.statusType,
};

Meteor.runAsUser(this.userId, () => {
Meteor.call('insertOrUpdateUserStatus', userStatusData);
});

return API.v1.success({
customUserStatus: CustomUserStatus.findOneByName(userStatusData.name),
});
},
});

API.v1.addRoute('custom-user-status.delete', { authRequired: true }, {
post() {
const { customUserStatusId } = this.bodyParams;
if (!customUserStatusId) {
return API.v1.failure('The "customUserStatusId" params is required!');
}

Meteor.runAsUser(this.userId, () => Meteor.call('deleteCustomUserStatus', customUserStatusId));

return API.v1.success();
},
});

API.v1.addRoute('custom-user-status.update', { authRequired: true }, {
post() {
check(this.bodyParams, {
_id: String,
name: String,
statusType: Match.Maybe(String),
});

const userStatusData = {
_id: this.bodyParams._id,
name: this.bodyParams.name,
statusType: this.bodyParams.statusType,
};

const customUserStatus = CustomUserStatus.findOneById(userStatusData._id);

// Ensure the message exists
if (!customUserStatus) {
return API.v1.failure(`No custom user status found with the id of "${ userStatusData._id }".`);
}

Meteor.runAsUser(this.userId, () => {
Meteor.call('insertOrUpdateUserStatus', userStatusData);
});

return API.v1.success({
customUserStatus: CustomUserStatus.findOneById(userStatusData._id),
});
},
});
1 change: 1 addition & 0 deletions app/api/server/v1/invites.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ API.v1.addRoute('removeInvite/:_id', { authRequired: true }, {
API.v1.addRoute('useInviteToken', { authRequired: true }, {
post() {
const { token } = this.bodyParams;
// eslint-disable-next-line react-hooks/rules-of-hooks
const result = useInviteToken(this.userId, token);

return API.v1.success(result);
Expand Down
31 changes: 9 additions & 22 deletions app/apps/client/orchestrator.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Meteor } from 'meteor/meteor';
import { AppClientManager } from '@rocket.chat/apps-engine/client/AppClientManager';
import { Meteor } from 'meteor/meteor';
import toastr from 'toastr';

import { AppWebsocketReceiver } from './communication';
import { APIClient } from '../../utils';
import { registerAdminSidebarItem } from '../../../client/admin';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { hasAtLeastOnePermission } from '../../authorization';
import { settings } from '../../settings/client';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { APIClient } from '../../utils';
import { AppWebsocketReceiver } from './communication';
import { handleI18nResources } from './i18n';
import { RealAppsEngineUIHost } from './RealAppsEngineUIHost';

Expand All @@ -32,7 +32,6 @@ class AppClientOrchestrator {
load = async (isEnabled) => {
if (!this.isLoaded) {
this.ws = new AppWebsocketReceiver();
this.registerAdminMenuItems();
this.isLoaded = true;
}

Expand All @@ -50,22 +49,6 @@ class AppClientOrchestrator {

getAppClientManager = () => this._manager;

registerAdminMenuItems = () => {
registerAdminSidebarItem({
icon: 'cube',
href: 'admin-apps',
i18nLabel: 'Apps',
permissionGranted: () => hasAtLeastOnePermission(['manage-apps']),
});

registerAdminSidebarItem({
icon: 'cube',
href: 'admin-marketplace',
i18nLabel: 'Marketplace',
permissionGranted: () => hasAtLeastOnePermission(['manage-apps']),
});
}

handleError = (error) => {
console.error(error);
if (hasAtLeastOnePermission(['manage-apps'])) {
Expand Down Expand Up @@ -208,4 +191,8 @@ Meteor.startup(() => {
Apps.load(isEnabled);
});
});

settings.get('Apps_Framework_enabled', (isEnabled) => {
Apps.load(isEnabled);
});
});
Loading

0 comments on commit cc80513

Please sign in to comment.