Skip to content

Commit

Permalink
Finish editing and listing system messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE authored and Martin Kruliš committed May 17, 2019
1 parent 4619ed4 commit 4f7d45e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/SystemMessages/MessagesList/MessagesList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
import { Alert } from 'react-bootstrap';
import { defaultMemoize } from 'reselect';

import SortableTable, { SortableTableColumnDescriptor } from '../../widgets/SortableTable';
Expand All @@ -9,14 +10,16 @@ import DateTime from '../../widgets/DateTime';
import { roleLabels } from '../../helpers/usersRoles';
import UsersNameContainer from '../../../containers/UsersNameContainer';

import styles from './MessagesList.less';

class MessagesList extends Component {
prepareColumnDescriptors = defaultMemoize((systemMessages, locale) => {
const columns = [
new SortableTableColumnDescriptor(
'text',
<FormattedMessage id="app.systemMessagesList.text" defaultMessage="Text" />,
{
className: 'text-left',
className: styles.textPreview,
comparator: ({ text: t1 }, { text: t2 }) =>
getLocalizedText(t1, locale).localeCompare(getLocalizedText(t2, locale), locale),
cellRenderer: text => text && <i>{getLocalizedText(text, locale)}</i>,
Expand Down Expand Up @@ -59,7 +62,7 @@ class MessagesList extends Component {
<FormattedMessage id="app.systemMessagesList.type" defaultMessage="Type" />,
{
comparator: ({ type: t1 }, { type: t2 }) => t1.localeCompare(t2, locale),
cellRenderer: type => type && <span>{type}</span>,
cellRenderer: type => type && <Alert bsStyle={type} className={styles.alertType} />,
}
),

Expand Down
13 changes: 13 additions & 0 deletions src/components/SystemMessages/MessagesList/MessagesList.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.alertType {
margin-bottom: 0px;
padding: 10px;
height: 10px;
width: 10px;
}

.textPreview {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 20vw;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const EditSystemMessageForm = ({
name="type"
component={SelectField}
options={[
{ key: 'success', name: 'Success' },
{ key: 'info', name: 'Info' },
{ key: 'warning', name: 'Warning' },
{ key: 'danger', name: 'Danger' },
Expand Down
1 change: 1 addition & 0 deletions src/pages/SystemMessages/SystemMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class SystemMessages extends Component {
<Button
bsSize="xs"
bsStyle="warning"
className="btn-flat"
onClick={() => {
this.setState({ isOpen: true, message: messageToForm(message) });
}}>
Expand Down

0 comments on commit 4f7d45e

Please sign in to comment.