Skip to content

Commit

Permalink
New Design (#283)
Browse files Browse the repository at this point in the history
* Update styles of message block

* Create LESS file

* Scroll down button

* Move person name into speech bubble

* Remove profile data in direct message

* Update conversation header style

* Fix conversation header

* Display time of conversation entry

* Display date badge between day conversations

* Update time position

* Limit users list

* Apply username colors

* Fix tests

* Show all messages on small screen

* Implement message entry user states "joined" and "left"

* Hide date on over conversation entry

* Remove useless column `message_entry:file_id`

* Update REST API docs

* Fix entry time position

* Fix space around entry state badge

* Update Message Count

* Updated Changelog

* Updated minimized notificaation js

* Changed Test to min version 1.12

* Update conversation panel header

* Use full width container on fluid themes

* Fix date and state badges visibility

* Fix date badge visibility after reply

* Update conversation panel header styles

* Improve user names limit in conversation header

* Update inbox styles

* Update inbox styles

* Update inbox styles

---------

Co-authored-by: Lucas Bartholemy <[email protected]>
  • Loading branch information
yurabakhtin and luke- authored Mar 13, 2023
1 parent 9a5917a commit f84e77e
Show file tree
Hide file tree
Showing 55 changed files with 3,578 additions and 1,942 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/php-test-v1.10.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/php-test-v1.12.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: PHP Codeception Tests - v1.12

on:
push:

jobs:
tests:
uses: humhub/actions/.github/workflows/module-tests-v1.12.yml@main
with:
module-id: mail
use-rest-module: true
14 changes: 10 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ module.exports = function (grunt) {
}
}
},
less: {
dev: {
files: {
'resources/css/humhub.mail.css': 'resources/css/humhub.mail.less'
}
}
},
cssmin: {
target: {
files: {
Expand All @@ -30,7 +37,7 @@ module.exports = function (grunt) {
},
watch: {
scripts: {
files: ['resources/js/*.js', 'resources/css/*.css'],
files: ['resources/js/*.js', 'resources/css/*.less'],
tasks: ['build'],
options: {
spawn: false,
Expand All @@ -39,12 +46,11 @@ module.exports = function (grunt) {
},
});

//grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');


grunt.registerTask('build', ['concat', 'uglify', 'cssmin']);
grunt.registerTask('build', ['concat', 'uglify', 'less', 'cssmin']);
};
8 changes: 6 additions & 2 deletions controllers/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ public function actionUpdate($id, $from = null)

$this->checkMessagePermissions($message);

return $this->renderAjaxContent(Messages::widget(['message' => $message, 'entries' => $message->getEntryUpdates($from)->all()]));
return $this->renderAjaxContent(Messages::widget([
'message' => $message,
'entries' => $message->getEntryUpdates($from)->all(),
'showDateBadge' => false
]));
}

public function actionLoadMore($id, $from)
Expand Down Expand Up @@ -133,7 +137,7 @@ public function actionReply($id)
if ($replyForm->load(Yii::$app->request->post()) && $replyForm->save()) {
return $this->asJson([
'success' => true,
'content' => ConversationEntry::widget(['entry' => $replyForm->reply])
'content' => ConversationEntry::widget(['entry' => $replyForm->reply, 'showDateBadge' => $replyForm->reply->isFirstToday()])
]);
}

Expand Down
4 changes: 3 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Changelog
=========

2.1.1 (Unreleased)
3.0.0-beta.1 (Unreleased)
-------------------------
- Fix #252: Fix wrong user guid in Live Notification
- Fix #251: Fix edit message
- Fix: Add markdown-render class to Markdown text for Translator module to work
- Fix #280: Update styles of message block
- Enh #274: Browser Tab Indicator on New Unread Message

2.1.0 (December 7, 2021)
-------------------------
Expand Down
945 changes: 435 additions & 510 deletions docs/swagger/mail.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/swagger/mail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,14 @@ definitions:
format: int64
readOnly: true
example: 1
file_id:
type: integer
format: int64
readOnly: true
example: null
content:
type: string
example: Sample message
type:
type: integer
format: int64
readOnly: true
example: 0
created_at:
type: string
format: datetime
Expand Down
2 changes: 1 addition & 1 deletion helpers/RestDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public static function getMessageEntry(MessageEntry $entry)
return [
'id' => $entry->id,
'user_id' => $entry->user_id,
'file_id' => $entry->file_id,
'content' => $entry->content,
'type' => $entry->type,
'created_at' => $entry->created_at,
'created_by' => $entry->created_by,
'updated_at' => $entry->updated_at,
Expand Down
34 changes: 34 additions & 0 deletions migrations/m230213_094842_add_entry_type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use humhub\components\Migration;
use humhub\modules\mail\models\AbstractMessageEntry;
use humhub\modules\mail\models\MessageEntry;

/**
* Class m230213_094842_add_state
*/
class m230213_094842_add_entry_type extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->safeAddColumn(AbstractMessageEntry::tableName(), 'type', $this->tinyInteger()
->defaultValue(MessageEntry::type())
->notNull()
->unsigned()
->after('content')
);
$this->alterColumn(AbstractMessageEntry::tableName(), 'content', $this->text()->null());
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->safeDropColumn(AbstractMessageEntry::tableName(), 'type');
$this->alterColumn(AbstractMessageEntry::tableName(), 'content', $this->text()->notNull());
}
}
29 changes: 29 additions & 0 deletions migrations/m230214_062338_drop_file_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use humhub\components\Migration;
use humhub\modules\mail\models\MessageEntry;


/**
* Class m230214_062338_drop_file_id
*/
class m230214_062338_drop_file_id extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->safeDropColumn(MessageEntry::tableName(), 'file_id');
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
echo "m230214_062338_drop_file_id cannot be reverted.\n";

return false;
}
}
168 changes: 168 additions & 0 deletions models/AbstractMessageEntry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2023 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\mail\models;

