@webitel/ui-sdk 3.2.125 → 3.2.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +2 -1
- package/src/components/on-demand/wt-cc-agent-status-timers/__tests__/wt-cc-agent-status-timers.spec.js +25 -0
- package/src/components/on-demand/wt-cc-agent-status-timers/wt-cc-agent-status-timers.vue +56 -0
- package/src/composables/useRepresentableAgentPauseCause/__tests__/useRepresentableAgentPauseCause.spec.js +78 -0
- package/src/composables/useRepresentableAgentPauseCause/useRepresentableAgentPauseCause.js +36 -0
- package/src/locale/en/en.js +7 -0
- package/src/locale/ru/ru.js +7 -0
- package/src/locale/ua/ua.js +7 -0
- package/src/locale/.DS_Store +0 -0
- /package/src/{scripts/validators → validators}/domainValidator.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-sdk",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.126",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve-lib": "vue-cli-service serve",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"src/enums/*",
|
|
25
25
|
"src/mixins/*",
|
|
26
26
|
"src/scripts/*",
|
|
27
|
+
"src/validators/*",
|
|
27
28
|
"src/modules/*",
|
|
28
29
|
"src/plugins/*",
|
|
29
30
|
"src/store/*",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import WtCcAgentStatusTimers from '../wt-cc-agent-status-timers.vue';
|
|
3
|
+
|
|
4
|
+
describe('Wt Cc Agent Status Timers', () => {
|
|
5
|
+
it('renders a component', () => {
|
|
6
|
+
const wrapper = shallowMount(WtCcAgentStatusTimers, {
|
|
7
|
+
props: {
|
|
8
|
+
status: {
|
|
9
|
+
online: 123,
|
|
10
|
+
pause: 123,
|
|
11
|
+
offline: 123,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
expect(wrapper.exists())
|
|
16
|
+
.toBe(true);
|
|
17
|
+
});
|
|
18
|
+
it('renders component with empty status prop', () => {
|
|
19
|
+
const wrapper = shallowMount(WtCcAgentStatusTimers, {
|
|
20
|
+
props: { status: {} },
|
|
21
|
+
});
|
|
22
|
+
expect(wrapper.exists())
|
|
23
|
+
.toBe(true);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<article class="wt-cc-agent-status-timers">
|
|
3
|
+
<wt-indicator
|
|
4
|
+
color="disabled"
|
|
5
|
+
:text="status.offline"
|
|
6
|
+
:size="size"
|
|
7
|
+
></wt-indicator>
|
|
8
|
+
<wt-indicator
|
|
9
|
+
color="success"
|
|
10
|
+
:text="status.online"
|
|
11
|
+
:size="size"
|
|
12
|
+
></wt-indicator>
|
|
13
|
+
<wt-indicator
|
|
14
|
+
color="primary"
|
|
15
|
+
:text="pause"
|
|
16
|
+
:size="size"
|
|
17
|
+
></wt-indicator>
|
|
18
|
+
</article>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup>
|
|
22
|
+
import { computed } from 'vue';
|
|
23
|
+
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
/**
|
|
26
|
+
* @description Status object
|
|
27
|
+
* @type {Object}
|
|
28
|
+
* @property {Number} offline
|
|
29
|
+
* @property {Number} online
|
|
30
|
+
* @property {Number} pause
|
|
31
|
+
* @property {Number} allowPause
|
|
32
|
+
*/
|
|
33
|
+
status: {
|
|
34
|
+
type: Object,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: 'md',
|
|
40
|
+
options: ['sm', 'md'],
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const pause = computed(() => {
|
|
45
|
+
if (!props.status.allowPause) return props.status.pause;
|
|
46
|
+
return `${props.status.pause} / ${props.status.allowPause}`;
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style lang="scss" scoped>
|
|
51
|
+
.wt-cc-agent-status-timers {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: var(--spacing-sm);
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useRepresentableAgentPauseCause,
|
|
3
|
+
} from '../useRepresentableAgentPauseCause';
|
|
4
|
+
|
|
5
|
+
let pauseCauses = [];
|
|
6
|
+
|
|
7
|
+
describe('useRepresentableAgentPauseCause', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
pauseCauses = [{ durationMin: 10, limitMin: 12 }];
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('correctly computes duration', () => {
|
|
13
|
+
const {
|
|
14
|
+
representablePauseCause,
|
|
15
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
16
|
+
expect(representablePauseCause.value[0].duration).toBe('00:10');
|
|
17
|
+
});
|
|
18
|
+
it('isOverflow with limit = 0 returns false', () => {
|
|
19
|
+
const pauseCauses = [{ durationMin: 10, limitMin: 0 }];
|
|
20
|
+
const {
|
|
21
|
+
representablePauseCause,
|
|
22
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
23
|
+
expect(representablePauseCause.value[0].isOverflow).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
it('isOverflow with duration < limit returns false', () => {
|
|
26
|
+
const pauseCauses = [{ durationMin: 10, limitMin: 15 }];
|
|
27
|
+
const {
|
|
28
|
+
representablePauseCause,
|
|
29
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
30
|
+
expect(representablePauseCause.value[0].isOverflow).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
it('isOverflow with duration > limit returns true', () => {
|
|
33
|
+
const pauseCauses = [{ durationMin: 15, limitMin: 10 }];
|
|
34
|
+
const {
|
|
35
|
+
representablePauseCause,
|
|
36
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
37
|
+
expect(representablePauseCause.value[0].isOverflow).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('isOverflow with duration = limit returns false', () => {
|
|
41
|
+
const pauseCauses = [{ durationMin: 10, limitMin: 10 }];
|
|
42
|
+
const {
|
|
43
|
+
representablePauseCause,
|
|
44
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
45
|
+
expect(representablePauseCause.value[0].isOverflow).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('correctly computes progressColor', () => {
|
|
49
|
+
const {
|
|
50
|
+
representablePauseCause,
|
|
51
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
52
|
+
expect(representablePauseCause.value[0].progressColor).toBe('primary');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('correctly computes progressColor with duration > limit', () => {
|
|
56
|
+
const pauseCauses = [{ durationMin: 15, limitMin: 10 }];
|
|
57
|
+
const {
|
|
58
|
+
representablePauseCause,
|
|
59
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
60
|
+
expect(representablePauseCause.value[0].progressColor).toBe('danger');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('correctly computes progressColor with duration < limit', () => {
|
|
64
|
+
const pauseCauses = [{ durationMin: 10, limitMin: 15 }];
|
|
65
|
+
const {
|
|
66
|
+
representablePauseCause,
|
|
67
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
68
|
+
expect(representablePauseCause.value[0].progressColor).toBe('success');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('correctly computes progressColor with duration = limit', () => {
|
|
72
|
+
const pauseCauses = [{ durationMin: 10, limitMin: 10 }];
|
|
73
|
+
const {
|
|
74
|
+
representablePauseCause,
|
|
75
|
+
} = useRepresentableAgentPauseCause(pauseCauses);
|
|
76
|
+
expect(representablePauseCause.value[0].progressColor).toBe('primary');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import convertDuration from '../../scripts/convertDuration';
|
|
3
|
+
|
|
4
|
+
const prettifyPauseCauseDuration = (min) => {
|
|
5
|
+
const SEC_IN_MIN = 60;
|
|
6
|
+
const secDuration = convertDuration(min * SEC_IN_MIN);
|
|
7
|
+
return secDuration.slice(0, -3);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const isDurationOverflow = ({ durationMin, limitMin }) => {
|
|
11
|
+
return (durationMin > limitMin) && limitMin !== 0;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const duration = ({ durationMin, limitMin }) => {
|
|
15
|
+
return isDurationOverflow({ durationMin, limitMin })
|
|
16
|
+
? `-${prettifyPauseCauseDuration(durationMin - limitMin)}`
|
|
17
|
+
: prettifyPauseCauseDuration(durationMin);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const pauseCauseProgressColor = ({ durationMin, limitMin }) => {
|
|
21
|
+
if (isDurationOverflow({ durationMin, limitMin })) return 'danger';
|
|
22
|
+
if (durationMin <= (limitMin * 0.75)) return 'success';
|
|
23
|
+
return 'primary';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
27
|
+
export const useRepresentableAgentPauseCause = (pauseCauses) => {
|
|
28
|
+
const representablePauseCause = computed(() => pauseCauses.map((pauseCause) => ({
|
|
29
|
+
...pauseCause,
|
|
30
|
+
duration: duration(pauseCause),
|
|
31
|
+
progressColor: pauseCauseProgressColor(pauseCause),
|
|
32
|
+
isOverflow: isDurationOverflow(pauseCause),
|
|
33
|
+
})));
|
|
34
|
+
|
|
35
|
+
return { representablePauseCause };
|
|
36
|
+
};
|
package/src/locale/en/en.js
CHANGED
package/src/locale/ru/ru.js
CHANGED
package/src/locale/ua/ua.js
CHANGED
package/src/locale/.DS_Store
DELETED
|
Binary file
|
|
File without changes
|