Skip to content

Commit a8babfe

Browse files
authored
Merge pull request #902 from ExtensionEngine/feature/update-publishing-component
Update publishing component labeling, tooltip and badge
2 parents c980bbd + d0443cb commit a8babfe

File tree

3 files changed

+74
-94
lines changed

3 files changed

+74
-94
lines changed

client/components/repository/Workflow/Overview/index.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
<template #item.name="{ item, value }">
1111
<div class="d-flex">
1212
<overview-name :value="value" />
13-
<publishing-badge v-if="isAdmin || isRepositoryAdmin" :activity="item" />
13+
<publishing
14+
v-if="isAdmin || isRepositoryAdmin"
15+
:activity="item"
16+
:outline-activities="outlineActivities"
17+
hide-publish
18+
hide-details />
1419
</div>
1520
</template>
1621
<template #item.status="{ value }">
@@ -36,7 +41,7 @@ import OverviewDueDate from './DueDate';
3641
import OverviewName from './Name';
3742
import OverviewPriority from './Priority';
3843
import OverviewStatus from './Status';
39-
import PublishingBadge from '@/components/repository/common/Sidebar/Badge';
44+
import Publishing from '@/components/repository/common/Sidebar/Publishing';
4045
import selectActivity from '@/components/repository/common/selectActivity';
4146
4247
export default {
@@ -47,7 +52,7 @@ export default {
4752
},
4853
computed: {
4954
...mapGetters(['isAdmin']),
50-
...mapGetters('repository', ['isRepositoryAdmin', 'workflow']),
55+
...mapGetters('repository', ['isRepositoryAdmin', 'workflow', 'outlineActivities']),
5156
headers() {
5257
return [{
5358
text: 'Name',
@@ -105,7 +110,7 @@ export default {
105110
}
106111
},
107112
components: {
108-
PublishingBadge,
113+
Publishing,
109114
OverviewAssignee,
110115
OverviewDueDate,
111116
OverviewName,

client/components/repository/common/Sidebar/Badge.vue

Lines changed: 0 additions & 73 deletions
This file was deleted.

client/components/repository/common/Sidebar/Publishing.vue

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,49 @@
2222
</v-list-item>
2323
</v-list>
2424
</v-menu>
25-
<div class="publish-status">
26-
<publishing-badge :activity="activity" />
27-
<span class="pl-1">
28-
{{ isPublishing ? publishStatus.message : publishedAtMessage }}
29-
</span>
25+
<div :class="{ 'mt-4': !hideDetails }" class="d-flex align-center">
26+
<v-tooltip open-delay="100" max-width="300" left>
27+
<template v-slot:activator="{ on }">
28+
<span v-on="on">
29+
<v-badge :color="badgeColor" inline dot />
30+
<span v-if="!hideDetails" class="ml-1">
31+
{{ isPublishing ? publishStatus.message : publishDetails }}
32+
</span>
33+
</span>
34+
</template>
35+
<span class="pl-1">
36+
{{ publishedAtMessage }}
37+
</span>
38+
</v-tooltip>
3039
</div>
3140
</span>
3241
</template>
3342

3443
<script>
44+
import { getDescendants, getLabel, isChanged } from '@/utils/activity';
45+
import countBy from 'lodash/countBy';
3546
import fecha from 'fecha';
36-
import { getDescendants } from 'utils/activity';
47+
import filter from 'lodash/filter';
3748
import { getLevel } from 'shared/activities';
49+
import map from 'lodash/map';
3850
import { mapActions } from 'vuex';
39-
import PublishingBadge from './Badge';
51+
import pluralize from 'pluralize';
4052
import publishMixin from 'components/common/mixins/publish';
4153
54+
const getDescriptor = (count, type) => `${count} ${pluralize(type, count)}`;
55+
const arrayToSentence = arr => arr.join(', ').replace(/, ([^,]*)$/, ' and $1');
56+
const getActivityInfo = hasChanges => hasChanges ? 'Has unpublished changes' : 'Published';
57+
const getDescendantsInfo = (descendants, count, label) => {
58+
return `${descendants} within this ${label} ${pluralize('has', count)}
59+
unpublished changes.`;
60+
};
61+
4262
export default {
4363
mixins: [publishMixin],
4464
props: {
4565
activity: { type: Object, required: true },
4666
outlineActivities: { type: Array, required: true },
67+
hideDetails: { type: Boolean, default: false },
4768
hidePublish: { type: Boolean, default: false }
4869
},
4970
computed: {
@@ -54,19 +75,46 @@ export default {
5475
? `Published on ${fecha.format(new Date(publishedAt), 'M/D/YY h:mm A')}`
5576
: 'Not published';
5677
},
78+
publishDetails() {
79+
const {
80+
activity: { publishedAt },
81+
activityInfo,
82+
descendantsInfo,
83+
subtreeHasChanges
84+
} = this;
85+
86+
if (!publishedAt) return 'Not published';
87+
if (subtreeHasChanges) return descendantsInfo;
88+
return activityInfo;
89+
},
5790
activityWithDescendants({ outlineActivities, activity } = this) {
5891
return [...getDescendants(outlineActivities, activity), activity];
92+
},
93+
label() {
94+
return getLabel(this.activity);
95+
},
96+
hasChanges() {
97+
return isChanged(this.activity);
98+
},
99+
changedDescendants() {
100+
return filter(getDescendants(this.outlineActivities, this.activity), isChanged);
101+
},
102+
subtreeHasChanges() {
103+
return !!this.changedDescendants.length;
104+
},
105+
activityInfo() {
106+
return getActivityInfo(this.hasChanges);
107+
},
108+
descendantsInfo() {
109+
const { changedDescendants, label } = this;
110+
const labelCountMap = countBy(changedDescendants, getLabel);
111+
const descendants = arrayToSentence(map(labelCountMap, getDescriptor));
112+
return getDescendantsInfo(descendants, changedDescendants.length, label);
113+
},
114+
badgeColor() {
115+
return this.hasChanges || this.subtreeHasChanges ? 'orange' : 'green';
59116
}
60117
},
61-
methods: mapActions('repository/activities', { publishActivity: 'publish' }),
62-
components: { PublishingBadge }
118+
methods: mapActions('repository/activities', { publishActivity: 'publish' })
63119
};
64120
</script>
65-
66-
<style lang="scss" scoped>
67-
.publish-status {
68-
display: flex;
69-
align-items: center;
70-
padding: 1.125rem 0.375rem 0 0.25rem;
71-
}
72-
</style>

0 commit comments

Comments
 (0)