use humhub\components\ActiveRecord;
use humhub\modules\content\widgets\richtext\RichText;
use humhub\modules\mail\live\UserMessageDeleted;
use humhub\modules\user\models\User;
use Yii;
use yii\db\ActiveQuery;

/**
* This class represents abstract class for normal message and state entries within a conversation.
*
* The followings are the available columns in table 'message_entry':
* @property integer $id
* @property integer $message_id
* @property integer $user_id
* @property string $content
* @property integer $type
* @property string $created_at
* @property integer $created_by
* @property string $updated_at
* @property integer $updated_by
*
* The followings are the available model relations:
* @property Message $message
* @property User $user
*
* @package humhub.modules.mail.models
* @since 2.1
*/
abstract class AbstractMessageEntry extends ActiveRecord
{
const TYPE_MESSAGE = 0;
const TYPE_USER_JOINED = 1;
const TYPE_USER_LEFT = 2;

protected bool $requiredContent = true;

/**
* Get type of the message entry
*
* @return int
*/
abstract public static function type(): int;

/**
* Check if the given or current User can edit the message entry
*
* @param User|null $user
* @return bool
*/
abstract public function canEdit(?User $user = null): bool;

/**
* Notify Users about this message entry
*
* @var bool $isNewConversation
*/
abstract public function notify(bool $isNewConversation = false);

/**
* @inheritdoc
*/
public static function tableName()
{
return 'message_entry';
}

/**
* @inheritdoc
*/
public function rules()
{
$requiredColumns = ['message_id', 'user_id'];

if ($this->requiredContent) {
$requiredColumns[] = 'content';
}

return [
[$requiredColumns, 'required'],
[['message_id', 'user_id', 'created_by', 'updated_by'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
];
}

/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->type = $this->type();
}

/**
* @param Message $message
* @param User $user
* @param string|null $content
* @return self
*/
public static function createForMessage(Message $message, User $user, ?string $content = null): self
{
// Attach Message Entry
return new static([
'message_id' => $message->id,
'user_id' => $user->id,
'content' => $content,
'type' => static::type(),
]);
}

/**
* @inheritdoc
*/
public function beforeSave($insert)
{
if ($this->isNewRecord) {
// Updates the updated_at attribute
$this->message->save();
}

return parent::beforeSave($insert);
}

/**
* @inheritdoc
*/
public function afterSave($insert, $changedAttributes)
{
RichText::postProcess($this->content, $this);
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
}

/**
* @inheritdoc
*/
public function afterDelete()
{
foreach ($this->message->users as $user) {
Yii::$app->live->send(new UserMessageDeleted([
'contentContainerId' => $user->contentcontainer_id,
'message_id' => $this->message_id,
'entry_id' => $this->id,
'user_id' => $user->id
]));
}

parent::afterDelete();
}

public function getUser(): ActiveQuery
{
return $this->hasOne(User::class, ['id' => 'user_id']);
}

public function getMessage(): ActiveQuery
{
return $this->hasOne(Message::class, ['id' => 'message_id']);
}
}
Loading

0 comments on commit f84e77e

Please sign in to comment.