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] Rewrite admin pages #17388

Merged
merged 27 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
72b86f0
[NEW] Rewrite admin view-logs page (#17276)
dudizilla Apr 22, 2020
49ec1b6
[CHORE] Enable TypeScript in Storybook (#17386)
tassoevan Apr 22, 2020
2a6ddf4
[IMPROVE] Rearrange hooks (#17392)
tassoevan Apr 22, 2020
8b4dad5
Regression: Setup Wizard layout (#17394)
tassoevan Apr 23, 2020
35bed0e
Merge branch 'develop' into admin-refactor
ggazzo Apr 23, 2020
058c389
[FIX] Use useMediaQuery hook from @rocket.chat/fuselage-hooks (#17374)
tassoevan Apr 24, 2020
6374532
Merge branch 'develop' into admin-refactor
ggazzo Apr 24, 2020
4d58ac4
Prototype of rewritten Administration > Users and Administration > Ro…
gabriellsh Apr 27, 2020
1cd82ca
Merge branch 'develop' into admin-refactor
ggazzo Apr 28, 2020
890812c
[IMPROVE] Redesign Administration > Invites (#17390)
tassoevan Apr 28, 2020
6359c3c
[FIX] Prepare import page scroll issue (#17457)
ggazzo Apr 28, 2020
a26700c
[IMPROVE] Adm rewrite > Custom Status (#17456)
gabriellsh Apr 28, 2020
43a8649
[IMPROVE] Depart from /app/ui-admin (#17464)
tassoevan Apr 29, 2020
871271c
Fix bad component reference
tassoevan Apr 29, 2020
84169b6
fix: Admin Users Actions (#17469)
gabriellsh Apr 29, 2020
1573128
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into admi…
tassoevan May 4, 2020
72b98c2
Merge branch 'develop' into admin-refactor
ggazzo May 4, 2020
a7e88f8
Fix storybook
gabriellsh May 4, 2020
239ceeb
regression: Fix storybook
gabriellsh May 4, 2020
c9c6e9b
[IMPROVE] Custom emoji refactor (#17499)
dudizilla May 5, 2020
db7b469
Regression: Removed old user and room files from admin (#17528)
ggazzo May 5, 2020
9896f31
[IMPROVE] Custom sounds refactor (#17485)
MartinSchoeler May 5, 2020
48c43c6
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into admi…
ggazzo May 5, 2020
2848317
fix all paddings and mixed content between screens (#17538)
ggazzo May 5, 2020
e009ec8
Merge branch 'develop' into admin-refactor
ggazzo May 5, 2020
d8a89cd
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into admi…
tassoevan May 5, 2020
255901a
Update Fuselage
ggazzo May 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 0 additions & 19 deletions .storybook/.babelrc

This file was deleted.

4 changes: 0 additions & 4 deletions .storybook/addons.js

This file was deleted.

20 changes: 20 additions & 0 deletions .storybook/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
shippedProposals: true,
useBuiltIns: 'usage',
corejs: '3',
modules: 'commonjs',
},
],
'@babel/preset-react',
'@babel/preset-flow',
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
],
};
20 changes: 0 additions & 20 deletions .storybook/config.js

This file was deleted.

11 changes: 11 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
stories: [
'../app/**/*.stories.js',
'../client/**/*.stories.js',
'../ee/app/**/*.stories.js',
],
addons: [
'@storybook/addon-actions',
'@storybook/addon-knobs',
],
};
16 changes: 11 additions & 5 deletions .storybook/mocks/meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export const Meteor = {
_localStorage: window.localStorage,
absoluteUrl: () => {},
userId: () => {},
Streamer: () => {},
Streamer: () => ({
on: () => {},
removeListener: () => {},
}),
startup: () => {},
methods: () => {},
call: () => {},
Expand All @@ -31,10 +34,13 @@ export const Mongo = {
}),
};

export const ReactiveVar = () => ({
get: () => {},
set: () => {},
});
export const ReactiveVar = (val) => {
let currentVal = val;
return {
get: () => currentVal,
set: (val) => { currentVal = val; },
};
};

export const ReactiveDict = () => ({
get: () => {},
Expand Down
7 changes: 7 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { withKnobs } from '@storybook/addon-knobs';
import { addDecorator } from '@storybook/react';

import { rocketChatDecorator } from './mocks/decorators';

addDecorator(rocketChatDecorator);
addDecorator(withKnobs);
38 changes: 29 additions & 9 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,35 @@ module.exports = async ({ config }) => {
use: '@settlin/spacebars-loader',
});

config.plugins.push(new webpack.NormalModuleReplacementPlugin(
/^meteor/,
require.resolve('./mocks/meteor.js'),
));

config.plugins.push(new webpack.NormalModuleReplacementPlugin(
/\.\/server\/index.js/,
require.resolve('./mocks/empty.js'),
));
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: {
noEmit: false,
},
},
},
{
loader: 'react-docgen-typescript-loader',
},
],
});

config.resolve.extensions.push('.ts', '.tsx');

config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/^meteor/,
require.resolve('./mocks/meteor.js'),
),
new webpack.NormalModuleReplacementPlugin(
/\/server(\/index.js)$/,
require.resolve('./mocks/empty.js'),
),
);

config.mode = 'development';
config.optimization.usedExports = true;
Expand Down
28 changes: 28 additions & 0 deletions app/api/server/lib/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ export async function findAdminRooms({ uid, filter, types = [], pagination: { of
};
}

export async function findAdminRoom({ uid, rid }) {
if (!await hasPermissionAsync(uid, 'view-room-administration')) {
throw new Error('error-not-authorized');
}
const fields = {
prid: 1,
fname: 1,
name: 1,
t: 1,
cl: 1,
u: 1,
usernames: 1,
usersCount: 1,
muted: 1,
unmuted: 1,
ro: 1,
default: 1,
favorite: 1,
featured: 1,
topic: 1,
msgs: 1,
archived: 1,
tokenpass: 1,
};

return Rooms.findOneById(rid, { fields });
}

export async function findChannelAndPrivateAutocomplete({ uid, selector }) {
if (!await hasPermissionAsync(uid, 'view-other-user-channels')) {
return { items: [] };
Expand Down
43 changes: 42 additions & 1 deletion app/api/server/v1/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Busboy from 'busboy';
import { FileUpload } from '../../../file-upload';
import { Rooms, Messages } from '../../../models';
import { API } from '../api';
import { findAdminRooms, findChannelAndPrivateAutocomplete } from '../lib/rooms';
import { findAdminRooms, findChannelAndPrivateAutocomplete, findAdminRoom } from '../lib/rooms';

function findRoomByIdOrName({ params, checkedArchived = true }) {
if ((!params.roomId || !params.roomId.trim()) && (!params.roomName || !params.roomName.trim())) {
Expand Down Expand Up @@ -299,6 +299,22 @@ API.v1.addRoute('rooms.adminRooms', { authRequired: true }, {
},
});

API.v1.addRoute('rooms.adminRooms.getRoom', { authRequired: true }, {
get() {
const { rid } = this.requestParams();
const room = Promise.await(findAdminRoom({
uid: this.userId,
rid,
}));

if (!room) {
return API.v1.failure('not-allowed', 'Not Allowed');
}
return API.v1.success(room);
},
});


API.v1.addRoute('rooms.autocomplete.channelAndPrivate', { authRequired: true }, {
get() {
const { selector } = this.queryParams;
Expand All @@ -312,3 +328,28 @@ API.v1.addRoute('rooms.autocomplete.channelAndPrivate', { authRequired: true },
})));
},
});

API.v1.addRoute('rooms.saveRoomSettings', { authRequired: true }, {
post() {
const { rid, ...params } = this.bodyParams;

const result = Meteor.runAsUser(this.userId, () => Meteor.call('saveRoomSettings', rid, params));

return API.v1.success({ rid: result.rid });
},
});

API.v1.addRoute('rooms.changeArchivationState', { authRequired: true }, {
post() {
const { rid, action } = this.bodyParams;

let result;
if (action === 'archive') {
result = Meteor.runAsUser(this.userId, () => Meteor.call('archiveRoom', rid));
} else {
result = Meteor.runAsUser(this.userId, () => Meteor.call('unarchiveRoom', rid));
}

return API.v1.success({ result });
},
});
3 changes: 3 additions & 0 deletions app/api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ API.v1.addRoute('users.create', { authRequired: true }, {
password: String,
username: String,
active: Match.Maybe(Boolean),
bio: Match.Maybe(String),
statusText: Match.Maybe(String),
roles: Match.Maybe(Array),
joinDefaultChannels: Match.Maybe(Boolean),
requirePasswordChange: Match.Maybe(Boolean),
Expand Down Expand Up @@ -431,6 +433,7 @@ API.v1.addRoute('users.update', { authRequired: true, twoFactorRequired: true },
name: Match.Maybe(String),
password: Match.Maybe(String),
username: Match.Maybe(String),
bio: Match.Maybe(String),
statusText: Match.Maybe(String),
active: Match.Maybe(Boolean),
roles: Match.Maybe(Array),
Expand Down
2 changes: 1 addition & 1 deletion app/apps/client/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import toastr from 'toastr';

import { AppWebsocketReceiver } from './communication';
import { APIClient } from '../../utils';
import { registerAdminSidebarItem } from '../../ui-admin/client';
import { registerAdminSidebarItem } from '../../../client/admin';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { hasAtLeastOnePermission } from '../../authorization';
import { handleI18nResources } from './i18n';
Expand Down
2 changes: 1 addition & 1 deletion app/apps/client/routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';

import { registerAdminRoute } from '../../ui-admin/client';
import { registerAdminRoute } from '../../../client/admin';
import { Apps } from './orchestrator';

registerAdminRoute('/apps/what-is-it', {
Expand Down
2 changes: 1 addition & 1 deletion app/authorization/client/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BlazeLayout } from 'meteor/kadira:blaze-layout';

import { registerAdminRoute } from '../../ui-admin/client';
import { registerAdminRoute } from '../../../client/admin';
import { t } from '../../utils/client';

registerAdminRoute('/permissions', {
Expand Down
2 changes: 1 addition & 1 deletion app/authorization/client/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { hasAtLeastOnePermission } from './hasPermission';
import { registerAdminSidebarItem } from '../../ui-admin/client';
import { registerAdminSidebarItem } from '../../../client/admin';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { APIClient } from '../../utils/client';
import { Roles } from '../../models/client';
Expand Down
2 changes: 1 addition & 1 deletion app/channel-settings/client/views/Multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createTemplateForComponent } from '../../../../client/reactAdapters';

createTemplateForComponent(
'Multiselect',
() => import('../../../ui-admin/client/components/settings/inputs/MultiSelectSettingInput'),
() => import('../../../../client/admin/settings/inputs/MultiSelectSettingInput'),
{
// eslint-disable-next-line new-cap
renderContainerView: () => HTML.DIV({ class: 'rc-multiselect', style: 'display: flex;' }),
Expand Down
2 changes: 1 addition & 1 deletion app/chatpal-search/client/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BlazeLayout } from 'meteor/kadira:blaze-layout';

import { registerAdminRoute } from '../../ui-admin/client';
import { registerAdminRoute } from '../../../client/admin';
import { t } from '../../utils';

registerAdminRoute('/chatpal', {
Expand Down
2 changes: 1 addition & 1 deletion app/cloud/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './admin/cloudRegisterManually';

import { BlazeLayout } from 'meteor/kadira:blaze-layout';

import { registerAdminRoute, registerAdminSidebarItem } from '../../ui-admin/client';
import { registerAdminRoute, registerAdminSidebarItem } from '../../../client/admin';
import { hasAtLeastOnePermission } from '../../authorization';

registerAdminRoute('/cloud', {
Expand Down
Loading