Skip to content

Commit 172c608

Browse files
author
Jenkins CI
committed
Merge branch 'branches/rudder/8.0'
2 parents 79fd607 + b4c201e commit 172c608

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

webapp/sources/rudder/rudder-web/src/main/webapp/secure/configurationManager/techniqueEditor.html

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<div id="filemanager-editor">
1212
</div>
1313
<div id="technique-editor">
14+
</div>
1415
<script>
1516
var hasWriteRights = false;
1617
</script>
@@ -101,23 +102,35 @@
101102
});
102103

103104
app.ports.storeDraft.subscribe(function(draft) {
104-
draft.date = new Date().toISOString();
105-
var drafts = JSON.parse(localStorage.getItem("drafts"))
106-
if (drafts === null) { drafts = {} }
107-
drafts[draft.id] = draft;
108-
localStorage.setItem("drafts", JSON.stringify(drafts));
105+
try {
106+
draft.date = new Date().toISOString();
107+
var drafts = JSON.parse(localStorage.getItem("drafts"))
108+
if (drafts === null) { drafts = {} }
109+
drafts[draft.id] = draft;
110+
localStorage.setItem("drafts", JSON.stringify(drafts));
111+
} catch (error) {
112+
createErrorNotification("An error occurred while saving technique draft, it will not be persisted in your browser.\nYou can try to clean your browser local storage, but you'll lose existing drafts.\nError details: " + error) ;
113+
}
109114
});
110115

111116
app.ports.clearDraft.subscribe(function(key) {
112-
var drafts = JSON.parse(localStorage.getItem("drafts"));
113-
delete drafts[key];
114-
localStorage.setItem("drafts", JSON.stringify(drafts));
117+
try {
118+
var drafts = JSON.parse(localStorage.getItem("drafts"));
119+
delete drafts[key];
120+
localStorage.setItem("drafts", JSON.stringify(drafts));
121+
} catch (error) {
122+
createErrorNotification("An error occurred while removing draft for technique '" + key +"'.\nYou can try to clean your browser local storage, but you'll lose existing drafts.\nError details: " + error) ;
123+
}
115124
});
116125

117126
app.ports.getDrafts.subscribe(function() {
118-
var drafts = JSON.parse(localStorage.getItem("drafts"))
119-
if (drafts === null) { drafts = {} }
120-
app.ports.draftsResponse.send(drafts)
127+
try {
128+
var drafts = JSON.parse(localStorage.getItem("drafts"))
129+
if (drafts === null) { drafts = {} }
130+
app.ports.draftsResponse.send(drafts)
131+
} catch (error) {
132+
createErrorNotification("An error occurred while getting drafts.\nYou can try to clean your browser local storage, but you'll lose existing drafts.\nError details: " + error) ;
133+
}
121134
});
122135
app.ports.successNotification.subscribe(function(str) {
123136
createSuccessNotification(str)
@@ -174,6 +187,5 @@
174187
return false;
175188
}
176189
</script>
177-
</div>
178190
</div>
179191
</lift:surround>

0 commit comments

Comments
 (0)