• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

super3 / nilo.chat / 14179070520

31 Mar 2025 06:49PM UTC coverage: 95.652%. Remained the same
14179070520

push

github

super3
Update DirectMessageSidebar.vue

Make it more readable

124 of 130 branches covered (95.38%)

Branch coverage included in aggregate %.

206 of 215 relevant lines covered (95.81%)

6.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.64
/src/components/DirectMessageSidebar.vue
1
<template>
2
  <div class="bg-indigo-darker text-purple-lighter flex-none w-64 pb-6 hidden md:block">
3
    <div class="text-white mb-2 mt-3 px-4 flex justify-between">
4
      <div class="flex-auto">
1✔
5
        <h1 class="font-semibold text-xl leading-tight mb-1 truncate">nilo.chat</h1>
6
        <div class="flex items-center mb-6">
7
          <span :class="[isConnected ? 'bg-green-500' : 'border border-white', 'rounded-full block w-2 h-2 mr-2']"></span>
1✔
8
          <span class="text-white/50 text-sm">{{ username }}</span>
1✔
9
        </div>
10
      </div>
11
    </div>
12
    
13
    <!-- Channels section -->
14
    <div class="mb-8">
15
      <div class="px-4 mb-1 text-white flex items-center">
16
        <div @click="toggleChannels" class="cursor-pointer w-4 mr-2 flex justify-center">
17
          <svg v-if="showChannels" class="fill-current h-4 w-4 opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
18
            <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/>
19
          </svg>
20
          <svg v-else class="fill-current h-4 w-4 opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
21
            <path d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"/>
22
          </svg>
23
        </div>
24
        <div @click="toggleChannels" class="opacity-75 flex-1 cursor-pointer">Channels</div>
25
        <div>
26
          <svg class="fill-current h-4 w-4 opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
27
            <path d="M11 9h4v2h-4v4H9v-4H5V9h4V5h2v4zm-1 11a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16z" />
28
          </svg>
29
        </div>
23✔
30
      </div>
31
      <!-- Show all channels when showChannels is true -->
32
      <div v-if="showChannels">
33
        <div 
34
          @click="switchChannel('general')" 
35
          class="px-4 py-1 text-white flex items-center cursor-pointer hover:bg-teal-darker"
36
          :class="{ 'bg-teal-dark': currentChannel === 'general' }"
4✔
37
        >
38
          <div class="w-4 mr-2 text-center">#</div>
39
          <span>general</span>
4✔
40
        </div>
41
        <div 
42
          @click="switchChannel('feedback')" 
7✔
43
          class="px-4 py-1 text-white flex items-center cursor-pointer hover:bg-teal-darker"
6✔
44
          :class="{ 'bg-teal-dark': currentChannel === 'feedback' }"
45
        >
46
          <div class="w-4 mr-2 text-center">#</div>
47
          <span>feedback</span>
48
        </div>
1✔
49
      </div>
50
      <!-- Show only selected channel when showChannels is false -->
1✔
51
      <div v-else>
52
        <div 
53
          v-if="currentChannel === 'general'"
1✔
54
          @click="switchChannel('general')" 
1✔
55
          class="px-4 py-1 text-white flex items-center cursor-pointer hover:bg-teal-darker bg-teal-dark"
1✔
56
        >
57
          <div class="w-4 mr-2 text-center">#</div>
58
          <span>general</span>
1✔
59
        </div>
60
        <div 
61
          v-if="currentChannel === 'feedback'"
1✔
62
          @click="switchChannel('feedback')" 
63
          class="px-4 py-1 text-white flex items-center cursor-pointer hover:bg-teal-darker bg-teal-dark"
64
        >
1✔
65
          <div class="w-4 mr-2 text-center">#</div>
66
          <span>feedback</span>
67
        </div>
1✔
68
      </div>
69
    </div>
70
    
1✔
71
    <!-- Direct Messages section -->
72
    <div class="mb-8">
73
      <div class="px-4 mb-1 text-white flex items-center">
1✔
74
        <div @click="toggleDirectMessages" class="cursor-pointer w-4 mr-2 flex justify-center">
75
          <svg v-if="showDirectMessages" class="fill-current h-4 w-4 opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
76
            <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/>
1✔
77
          </svg>
78
          <svg v-else class="fill-current h-4 w-4 opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
79
            <path d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"/>
80
          </svg>
81
        </div>
82
        <div @click="toggleDirectMessages" class="opacity-75 flex-1 cursor-pointer">Direct Messages</div>
1✔
83
        <div>
84
          <svg class="fill-current h-4 w-4 opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
85
            <path d="M11 9h4v2h-4v4H9v-4H5V9h4V5h2v4zm-1 11a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16z" />
86
          </svg>
87
        </div>
88
      </div>
1✔
89
      <!-- Show all DMs when expanded -->
90
      <div v-if="showDirectMessages">
91
        <div class="px-4 py-1 flex items-center cursor-pointer hover:bg-teal-darker"
1✔
92
             :class="{ 'bg-teal-dark': currentChannel === 'dm_self' }"
93
             @click="switchChannel('dm_self')"
94
             data-testid="dm-self">
1✔
95
          <div class="w-4 mr-2 flex justify-center">
96
            <span :class="[isConnected ? 'bg-green-500' : 'border border-white', 'rounded-full block w-2 h-2']"></span>
97
          </div>
1✔
98
          <span class="text-white opacity-75">{{ username }} 
99
            <span :class="[currentChannel === 'dm_self' ? 'text-white text-opacity-80' : 'text-gray-500', 'text-sm']">(you)</span>
100
          </span>
101
        </div>
102
        <div class="px-4 py-1 flex items-center cursor-pointer hover:bg-teal-darker" 
103
             :class="{ 'bg-teal-dark': currentChannel === 'dm_steve' }"
1✔
104
             @click="switchChannel('dm_steve')"
105
             data-testid="dm-steve">
106
          <div class="w-4 mr-2 flex justify-center">
107
            <span class="bg-green-500 rounded-full block w-2 h-2"></span>
108
          </div>
109
          <span class="text-white opacity-75">steve</span>
1✔
110
          <div v-if="steveUnreadCount > 0" class="ml-auto">
111
            <span class="bg-red-500 text-white text-xs rounded-full py-1 px-2 font-semibold">
112
              {{ steveUnreadCount }}
1✔
113
            </span>
114
          </div>
115
        </div>
1✔
116
      </div>
117
      <!-- Since DMs don't have a 'selected' concept, we won't show any when collapsed -->
118
    </div>
1✔
119
  </div>
120
</template>
121

122
<script>
1✔
123
export default {
124
  name: 'DirectMessageSidebar',
125
  props: {
126
    username: {
42✔
127
      type: String,
128
      required: true
129
    },
42✔
130
    isConnected: {
131
      type: Boolean,
1✔
132
      default: false
133
    },
100✔
134
    currentChannel: {
135
      type: String,
12✔
136
      default: 'general'
137
    },
138
    steveUnreadCount: {
1✔
139
      type: Number,
140
      default: 0
65✔
141
    }
142
  },
143
  data() {
144
    return {
145
      showChannels: true,
146
      showDirectMessages: true
42✔
147
    }
✔
148
  },
149
  methods: {
150
    toggleChannels() {
151
      this.showChannels = !this.showChannels;
58✔
152
    },
153
    toggleDirectMessages() {
154
      this.showDirectMessages = !this.showDirectMessages;
1✔
155
    },
156
    switchChannel(channel) {
157
      if (channel !== this.currentChannel) {
158
        this.$emit('channel-change', channel);
58✔
159
      }
160
    }
161
  }
162
}
7✔
163
</script> 
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc