Skip to content

Commit

Permalink
Rename toolbox actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Mar 14, 2023
1 parent 98b91f4 commit aacd393
Show file tree
Hide file tree
Showing 83 changed files with 217 additions and 208 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/.eslintcache

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IUIActionButton } from '@rocket.chat/apps-engine/definition/ui';

import { Utilities } from '../../../../ee/lib/misc/Utilities';
import { messageToolboxActions } from '../../../ui-utils/client';
import { messageToolboxActions } from '../../../../client/lib/MessageToolboxActions';
import { messageArgs } from '../../../../client/lib/utils/messageArgs';
import { t } from '../../../utils/client';
import { triggerActionButtonAction } from '../ActionManager';
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/app/ui-message/client/actionButtons/tabbar.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import type { IUIActionButton } from '@rocket.chat/apps-engine/definition/ui';

import { addAction, deleteAction } from '../../../../client/views/room/lib/Toolbox';
import { roomToolboxActions } from '../../../../client/views/room/lib/Toolbox';
import { Utilities } from '../../../../ee/lib/misc/Utilities';
import { t } from '../../../utils/client';
import { triggerActionButtonAction } from '../ActionManager';
import { applyButtonFilters } from './lib/applyButtonFilters';

const getIdForActionButton = ({ appId, actionId }: IUIActionButton): string => `${appId}/${actionId}`;

export const onAdded = (button: IUIActionButton): void =>
// eslint-disable-next-line no-void
void addAction(getIdForActionButton(button), ({ room }) =>
export const onAdded = (button: IUIActionButton): void => {
roomToolboxActions.add(getIdForActionButton(button), ({ room }) =>
applyButtonFilters(button, room)
? {
id: button.actionId,
Expand All @@ -30,5 +29,6 @@ export const onAdded = (button: IUIActionButton): void =>
}
: null,
);
};

export const onRemoved = (button: IUIActionButton): boolean => deleteAction(getIdForActionButton(button));
export const onRemoved = (button: IUIActionButton): boolean => roomToolboxActions.remove(getIdForActionButton(button));
1 change: 0 additions & 1 deletion apps/meteor/app/ui-utils/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { AccountBox } from './lib/AccountBox';
export { messageToolboxActions } from './lib/MessageToolboxActions';
export { messageBox } from './lib/messageBox';
export { readMessage } from './lib/readMessages';
export { RoomManager } from './lib/RoomManager';
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/components/message/ToolboxHolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
import type { ReactElement } from 'react';
import React, { memo, useRef } from 'react';

import type { MessageToolboxActionContext } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import type { MessageToolboxActionContext } from '../../lib/MessageToolboxActions';
import { useChat } from '../../views/room/contexts/ChatContext';
import { useIsVisible } from '../../views/room/hooks/useIsVisible';
import Toolbox from './toolbox/Toolbox';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ComponentProps, UIEvent, ReactElement } from 'react';
import React, { useState, Fragment, useRef } from 'react';

import type { MessageToolboxActionConfig } from '../../../../app/ui-utils/client/lib/MessageToolboxActions';
import { useEmbeddedLayout } from '../../../hooks/useEmbeddedLayout';
import type { MessageToolboxActionConfig } from '../../../lib/MessageToolboxActions';
import ToolboxDropdown from './ToolboxDropdown';

type MessageActionConfigOption = Omit<MessageToolboxActionConfig, 'condition' | 'context' | 'order' | 'action'> & {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/components/message/toolbox/Toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useQuery } from '@tanstack/react-query';
import type { ReactElement } from 'react';
import React, { memo, useMemo } from 'react';

import type { MessageToolboxActionContext } from '../../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../../../app/ui-utils/client/lib/MessageToolboxActions';
import type { MessageToolboxActionContext } from '../../../lib/MessageToolboxActions';
import { messageToolboxActions } from '../../../lib/MessageToolboxActions';
import { useIsSelecting } from '../../../views/room/MessageList/contexts/SelectedMessagesContext';
import { useAutoTranslate } from '../../../views/room/MessageList/hooks/useAutoTranslate';
import { useChat } from '../../../views/room/contexts/ChatContext';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useUserId } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useRef, memo } from 'react';

