feat: add context menu in sms message table.

This commit is contained in:
elforjani13
2021-11-08 16:41:36 +02:00
parent 8c2d138976
commit 7a1c9caa70
5 changed files with 45 additions and 19 deletions

View File

@@ -20,7 +20,7 @@ function SMSMessageDialog({
return (
<Dialog
name={dialogName}
title={intl.get('sms_message')}
title={intl.get('sms_message.dialog.label')}
isOpen={isOpen}
canEscapeJeyClose={true}
autoFocus={true}

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { DataTableEditable, DataTable } from 'components';
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import { useSMSIntegrationTableColumns } from './components';
import { useSMSIntegrationTableColumns, ActionsMenu } from './components';
import { useSMSIntegrationContext } from './SMSIntegrationProvider';
import withDialogActions from 'containers/Dialog/withDialogActions';
@@ -18,10 +18,12 @@ function SMSMessagesDataTable({
const { notifications, isSMSNotificationsLoading } =
useSMSIntegrationContext();
const handleEditSMSMessage = ({ key }) => {
const handleEditMessageText = ({ key }) => {
openDialog('sms-message-form', { notificationkey: key });
};
const handleEnableNotification = () => {};
return (
<DataTable
columns={columns}
@@ -30,8 +32,10 @@ function SMSMessagesDataTable({
progressBarLoading={isSMSNotificationsLoading}
TableLoadingRenderer={TableSkeletonRows}
noInitialFetch={true}
ContextMenu={ActionsMenu}
payload={{
onEditSMSMessage: handleEditSMSMessage,
onEditMessageText: handleEditMessageText,
onEnableNotification: handleEnableNotification,
}}
/>
);

View File

@@ -1,8 +1,27 @@
import React from 'react';
import intl from 'react-intl-universal';
import { Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
import { SwitchFieldCell } from 'components/DataTableCells';
import { safeCallback } from 'utils';
export function ActionsMenu({
payload: { onEditMessageText, onEnableNotification },
row: { original },
}) {
return (
<Menu>
<MenuItem
text={intl.get('edit_message_text')}
onClick={safeCallback(onEditMessageText, original)}
/>
<MenuItem
text={intl.get('enable_notification')}
onClick={safeCallback(onEnableNotification, original)}
/>
</Menu>
);
}
/**
* Notification accessor.
*/
@@ -18,14 +37,14 @@ export const NotificationAccessor = (row) => {
};
export const SMSMessageCell = ({
payload: { onEditSMSMessage },
payload: { onEditMessageText },
row: { original },
}) => (
<div>
{original.sms_message}
<span
className="edit-text"
onClick={safeCallback(onEditSMSMessage, original)}
onClick={safeCallback(onEditMessageText, original)}
>
{'Edit'}
</span>
@@ -35,7 +54,7 @@ export const SMSMessageCell = ({
export function useSMSIntegrationTableColumns() {
return React.useMemo(() => [
{
Header: intl.get('sms_message.label_Notification'),
Header: intl.get('sms_messages.label_notification'),
accessor: NotificationAccessor,
className: 'notification',
width: '180',
@@ -49,7 +68,7 @@ export function useSMSIntegrationTableColumns() {
disableSortBy: true,
},
{
Header: intl.get('sms_message.label_mesage'),
Header: intl.get('sms_messages.label_mesage'),
accessor: 'sms_message',
Cell: SMSMessageCell,
className: 'sms_message',
@@ -58,7 +77,7 @@ export function useSMSIntegrationTableColumns() {
disableSortBy: true,
},
{
Header: intl.get('sms_message.label_auto'),
Header: intl.get('sms_messages.label_auto'),
accessor: 'is_notification_enabled',
Cell: SwitchFieldCell,
className: 'is_notification_enabled',

View File

@@ -1455,9 +1455,11 @@
"sms_integration.label.overview":"نظرة عامة",
"sms_integration.label.sms_messages":"رسائل SMS ",
"sms_message.label.sms_messages_template":" إشعارات رسائل قصيرة ",
"sms_message.label_mesage":"رسالة ",
"sms_message.label_Notification":"إشعار",
"sms_message.label_auto":"Auto",
"sms_messages.label_mesage":"رسالة ",
"sms_messages.label_notification":"إشعار",
"sms_messages.label_auto":"Auto",
"sms_message":"رسالة SMS" ,
"sms_message.dialog.success_message":"Sms notification settings has been updated successfully."
"sms_message.dialog.success_message":"Sms notification settings has been updated successfully.",
"edit_message_text":"تعديل نص رسالة",
"enable_notification":"تفعيل الإشعارات"
}

View File

@@ -1440,12 +1440,13 @@
"sms_integration.label":"SMS Integration",
"sms_integration.label.overview":"Overview",
"sms_integration.label.sms_messages":"SMS Messages",
"sms_message.label.sms_messages_template":"SMS Notifications ",
"sms_message.label_mesage":"Message",
"sms_message.label_Notification":"Notification",
"sms_message.label_auto":"Auto",
"sms_message":"SMS message",
"sms_messages.label_notification":"Notification",
"sms_messages.label_mesage":"Message",
"sms_messages.label_auto":"Auto",
"sms_message.dialog.label":"SMS message",
"sms_message.dialog.success_message":"Sms notification settings has been updated successfully.",
"sms_message.dialog.unsupported_variables_error_message":"Unsupported variables"
"sms_message.dialog.unsupported_variables_error_message":"Unsupported variables",
"edit_message_text":"Edit message text",
"enable_notification":"Enable notification"
}