Skip to content

Commit d0ffdc3

Browse files
Merge pull request #11 from exadel-inc/develop
Release preparation 1.2.0
2 parents e320f1e + 19b5797 commit d0ffdc3

File tree

16 files changed

+158
-21
lines changed

16 files changed

+158
-21
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ The button allows to select or unselect all target paths. The button label is ch
9696

9797
![unselect-all](_img/unselect-all.png)
9898

99-
#### New label
100-
The _new_ label is shown if a selected page doesn't exist under a target path and will be created during a rollout process.
99+
#### Not Rolled Out label
100+
The _Not Rolled Out_ label is shown if a selected page doesn't exist under a target path and will be created during a rollout process.
101101

102-
![new-label](_img/new-label.png)
102+
![new-label](_img/not-rolled-out-label.png)
103103

104104
#### Selection validation
105105
The _Rollout_ button is disabled if no target paths are selected.

_img/new-label.png

-34.2 KB
Binary file not shown.

_img/not-rolled-out-label.png

45.1 KB
Loading

all/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>com.exadel.etoolbox</groupId>
2424
<artifactId>etoolbox-rollout-manager</artifactId>
25-
<version>1.1</version>
25+
<version>1.2.0</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828

core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<groupId>com.exadel.etoolbox</groupId>
2020
<artifactId>etoolbox-rollout-manager</artifactId>
21-
<version>1.1</version>
21+
<version>1.2.0</version>
2222
<relativePath>../pom.xml</relativePath>
2323
</parent>
2424
<artifactId>etoolbox-rollout-manager.core</artifactId>

core/src/main/java/com/exadel/etoolbox/rolloutmanager/core/servlets/CollectLiveCopiesServlet.java

+16
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
import org.apache.commons.httpclient.HttpStatus;
2626
import org.apache.commons.lang3.StringUtils;
2727
import org.apache.commons.lang3.time.StopWatch;
28+
import org.apache.jackrabbit.JcrConstants;
2829
import org.apache.sling.api.SlingHttpServletRequest;
2930
import org.apache.sling.api.SlingHttpServletResponse;
3031
import org.apache.sling.api.resource.Resource;
3132
import org.apache.sling.api.resource.ResourceResolver;
33+
import org.apache.sling.api.resource.ValueMap;
3234
import org.apache.sling.api.servlets.HttpConstants;
3335
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
3436
import org.apache.sling.servlets.annotations.SlingServletResourceTypes;
@@ -48,6 +50,8 @@
4850
import java.util.Optional;
4951
import java.util.concurrent.TimeUnit;
5052

