Skip to content

Commit

Permalink
created chat component
Browse files Browse the repository at this point in the history
  • Loading branch information
doljko committed Apr 2, 2024
1 parent 813241f commit 0b1bf60
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addon/components/chat-container.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="absolute">
<a>Chat</a>
{{#each this.chatChannels as |chatChannel|}}
<ChatWindow @channel={{chatChannel}} />
{{/each}}
</div>
6 changes: 6 additions & 0 deletions addon/components/chat-container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class ChatContainerComponent extends Component {
@tracked chatChannels = []
}
16 changes: 16 additions & 0 deletions addon/components/chat-window.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="click-to-copy" {{on "click" (fn this.copyToClipboard @value)}} ...attributes>
<span class="click-to-copy--value">
{{#if (has-block)}}
{{yield}}
{{else}}
{{n-a @value}}
{{/if}}
</span>
<span class="click-to-copy--tooltip">
{{#if this.isCopied}}
Copied!
{{else}}
Click to copy
{{/if}}
</span>
</div>
18 changes: 18 additions & 0 deletions addon/components/chat-window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Component from '@glimmer/component';

export class ChatWindowComponent extends Component {
@service socket;
@service chat;
@tracked channel;
constructor(owner, { chatChannel }) {
super(...arguments);
this.channel = chatChannel;
this.listen();
}

listen() {
this.socket.listen(`chat.${this.channel.public_id}`, (event) => {
console.log('[chat event]', event);
});
}
}
1 change: 1 addition & 0 deletions app/components/chat-container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@fleetbase/ember-ui/components/chat-container';
1 change: 1 addition & 0 deletions app/components/chat-window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@fleetbase/ember-ui/components/chat-window';
26 changes: 26 additions & 0 deletions tests/integration/components/chat-container-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'dummy/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | chat-container', function (hooks) {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`<ChatContainer />`);

assert.dom().hasText('');

// Template block usage:
await render(hbs`
<ChatContainer>
template block text
</ChatContainer>
`);

assert.dom().hasText('template block text');
});
});
26 changes: 26 additions & 0 deletions tests/integration/components/chat-window-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'dummy/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | chat-window', function (hooks) {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`<ChatWindow />`);

assert.dom().hasText('');

// Template block usage:
await render(hbs`
<ChatWindow>
template block text
</ChatWindow>
`);

assert.dom().hasText('template block text');
});
});

0 comments on commit 0b1bf60

Please sign in to comment.