Skip to content

Commit

Permalink
remove dead code (apache#6884)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw authored Feb 15, 2019
1 parent 5728946 commit bd9a2c1
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 151 deletions.
39 changes: 1 addition & 38 deletions superset/assets/spec/javascripts/utils/common_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import { isTruthy, optionFromValue, prepareCopyToClipboardTabularData } from '../../../src/utils/common';
import { optionFromValue, prepareCopyToClipboardTabularData } from '../../../src/utils/common';

describe('utils/common', () => {
describe('isTruthy', () => {
it('evals false-looking strings properly', () => {
expect(isTruthy('f')).toBe(false);
expect(isTruthy('false')).toBe(false);
expect(isTruthy('no')).toBe(false);
expect(isTruthy('n')).toBe(false);
expect(isTruthy('F')).toBe(false);
expect(isTruthy('False')).toBe(false);
expect(isTruthy('NO')).toBe(false);
expect(isTruthy('N')).toBe(false);
});
it('evals true-looking strings properly', () => {
expect(isTruthy('t')).toBe(true);
expect(isTruthy('true')).toBe(true);
expect(isTruthy('yes')).toBe(true);
expect(isTruthy('y')).toBe(true);
expect(isTruthy('Y')).toBe(true);
expect(isTruthy('True')).toBe(true);
expect(isTruthy('Yes')).toBe(true);
expect(isTruthy('YES')).toBe(true);
});
it('evals bools properly', () => {
expect(isTruthy(false)).toBe(false);
expect(isTruthy(true)).toBe(true);
});
it('evals ints properly', () => {
expect(isTruthy(0)).toBe(false);
expect(isTruthy(1)).toBe(true);
});
it('evals constants properly', () => {
expect(isTruthy(null)).toBe(false);
expect(isTruthy(undefined)).toBe(false);
});
it('string auto is false', () => {
expect(isTruthy('false')).toBe(false);
});
});
describe('optionFromValue', () => {
it('converts values as expected', () => {
expect(optionFromValue(false)).toEqual({ value: false, label: '<false>' });
Expand Down
11 changes: 0 additions & 11 deletions superset/assets/src/modules/dates.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@
*/
import moment from 'moment';

export function UTC(dttm) {
return new Date(
dttm.getUTCFullYear(),
dttm.getUTCMonth(),
dttm.getUTCDate(),
dttm.getUTCHours(),
dttm.getUTCMinutes(),
dttm.getUTCSeconds(),
);
}

export const fDuration = function (t1, t2, format = 'HH:mm:ss.SS') {
const diffSec = t2 - t1;
const duration = moment(new Date(diffSec));
Expand Down
12 changes: 0 additions & 12 deletions superset/assets/src/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,6 @@ export function showModal(options) {
$(options.modalSelector).modal('show');
}

/**
* Fix the height of the table body of a DataTable with scrollY set
*/
export const fixDataTableBodyHeight = function ($tableDom, height) {
const headHeight = $tableDom.find('.dataTables_scrollHead').height();
const filterHeight = $tableDom.find('.dataTables_filter').height() || 0;
const pageLengthHeight = $tableDom.find('.dataTables_length').height() || 0;
const paginationHeight = $tableDom.find('.dataTables_paginate').height() || 0;
const controlsHeight = (pageLengthHeight > filterHeight) ? pageLengthHeight : filterHeight;
$tableDom.find('.dataTables_scrollBody').css('max-height', height - headHeight - controlsHeight - paginationHeight);
};

export function formatSelectOptionsForRange(start, end) {
// outputs array of arrays
// formatSelectOptionsForRange(1, 5)
Expand Down
18 changes: 0 additions & 18 deletions superset/assets/src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
import { SupersetClient } from '@superset-ui/connection';
import getClientErrorObject from './getClientErrorObject';

export const LUMINANCE_RED_WEIGHT = 0.2126;
export const LUMINANCE_GREEN_WEIGHT = 0.7152;
export const LUMINANCE_BLUE_WEIGHT = 0.0722;

export function rgbLuminance(r, g, b) {
// Formula: https://en.wikipedia.org/wiki/Relative_luminance
return LUMINANCE_RED_WEIGHT * r + LUMINANCE_GREEN_WEIGHT * g + LUMINANCE_BLUE_WEIGHT * b;
}

export function getParamFromQuery(query, param) {
const vars = query.split('&');
for (let i = 0; i < vars.length; i += 1) {
Expand Down Expand Up @@ -83,15 +74,6 @@ export function supersetURL(rootUrl, getParams = {}) {
return url.href;
}

export function isTruthy(obj) {
if (typeof obj === 'boolean') {
return obj;
} else if (typeof obj === 'string') {
return ['yes', 'y', 'true', 't', '1'].indexOf(obj.toLowerCase()) >= 0;
}
return !!obj;
}

export function optionLabel(opt) {
if (opt === null) {
return '<NULL>';
Expand Down
72 changes: 0 additions & 72 deletions superset/assets/src/utils/reactify.jsx

This file was deleted.

0 comments on commit bd9a2c1

Please sign in to comment.