Commit cad21117 authored by Sean McGivern's avatar Sean McGivern

Improve request selector warning display

Show `(!)` as the warning glyph in the dropdown, rather than an
emoji. Add a popover to show the number of requests with warnings to the
warning emoji deside the selector.
parent a3651c02
<script> <script>
import { glEmojiTag } from '~/emoji'; import { glEmojiTag } from '~/emoji';
import { n__ } from '~/locale';
import { GlPopover } from '@gitlab/ui';
export default { export default {
components: {
GlPopover,
},
props: { props: {
currentRequest: { currentRequest: {
type: Object, type: Object,
...@@ -18,8 +23,15 @@ export default { ...@@ -18,8 +23,15 @@ export default {
}; };
}, },
computed: { computed: {
anyRequestsWithWarnings() { requestsWithWarnings() {
return this.requests.some(request => request.hasWarnings); return this.requests.filter(request => request.hasWarnings);
},
warningMessage() {
return n__(
'%d request with warnings',
'%d requests with warnings',
this.requestsWithWarnings.length,
);
}, },
}, },
watch: { watch: {
...@@ -52,9 +64,16 @@ export default { ...@@ -52,9 +64,16 @@ export default {
class="qa-performance-bar-request" class="qa-performance-bar-request"
> >
{{ truncatedUrl(request.url) }} {{ truncatedUrl(request.url) }}
<span v-if="request.hasWarnings" v-html="glEmojiTag('warning')"></span> <span v-if="request.hasWarnings">(!)</span>
</option> </option>
</select> </select>
<span v-if="anyRequestsWithWarnings" v-html="glEmojiTag('warning')"></span> <span v-if="requestsWithWarnings.length">
<span id="performance-bar-request-selector-warning" v-html="glEmojiTag('warning')"></span>
<gl-popover
target="performance-bar-request-selector-warning"
:content="warningMessage"
triggers="hover focus"
/>
</span>
</div> </div>
</template> </template>
...@@ -150,6 +150,11 @@ msgid_plural "%d more comments" ...@@ -150,6 +150,11 @@ msgid_plural "%d more comments"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
msgid "%d request with warnings"
msgid_plural "%d requests with warnings"
msgstr[0] ""
msgstr[1] ""
msgid "%d second" msgid "%d second"
msgid_plural "%d seconds" msgid_plural "%d seconds"
msgstr[0] "" msgstr[0] ""
......
...@@ -55,10 +55,10 @@ describe('request selector', () => { ...@@ -55,10 +55,10 @@ describe('request selector', () => {
expect(wrapper.find('span > gl-emoji').element.dataset.name).toEqual('warning'); expect(wrapper.find('span > gl-emoji').element.dataset.name).toEqual('warning');
}); });
it('adds a warning icon to requests with warnings', () => { it('adds a warning glyph to requests with warnings', () => {
const option = wrapper.find('[value="abc"]'); const requestValue = wrapper.find('[value="abc"]').text();
expect(option.find('gl-emoji').element.dataset.name).toEqual('warning'); expect(requestValue).toContain('discussions.json');
expect(option.text()).toContain('discussions.json'); expect(requestValue).toContain('(!)');
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment