Skip to content

Commit 29c71d9

Browse files
committed
Disable the trace delete link while that trace is running.
1 parent 328c8d9 commit 29c71d9

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

codepulse/src/main/resources/toserve/pages/TraceList/TraceList.js

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
itemsSelection.each(updateItem)
5151
}
5252

53+
function checkRunningState(data){
54+
switch(data.state){
55+
case 'running':
56+
case 'ending':
57+
return true
58+
default:
59+
return false
60+
}
61+
}
62+
5363
// Set up the export and delete links for the data/item.
5464
// This assumes that the hrefs won't change
5565
function setupNewItem(data){
@@ -62,16 +72,6 @@
6272
.attr('data-downloader', data.exportHref)
6373
.attr('data-filename', data.name + '.pulse')
6474
.traceDownloader('create')
65-
66-
// set up the delete link
67-
$deleteLink.click(function(){
68-
$.ajax(data.deleteHref, {
69-
type: 'DELETE',
70-
error: function(xhr, status){
71-
alert('Deleting failed.')
72-
}
73-
})
74-
})
7575
}
7676

7777
// Update the name and dates for the data/item
@@ -81,7 +81,8 @@
8181
$nameDiv = $item.find('.traceName'),
8282
$created = $item.find('.date-created span[name=date]'),
8383
$importedDiv = $item.find('.date-imported'),
84-
$imported = $importedDiv.find('span[name=date]')
84+
$imported = $importedDiv.find('span[name=date]'),
85+
isTraceRunning = checkRunningState(data)
8586

8687
$link
8788
.attr('href', data.href)
@@ -93,16 +94,24 @@
9394
$imported.text(imported)
9495
$importedDiv.css('display', imported ? null : 'none')
9596

96-
switch(data.state){
97-
case 'idle':
98-
case 'connecting':
99-
$item.removeClass('stripedBackground animated')
100-
break;
101-
case 'running':
102-
case 'ending':
103-
$item.addClass('stripedBackground animated')
104-
break;
97+
$item.toggleClass('stripedBackground animated', isTraceRunning)
98+
99+
function handleDeleteClick(){
100+
if(isTraceRunning){
101+
var msg = "You can't delete this trace because it is currently running."
102+
alert(msg)
103+
} else $.ajax(data.deleteHref, {
104+
type: 'DELETE',
105+
error: function(xhr, status){
106+
alert('Deleting failed.')
107+
}
108+
})
105109
}
110+
111+
// update the delete link: if the trace is running, you can't click it
112+
d3.select($item.find('a[name=delete]')[0])
113+
.on('click', handleDeleteClick)
114+
.attr('disabled', isTraceRunning ? 'disabled' : null)
106115
}
107116

108117
// Initiate an AJAX request to load the trace data list

codepulse/src/main/resources/toserve/pages/TraceSwitcher/TraceSwitcher.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@
184184
background-color: #BBB;
185185
}
186186

187+
.traceSwitcher .traceListItem .menu-links a[disabled] {
188+
text-decoration: line-through;
189+
}
190+
187191
.traceSwitcher .traceListItem .date {
188192
font-size: small;
189193
}

0 commit comments

Comments
 (0)