53+
import static com.day.cq.wcm.msm.api.MSMNameConstants.PN_LAST_ROLLEDOUT;
54+
5155
/**
5256
* Collects data related to eligible for synchronization live relationships for the given resource.
5357
* The data is necessary for building 'Targets' tree in the UI dialog and further rollout in {@link RolloutServlet}
@@ -61,6 +65,7 @@
6165
public class CollectLiveCopiesServlet extends SlingAllMethodsServlet {
6266
private static final Logger LOG = LoggerFactory.getLogger(CollectLiveCopiesServlet.class);
6367

68+
private static final String JCR_CONTENT_NODE = "/" + JcrConstants.JCR_CONTENT;
6469
private static final String PATH_REQUEST_PARAM = "path";
6570

6671
private static final String MASTER_JSON_FIELD = "master";
@@ -69,6 +74,7 @@ public class CollectLiveCopiesServlet extends SlingAllMethodsServlet {
6974
private static final String LIVE_COPIES_JSON_FIELD = "liveCopies";
7075
private static final String IS_NEW_JSON_FIELD = "isNew";
7176
private static final String HAS_ROLLOUT_TRIGGER_JSON_FIELD = "autoRolloutTrigger";
77+
private static final String LAST_ROLLED_OUT_JSON_FIELD = "lastRolledOut";
7278

7379
@Reference
7480
private transient LiveRelationshipManager liveRelationshipManager;
@@ -139,13 +145,15 @@ private JsonObject relationshipToJson(LiveRelationship relationship,
139145

140146
String liveCopyPath = liveCopy.getPath();
141147
boolean isNew = !resourceExists(resourceResolver, liveCopyPath + syncPath);
148+
142149
return Json.createObjectBuilder()
143150
.add(MASTER_JSON_FIELD, source + sourceSyncPath)
144151
.add(PATH_JSON_FIELD, liveCopyPath + syncPath)
145152
.add(DEPTH_JSON_FIELD, depth)
146153
.add(LIVE_COPIES_JSON_FIELD, getLiveCopiesJsonArray(liveCopyPath, syncPath, resourceResolver, depth + 1))
147154
.add(IS_NEW_JSON_FIELD, isNew)
148155
.add(HAS_ROLLOUT_TRIGGER_JSON_FIELD, !isNew && hasAutoTrigger(liveCopy))
156+
.add(LAST_ROLLED_OUT_JSON_FIELD, getStringDate(resourceResolver, liveCopyPath + syncPath))
149157
.build();
150158
}
151159

@@ -173,4 +181,12 @@ private boolean resourceExists(ResourceResolver resourceResolver, String path) {
173181
return Optional.ofNullable(resourceResolver.getResource(path))
174182
.isPresent();
175183
}
184+
185+
private static String getStringDate(ResourceResolver resourceResolver, String resourcePath) {
186+
Resource syncResource = resourceResolver.getResource(resourcePath + JCR_CONTENT_NODE);
187+
return Optional.ofNullable(syncResource)
188+
.map(r -> r.adaptTo(ValueMap.class))
189+
.map(vm -> vm.get(PN_LAST_ROLLEDOUT, String.class))
190+
.orElse(StringUtils.EMPTY);
191+
}
176192
}

core/src/test/resources/com/exadel/etoolbox/rolloutmanager/core/servlets/collect-expected-items.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
"depth": 1,
1111
"liveCopies": [],
1212
"isNew": true,
13-
"autoRolloutTrigger": false
13+
"autoRolloutTrigger": false,
14+
"lastRolledOut":""
1415
}
1516
],
1617
"isNew": false,
17-
"autoRolloutTrigger": false
18+
"autoRolloutTrigger": false,
19+
"lastRolledOut":""
1820
}
1921
]

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<groupId>com.exadel.etoolbox</groupId>
2020
<artifactId>etoolbox-rollout-manager</artifactId>
2121
<packaging>pom</packaging>
22-
<version>1.1</version>
22+
<version>1.2.0</version>
2323
<name>EToolbox Rollout Manager</name>
2424
<description>EToolbox Rollout Manager</description>
2525

ui.apps.structure/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.exadel.etoolbox</groupId>
2323
<artifactId>etoolbox-rollout-manager</artifactId>
24-
<version>1.1</version>
24+
<version>1.2.0</version>
2525
<relativePath>../pom.xml</relativePath>
2626
</parent>
2727

ui.apps/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.exadel.etoolbox</groupId>
2323
<artifactId>etoolbox-rollout-manager</artifactId>
24-
<version>1.1</version>
24+
<version>1.2.0</version>
2525
<relativePath>../pom.xml</relativePath>
2626
</parent>
2727

ui.apps/src/main/content/jcr_root/apps/etoolbox-rollout-manager/clientlibs/rollout-manager-ui/css/console-ui.checkboxlist.css

+30-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
.rollout-manager-select-all {
3535
float: right;
36-
font-size: small
36+
font-size: small;
37+
min-width: 86px;
3738
}
3839

3940
.rollout-manager-coral-accordion-item-content {
@@ -56,10 +57,33 @@
5657
}
5758

5859
.rollout-manager-dialog .coral3-Dialog-wrapper {
59-
width: 600px;
60+
width: 800px;
6061
height: 526px;
6162
}
6263

64+
.rollout-manager-dialog .coral3-Checkbox {
65+
display: flex;
66+
}
67+
68+
.rollout-manager-dialog .coral3-Checkbox-description {
69+
display: flex;
70+
flex-grow: 1;
71+
}
72+
73+
.rollout-manager-dialog coral-checkbox-label {
74+
display: flex;
75+
flex-grow: 1;
76+
justify-content: space-between;
77+
}
78+
79+
.rollout-manager-dialog .coral3-Accordion-content {
80+
padding-right: 0;
81+
}
82+
83+
.rollout-manager-dialog .coral3-Accordion-header {
84+
padding-right: 0;
85+
}
86+
6387
.rollout-manager-nestedcheckboxlist-container {
6488
overflow-y: auto;
6589
height: 246px;
@@ -69,3 +93,7 @@
6993
width: 500px;
7094
height: auto;
7195
}
96+
97+
.rollout-manager-dialog .rollout-manager-last-rollout-date {
98+
z-index: 2;
99+
}

ui.apps/src/main/content/jcr_root/apps/etoolbox-rollout-manager/clientlibs/rollout-manager-ui/js.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
console-ui.checkboxlist.js
44
console-ui.dialog.js
5-
console-ui.actions.js
5+
console-ui.actions.js
6+
time-util.js

ui.apps/src/main/content/jcr_root/apps/etoolbox-rollout-manager/clientlibs/rollout-manager-ui/js/console-ui.dialog.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
const TARGET_PATHS_LABEL = Granite.I18n.get('Target paths');
114114
const ROLLOUT_SCOPE_LABEL = Granite.I18n.get('Rollout scope');
115115
const INCLUDE_SUBPAGES_LABEL = Granite.I18n.get('Include subpages');
116-
const NEW_LABEL = Granite.I18n.get('new');
117116
const CORAL_CHECKBOX_ITEM = 'coral-checkbox[name="liveCopyProperties[]"]';
118117
const MASTER_DATA_ATTR = 'master';
119118
const DEPTH_DATA_ATTR = 'depth';
@@ -183,11 +182,12 @@
183182
data-auto-rollout="${liveCopyJson.autoRolloutTrigger}"
184183
value="${liveCopyJson.path}">`
185184
).text(liveCopyJson.path);
186-
if (liveCopyJson.isNew) {
187-
const newLabel = $('<i class="rollout-manager-new-label">')
188-
.text(` ${NEW_LABEL}`);
189-
liveCopyCheckbox.append(newLabel);
190-
}
185+
const lastRolledOutTimeAgo =
186+
$(`<i
187+
title="${TimeUtil.displayLastRolledOut(liveCopyJson.lastRolledOut)}"
188+
class="rollout-manager-last-rollout-date">`
189+
).text(TimeUtil.timeSince(liveCopyJson.lastRolledOut));
190+
liveCopyCheckbox.append(lastRolledOutTimeAgo);
191191
if (liveCopyJson.liveCopies && liveCopyJson.liveCopies.length > 0) {
192192
const accordion = initNestedAccordion(liveCopyCheckbox, liveCopyJson.liveCopies);
193193
accordion.appendTo(liItem);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
/**
16+
* EToolbox Rollout Manager Time Utility.
17+
* Contains utilities for time data processing
18+
*/
19+
(function ($, ns, TimeUtil) {
20+
'use strict';
21+
22+
const NOT_ROLLED_OUT_LABEL = Granite.I18n.get('Not Rolled Out');
23+
const TIME_AGO_LABEL = Granite.I18n.get('ago');
24+
const PLURAL_SUFFIX = 's';
25+
26+
/**
27+
* Object containing time unit durations in milliseconds.
28+
*/
29+
const Time = {
30+
YEAR: 365 * 24 * 60 * 60 * 1000,
31+
MONTH: 30 * 24 * 60 * 60 * 1000,
32+
DAY: 24 * 60 * 60 * 1000,
33+
HOUR: 60 * 60 * 1000,
34+
MINUTE: 60 * 1000,
35+
SECOND: 1000
36+
};
37+
38+
/**
39+
* Options for formatting a timestamp.
40+
*/
41+
const TIME_FORMATTER_OPTIONS = {
42+
day: 'numeric',
43+
month: 'short',
44+
year: 'numeric',
45+
hour: 'numeric',
46+
hourCycle: 'h23',
47+
minute: '2-digit',
48+
second: '2-digit'
49+
};
50+
51+
/**
52+
* Calculate and format the time difference between the given date and the current date.
53+
* @param {string} date - The date to calculate the time difference from (ISO 8601 format).
54+
* @returns {string} A formatted string indicating the time difference.
55+
*/
56+
TimeUtil.timeSince = function (date) {
57+
if (!date) {
58+
return NOT_ROLLED_OUT_LABEL;
59+
}
60+
61+
const startDate = new Date(date);
62+
const now = new Date();
63+
const millisecondsBetween = now - startDate;
64+
65+
let result = '';
66+
for (const timeUnit in Time) {
67+
if (millisecondsBetween >= Time[timeUnit]) {
68+
const time = Math.floor(millisecondsBetween / Time[timeUnit]);
69+
70+
result = time + ' ' + Granite.I18n.get(timeUnit.toLowerCase() + (time !== 1 ? PLURAL_SUFFIX : '')) + ' ' + TIME_AGO_LABEL;
71+
break;
72+
}
73+
}
74+
75+
return result;
76+
};
77+
78+
/**
79+
* Display a timestamp in a formatted way.
80+
* @param {string} date - The date to format (ISO 8601 format).
81+
* @returns {string} A formatted timestamp string.
82+
*/
83+
TimeUtil.displayLastRolledOut = function (date) {
84+
if (!date) {
85+
return '';
86+
}
87+
return new Date(date).toLocaleString(undefined, TIME_FORMATTER_OPTIONS);
88+
};
89+
90+
})(Granite.$, Granite.author, (window.TimeUtil = (window.TimeUtil || {})));

ui.config/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.exadel.etoolbox</groupId>
2323
<artifactId>etoolbox-rollout-manager</artifactId>
24-
<version>1.1</version>
24+
<version>1.2.0</version>
2525
<relativePath>../pom.xml</relativePath>
2626
</parent>
2727

ui.content/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.exadel.etoolbox</groupId>
2323
<artifactId>etoolbox-rollout-manager</artifactId>
24-
<version>1.1</version>
24+
<version>1.2.0</version>
2525
<relativePath>../pom.xml</relativePath>
2626
</parent>
2727

0 commit comments

Comments
 (0)