mirror of
https://github.com/apache/superset.git
synced 2024-09-17 11:09:47 -04:00
remove dead code (#6884)
This commit is contained in:
parent
5728946270
commit
bd9a2c15e7
@ -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>' });
|
||||
|
@ -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));
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
@ -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>';
|
||||
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
|
||||
export default function reactify(renderFn) {
|
||||
class ReactifiedComponent extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.setContainerRef = this.setContainerRef.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.execute();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.execute();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.container = null;
|
||||
}
|
||||
|
||||
setContainerRef(c) {
|
||||
this.container = c;
|
||||
}
|
||||
|
||||
execute() {
|
||||
if (this.container) {
|
||||
renderFn(this.container, this.props);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { id, className } = this.props;
|
||||
return (
|
||||
<div
|
||||
id={id}
|
||||
className={className}
|
||||
ref={this.setContainerRef}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderFn.displayName) {
|
||||
ReactifiedComponent.displayName = renderFn.displayName;
|
||||
}
|
||||
if (renderFn.propTypes) {
|
||||
ReactifiedComponent.propTypes = renderFn.propTypes;
|
||||
}
|
||||
if (renderFn.defaultProps) {
|
||||
ReactifiedComponent.defaultProps = renderFn.defaultProps;
|
||||
}
|
||||
return ReactifiedComponent;
|
||||
}
|
Loading…
Reference in New Issue
Block a user