Skip to content

Commit

Permalink
Chat: Hide title prop and prevent Header rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
marker dao ® committed Aug 29, 2024
1 parent f40e5f9 commit 3e7656c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 29 deletions.
21 changes: 0 additions & 21 deletions packages/devextreme-angular/src/ui/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,6 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
}


/**
* [descr:dxChatOptions.title]
*/
@Input()
get title(): string {
return this._getOption('title');
}
set title(value: string) {
this._setOption('title', value);
}


/**
* [descr:dxChatOptions.user]
Expand Down Expand Up @@ -345,13 +332,6 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
*/
@Output() rtlEnabledChange: EventEmitter<boolean>;

/**
* This member supports the internal infrastructure and is not intended to be used directly from your code.
*/
@Output() titleChange: EventEmitter<string>;

/**
* This member supports the internal infrastructure and is not intended to be used directly from your code.
Expand Down Expand Up @@ -411,7 +391,6 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
{ emit: 'hoverStateEnabledChange' },
{ emit: 'itemsChange' },
{ emit: 'rtlEnabledChange' },
{ emit: 'titleChange' },
{ emit: 'userChange' },
{ emit: 'visibleChange' },
{ emit: 'widthChange' }
Expand Down
3 changes: 0 additions & 3 deletions packages/devextreme-vue/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type AccessibleOptions = Pick<Properties,
"onMessageSend" |
"onOptionChanged" |
"rtlEnabled" |
"title" |
"user" |
"visible" |
"width"
Expand All @@ -42,7 +41,6 @@ const DxChat = createComponent({
onMessageSend: Function,
onOptionChanged: Function,
rtlEnabled: Boolean,
title: String,
user: Object,
visible: Boolean,
width: [Function, Number, String]
Expand All @@ -64,7 +62,6 @@ const DxChat = createComponent({
"update:onMessageSend": null,
"update:onOptionChanged": null,
"update:rtlEnabled": null,
"update:title": null,
"update:user": null,
"update:visible": null,
"update:width": null,
Expand Down
7 changes: 6 additions & 1 deletion packages/devextreme/js/__internal/ui/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type {
import MessageBox from './chat_message_box';
import MessageList from './chat_message_list';

export const shouldHeaderBeRendered = false;

const CHAT_CLASS = 'dx-chat';
const TEXTEDITOR_INPUT_CLASS = 'dx-texteditor-input';

Expand Down Expand Up @@ -46,7 +48,10 @@ class Chat extends Widget<Properties> {

super._initMarkup();

this._renderHeader();
if (shouldHeaderBeRendered) {
this._renderHeader();
}

this._renderMessageList();
this._renderMessageBox();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/ui/chat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface dxChatOptions extends WidgetOptions<dxChat> {
/**
* @docid
* @default ''
* @public
* @hidden
*/
title?: string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import $ from 'jquery';

import Chat from 'ui/chat';

import { shouldHeaderBeRendered } from '__internal/ui/chat/chat';

const CHAT_CLASS = 'dx-chat';
const CHAT_HEADER_CLASS = 'dx-chat-header';
const CHAT_MESSAGE_BOX_CLASS = 'dx-chat-message-box';
Expand Down Expand Up @@ -29,7 +31,9 @@ const moduleConfig = {

QUnit.module('Chat', moduleConfig, () => {
QUnit.module('Render', () => {
QUnit.test('Header should be rendered', function(assert) {
const method = shouldHeaderBeRendered ? 'test' : 'skip';

QUnit[method]('Header should be rendered', function(assert) {
const $header = this.$element.find(`.${CHAT_HEADER_CLASS}`);

assert.strictEqual($header.length, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import Chat from 'ui/chat';
import MessageList from '__internal/ui/chat/chat_message_list';
import MessageBox from '__internal/ui/chat/chat_message_box';
import keyboardMock from '../../../helpers/keyboardMock.js';

import { shouldHeaderBeRendered } from '__internal/ui/chat/chat';
import { isRenderer } from 'core/utils/type';

import config from 'core/config';

const CHAT_HEADER_TEXT_CLASS = 'dx-chat-header-text';
Expand Down Expand Up @@ -93,7 +96,9 @@ QUnit.module('Chat', moduleConfig, () => {
});

QUnit.module('Header integration', () => {
QUnit.test('Header text element should have correct text', function(assert) {
const method = shouldHeaderBeRendered ? 'test' : 'skip';

QUnit[method]('Header text element should have correct text', function(assert) {
this.reinit({
title: MOCK_CHAT_HEADER_TEXT
});
Expand All @@ -103,7 +108,7 @@ QUnit.module('Chat', moduleConfig, () => {
assert.strictEqual($header.text(), MOCK_CHAT_HEADER_TEXT);
});

QUnit.test('Header text element should have correct text after runtime change', function(assert) {
QUnit[method]('Header text element should have correct text after runtime change', function(assert) {
this.instance.option({ title: 'new title' });

const $header = this.$element.find(`.${CHAT_HEADER_TEXT_CLASS}`);
Expand Down

0 comments on commit 3e7656c

Please sign in to comment.