Skip to content

Commit 31fb83b

Browse files
Merge pull request #9412 from jrafanie/dead-code-round2
Dead code round 2
2 parents 24b6d43 + 0afdd9d commit 31fb83b

File tree

6 files changed

+1
-203
lines changed

6 files changed

+1
-203
lines changed

app/helpers/js_helper.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ def javascript_focus(element)
1818
"$('##{j_str(element)}').focus();".html_safe
1919
end
2020

21-
def javascript_prepend_span(element, cls)
22-
"$('##{j_str(element)}').prepend('#{content_tag(:span, nil, :class => cls)}');".html_safe
23-
end
24-
25-
def javascript_highlight(element, status)
26-
"miqHighlight('##{j_str(element)}', #{j_str(status)});".html_safe
27-
end
28-
2921
def javascript_disable_field(element)
3022
"$('##{j_str(element)}').prop('disabled', true);".html_safe
3123
end
@@ -50,10 +42,6 @@ def javascript_hide_if_exists(element)
5042
"if (miqDomElementExists('#{j_str(element)}')) #{javascript_hide(element)}".html_safe
5143
end
5244

53-
def jquery_pulsate_element(element)
54-
"$('##{element}').fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut().fadeIn();".html_safe
55-
end
56-
5745
def partial_replace(from, partial, locals)
5846
"$(\"##{h(from)}\").replaceWith(\"#{escape_javascript(render(:partial => partial, :locals => locals))}\");".html_safe
5947
end
@@ -68,10 +56,6 @@ def javascript_unchecked(element)
6856
.html_safe
6957
end
7058

71-
def javascript_update_element(element, content)
72-
"$('##{element}').html('#{escape_javascript(content)}');"
73-
end
74-
7559
def js_build_calendar(options = {})
7660
skip_days = options[:skip_days].nil? ? 'undefined' : options[:skip_days].to_a.to_json
7761