import type { MessageToolboxActionContext } from '../../../../app/ui-utils/client/lib/MessageToolboxActions';
import type { MessageToolboxActionContext } from '../../../lib/MessageToolboxActions';
import { useIsMessageHighlight } from '../../../views/room/MessageList/contexts/MessageHighlightContext';
import {
useIsSelecting,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { ComponentProps, ContextType, UIEvent } from 'react';
import type { IMessage, IUser, ISubscription, IRoom, SettingValue, Serialized, ITranslatedMessage } from '@rocket.chat/core-typings';
import type { Icon } from '@rocket.chat/fuselage';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import mem from 'mem';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import type { Icon } from '@rocket.chat/fuselage';
import type { IMessage, IUser, ISubscription, IRoom, SettingValue, Serialized, ITranslatedMessage } from '@rocket.chat/core-typings';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import type { ComponentProps, ContextType, UIEvent } from 'react';

import { Messages, Rooms, Subscriptions } from '../../../models/client';
import { roomCoordinator } from '../../../../client/lib/rooms/roomCoordinator';
import type { ToolboxContextValue } from '../../../../client/views/room/contexts/ToolboxContext';
import type { ChatContext } from '../../../../client/views/room/contexts/ChatContext';
import { APIClient } from '../../../utils/client';
import type { AutoTranslateOptions } from '../../../../client/views/room/MessageList/hooks/useAutoTranslate';
import { Messages, Rooms, Subscriptions } from '../../app/models/client';
import { APIClient } from '../../app/utils/client';
import type { AutoTranslateOptions } from '../views/room/MessageList/hooks/useAutoTranslate';
import type { ChatContext } from '../views/room/contexts/ChatContext';
import type { ToolboxContextValue } from '../views/room/contexts/ToolboxContext';
import { roomCoordinator } from './rooms/roomCoordinator';

const findMessage = async (msgId: string): Promise<Serialized<IMessage> | null> => {
try {
Expand Down Expand Up @@ -132,10 +132,10 @@ class MessageToolboxActions {
}

private getButtonsByGroup = mem(
function (
(
group: MessageToolboxActionGroup,
arr: MessageToolboxActionConfigList = messageToolboxActions._getButtons(),
): MessageToolboxActionConfigList {
): MessageToolboxActionConfigList => {
return arr.filter((button) => !button.group || (Array.isArray(button.group) ? button.group.includes(group) : button.group === group));
},
{ maxAge: 1000 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { Box, Option } from '@rocket.chat/fuselage';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import type { ComponentProps, ReactNode } from 'react';

import type { ToolboxActionConfig } from '../Toolbox';
import type { Events as GeneratorEvents } from '../Toolbox/generator';
import { generator } from '../Toolbox/generator';
import type { ToolboxActionConfig } from '../views/room/lib/Toolbox';
import type { Events as GeneratorEvents } from '../views/room/lib/Toolbox/generator';
import { generator } from '../views/room/lib/Toolbox/generator';

type QuickActionsHook = ({ room }: { room: IRoom }) => QuickActionsActionConfig | null;

Expand Down Expand Up @@ -37,13 +37,13 @@ export type QuickActionsActionConfig = ToolboxActionConfig & {

export type QuickActionsAction = QuickActionsHook | QuickActionsActionConfig;

const { listen, add: addAction, remove: deleteAction, store: actions } = generator<QuickActionsAction>();
const { listen, add, remove, store: actions } = generator<QuickActionsAction>();

export type Events = GeneratorEvents<QuickActionsAction>;

export { listen, addAction, deleteAction, actions };
export { listen, actions };

export enum QuickActionsEnum {
export const enum QuickActionsEnum {
MoveQueue = 'rocket-move-to-queue',
ChatForward = 'rocket-chat-forward',
Transcript = 'rocket-transcript',
Expand All @@ -52,3 +52,8 @@ export enum QuickActionsEnum {
CloseChat = 'rocket-close-chat',
OnHoldChat = 'rocket-on-hold-chat',
}

export const quickActions = {
add,
remove,
};
3 changes: 2 additions & 1 deletion apps/meteor/client/lib/chats/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import moment from 'moment';
import { hasAtLeastOnePermission, hasPermission } from '../../../app/authorization/client';
import { Messages, ChatRoom, ChatSubscription } from '../../../app/models/client';
import { settings } from '../../../app/settings/client';
import { readMessage, MessageTypes, messageToolboxActions } from '../../../app/ui-utils/client';
import { readMessage, MessageTypes } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../MessageToolboxActions';
import { onClientBeforeSendMessage } from '../onClientBeforeSendMessage';
import { call } from '../utils/call';
import type { DataAPI } from './ChatAPI';
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/client/startup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import './afterLogoutCleanUp';
import './appRoot';
import './cachedCollections';
import './callbacks';
import './contextualBarActions';
import './customEmoji';
import './customOAuth';
import './customTranslations';
Expand Down Expand Up @@ -41,12 +40,14 @@ import './oauth';
import './openedRoom';
import './otr';
import './otrMessageTypes';
import './quickActions';
import './readMessage';
import './reloadRoomAfterLogin';
import './renderMessage';
import './renderNotification';
import './roles';
import './roomObserve';
import './roomToolboxActions';
import './rootUrlChange';
import './routes';
import './settingsOnLoadSiteUrl';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { hasAtLeastOnePermission } from '../../../app/authorization/client';
import { AutoTranslate } from '../../../app/autotranslate/client/lib/autotranslate';
import { Messages } from '../../../app/models/client';
import { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { call } from '../../lib/utils/call';
import { messageArgs } from '../../lib/utils/messageArgs';
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/startup/messageToolboxActions/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IMessage } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';

import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { dispatchToastMessage } from '../../lib/toast';
import { messageArgs } from '../../lib/utils/messageArgs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isRoomFederated } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { messageArgs } from '../../lib/utils/messageArgs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
import moment from 'moment';

import { hasAtLeastOnePermission, hasPermission } from '../../../app/authorization/client';
import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { messageArgs } from '../../lib/utils/messageArgs';

Meteor.startup(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Tracker } from 'meteor/tracker';

import { Messages } from '../../../app/models/client';
import { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { dispatchToastMessage } from '../../lib/toast';
import { callWithErrorHandling } from '../../lib/utils/callWithErrorHandling';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { messageArgs } from '../../lib/utils/messageArgs';
import { setMessageJumpQueryStringParameter } from '../../lib/utils/setMessageJumpQueryStringParameter';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { messageArgs } from '../../lib/utils/messageArgs';
import { setMessageJumpQueryStringParameter } from '../../lib/utils/setMessageJumpQueryStringParameter';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { messageArgs } from '../../lib/utils/messageArgs';
import { setMessageJumpQueryStringParameter } from '../../lib/utils/setMessageJumpQueryStringParameter';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';

import { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { messageArgs } from '../../lib/utils/messageArgs';
import { setMessageJumpQueryStringParameter } from '../../lib/utils/setMessageJumpQueryStringParameter';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { Meteor } from 'meteor/meteor';

import { ChatSubscription } from '../../../app/models/client';
import { RoomManager, messageToolboxActions } from '../../../app/ui-utils/client';
import { RoomManager } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { dispatchToastMessage } from '../../lib/toast';
import { call } from '../../lib/utils/call';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';

import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { dispatchToastMessage } from '../../lib/toast';
import { messageArgs } from '../../lib/utils/messageArgs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client';
import { t } from '../../../app/utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { dispatchToastMessage } from '../../lib/toast';
import { messageArgs } from '../../lib/utils/messageArgs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client';
import { t } from '../../../app/utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { dispatchToastMessage } from '../../lib/toast';
import { messageArgs } from '../../lib/utils/messageArgs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';

import { hasAtLeastOnePermission } from '../../../app/authorization/client';
import { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { queryClient } from '../../lib/queryClient';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { dispatchToastMessage } from '../../lib/toast';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { messageArgs } from '../../lib/utils/messageArgs';

Meteor.startup(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { imperativeModal } from '../../lib/imperativeModal';
import { messageArgs } from '../../lib/utils/messageArgs';
import ReactionList from '../../views/room/modals/ReactionListModal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';

import { EmojiPicker } from '../../../app/emoji/client';
import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { call } from '../../lib/utils/call';
import { messageArgs } from '../../lib/utils/messageArgs';
Expand Down
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 { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { imperativeModal } from '../../lib/imperativeModal';
import { messageArgs } from '../../lib/utils/messageArgs';
import ReadReceiptsModal from '../../views/room/modals/ReadReceiptsModal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';

import { hasPermission } from '../../../app/authorization/client';
import { Rooms, Subscriptions } from '../../../app/models/client';
import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { messageArgs } from '../../lib/utils/messageArgs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { messageArgs } from '../../lib/utils/messageArgs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IMessage } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';

import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { imperativeModal } from '../../lib/imperativeModal';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { messageArgs } from '../../lib/utils/messageArgs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IUser } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';

import { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { queryClient } from '../../lib/queryClient';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { dispatchToastMessage } from '../../lib/toast';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Tracker } from 'meteor/tracker';

import { hasPermission } from '../../../app/authorization/client';
import { settings } from '../../../app/settings/client';
import { messageToolboxActions } from '../../../app/ui-utils/client/lib/MessageToolboxActions';
import CreateDiscussion from '../../components/CreateDiscussion/CreateDiscussion';
import { messageToolboxActions } from '../../lib/MessageToolboxActions';
import { imperativeModal } from '../../lib/imperativeModal';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { messageArgs } from '../../lib/utils/messageArgs';
Expand Down
Loading

0 comments on commit aacd393

Please sign in to comment.