app/javascript/oldjs/.eslintrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"globals": {
3-
"GitImport": true, // local git_import.js
4-
"miqHideSearchClearButton": true // local miq_application.js
3+
"GitImport": true // local git_import.js
54
},
65
"rules": {
76
"key-spacing": ["error", {

app/javascript/oldjs/miq_application.js

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,6 @@ window.miqGetBrowserInfo = function() {
207207
}
208208
};
209209

210-
// Turn highlight on or off
211-
window.miqHighlight = function(elem, status) {
212-
if ($(elem).length) {
213-
return;
214-
}
215-
216-
if (status) {
217-
$(elem).addClass('active');
218-
} else {
219-
$(elem).removeClass('active');
220-
}
221-
};
222-
223210
// Turn on activity indicator
224211
window.miqSparkle = function(status) {
225212
if (status) {
@@ -855,18 +842,6 @@ window.miqSendDateRequest = function(el) {
855842
return miqObserveRequest(urlstring, options);
856843
};
857844

858-
// common function to pass ajax request to server
859-
window.miqAjaxRequest = function(itemId, path) {
860-
if (miqCheckForChanges()) {
861-
miqJqueryRequest(
862-
miqPassFields(path, { id: itemId }),
863-
{ beforeSend: true, complete: true }
864-
);
865-
return true;
866-
}
867-
return false;
868-
};
869-
870845
// Handle an element onclick to open href in a new window with optional confirmation
871846
window.miqClickAndPop = function(el) {
872847
const conmsg = el.getAttribute('data-miq_confirm');
@@ -943,13 +918,6 @@ window.miq_tabs_show_hide = function(tab_id, show) {
943918
$(tab_id).toggleClass('hidden', !show);
944919
};
945920

946-
// Send explorer search by name via ajax
947-
window.miqSearchByName = function(button) {
948-
if (button == null) {
949-
miqJqueryRequest('x_search_by_name', { beforeSend: true, data: miqSerializeForm('searchbox') });
950-
}
951-
};
952-
953921
// Send transaction to server so automate tree selection box can be made active
954922
// and rest of the screen can be blocked
955923
window.miqShowAE_Tree = function(typ) {
@@ -1341,29 +1309,6 @@ window.miqInitMainContent = function() {
13411309
$('#main-content').css('height', `calc(100% - ${height}px)`);
13421310
};
13431311

1344-
window.miqHideSearchClearButton = function(explorer) {
1345-
// Hide the clear button if the search input is empty
1346-
$('.search-pf .has-clear .clear').each(function() {
1347-
if (!$(this).prev('.form-control').val()) {
1348-
$(this).hide();
1349-
}
1350-
});
1351-
// Show the clear button upon entering text in the search input
1352-
$('.search-pf .has-clear .form-control').keyup(function() {
1353-
const t = $(this);
1354-
t.nextAll('button.clear').toggle(Boolean(t.val()));
1355-
});
1356-
// Upon clicking the clear button, empty the entered text and hide the clear button
1357-
$('.search-pf .has-clear .clear').click(function() {
1358-
$(this).prev('.form-control').val('').focus();
1359-
$(this).hide();
1360-
// Clear Search text values as well
1361-
const url = `/${ManageIQ.controller}/search_clear` + `?in_explorer=${explorer}`;
1362-
ManageIQ.gridChecks = [];
1363-
miqJqueryRequest(url);
1364-
});
1365-
};
1366-
13671312
window.toggle_expansion = function(link) {
13681313
link = $(link);
13691314
link.find('i').toggleClass('fa-angle-right fa-angle-down');
@@ -1540,16 +1485,6 @@ window.miqFormatNotification = function(text, bindings) {
15401485
return str;
15411486
};
15421487

1543-
window.fontIconChar = _.memoize((klass) => {
1544-
const tmp = document.createElement('i');
1545-
tmp.className = `hidden ${klass}`;
1546-
document.body.appendChild(tmp);
1547-
const char = window.getComputedStyle(tmp, ':before').content.replace(/'|"/g, '');
1548-
const font = window.getComputedStyle(tmp, ':before').fontFamily;
1549-
tmp.remove();
1550-
return { font, char };
1551-
});
1552-
15531488
window.redirectLogin = function(msg) {
15541489
if (ManageIQ.logoutInProgress) {
15551490
return; // prevent double redirect after pressing the Logout button or when changing group
@@ -1558,11 +1493,3 @@ window.redirectLogin = function(msg) {
15581493
add_flash(msg, 'warning');
15591494
window.document.location.href = '/dashboard/login?timeout=true';
15601495
};
1561-
1562-
window.camelizeQuadicon = function(quad) {
1563-
return _.reduce(quad, (result, current, key) => {
1564-
const item = {};
1565-
item[_.camelCase(key)] = current;
1566-
return Object.assign(result, item);
1567-
}, {});
1568-
};

app/javascript/oldjs/services/miq_service.js

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ ManageIQ.angular.app.service('miqService', ['$q', 'API', '$window', function($q,
2323
miqAjaxButton(url, serializeFields, options);
2424
};
2525

26-
this.miqAsyncAjaxButton = function(url, serializeFields) {
27-
miqJqueryRequest(url, {beforeSend: true, data: serializeFields});
28-
};
29-
30-
this.jqueryRequest = function(url, options) {
31-
return miqJqueryRequest(url, options);
32-
};
33-
3426
this.refreshSelectpicker = function() {
3527
$('select').selectpicker('refresh');
3628
};
@@ -87,34 +79,6 @@ ManageIQ.angular.app.service('miqService', ['$q', 'API', '$window', function($q,
8779
.catch(options.handleFailure);
8880
};
8981

90-
this.disabledClick = function($event) {
91-
$event.preventDefault();
92-
};
93-
94-
this.serializeModel = function(model) {
95-
var serializedObj = angular.copy(model);
96-
97-
for (var k in serializedObj) {
98-
if (serializedObj.hasOwnProperty(k) && !serializedObj[k]) {
99-
delete serializedObj[k];
100-
}
101-
}
102-
103-
return serializedObj;
104-
};
105-
106-
this.serializeModelWithIgnoredFields = function(model, ignoredFields) {
107-
var serializedObj = angular.copy(model);
108-
109-
for (var k in serializedObj) {
110-
if ((ignoredFields.indexOf(k) >= 0) || (serializedObj.hasOwnProperty(k) && !serializedObj[k])) {
111-
delete serializedObj[k];
112-
}
113-
}
114-
115-
return serializedObj;
116-
};
117-
11882
this.handleFailure = function(e) {
11983
miqSparkleOff();
12084

@@ -133,44 +97,6 @@ ManageIQ.angular.app.service('miqService', ['$q', 'API', '$window', function($q,
13397
return $q.reject(e);
13498
};
13599

136-
this.getCloudNetworksByEms = function(callback) {
137-
return function(id) {
138-
if (!id) {
139-
callback([]);
140-
return;
141-
}
142-
miqService.sparkleOn();
143-
144-
API.get('/api/cloud_networks?expand=resources&attributes=name,ems_ref&filter[]=external_facing=true&filter[]=ems_id=' + id)
145-
.then(getCloudNetworksByEmsData)
146-
.catch(miqService.handleFailure);
147-
};
148-
149-
function getCloudNetworksByEmsData(data) {
150-
callback(data);
151-
miqService.sparkleOff();
152-
}
153-
};
154-
155-
this.getProviderTenants = function(callback) {
156-
return function(id) {
157-
if (!id) {
158-
callback([]);
159-
return;
160-
}
161-
miqService.sparkleOn();
162-
163-
API.get('/api/providers/' + id + '/cloud_tenants?expand=resources&attributes=id,name')
164-
.then(getCloudTenantsByEms)
165-
.catch(miqService.handleFailure);
166-
};
167-
168-
function getCloudTenantsByEms(data) {
169-
callback(data);
170-
miqService.sparkleOff();
171-
}
172-
};
173-
174100
this.redirectBack = function(message, flashType, redirectUrl) {
175101
miqFlashLater({message: message, level: flashType});
176102

spec/helpers/js_helper_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
end
2222
end
2323

24-
context '#javascript_highlight' do
25-
it 'returns js to to add or remove the active class on the element' do
26-
expect(javascript_highlight('foo', true)).to eq("miqHighlight('\#foo', true);")
27-
expect(javascript_highlight('foo', false)).to eq("miqHighlight('\#foo', false);")
28-
end
29-
end
30-
3124
context '#javascript_disable_field' do
3225
it 'returns js to disable the provided element' do
3326
expect(javascript_disable_field('foo')).to eq("$('#foo').prop('disabled', true);")

spec/javascripts/services/miq_service_spec.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -128,37 +128,6 @@ describe('miqService', function() {
128128
expect(testService.saveable(scheduleForm)).toBe(false);
129129
});
130130
});
131-
132-
describe('when the passed in model contains few attributes with null vaues', function() {
133-
beforeEach(function() {
134-
model = {
135-
depot_name: 'my_nfs_depot',
136-
uri: 'nfs://nfs_location',
137-
uri_prefix: 'nfs',
138-
log_userid: null,
139-
log_password: null,
140-
log_protocol: 'NFS'
141-
};
142-
});
143-
144-
it('it returns an object with null attributes excluded', function() {
145-
returnedObj = {
146-
depot_name: 'my_nfs_depot',
147-
uri: 'nfs://nfs_location',
148-
uri_prefix: 'nfs',
149-
log_protocol: 'NFS'
150-
};
151-
expect(testService.serializeModel(model)).toEqual(returnedObj);
152-
});
153-
});
154-
});
155-
});
156-
157-
describe('#disabledClick', function() {
158-
it('prevents a submit action', function() {
159-
var event = $.Event('click');
160-
testService.disabledClick(event);
161-
expect(event.isDefaultPrevented()).toBeTruthy();
162131
});
163132
});
164133
});

0 commit comments

Comments
 (0)