Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Moves date utils to utils folder #20192

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import invert from 'lodash/invert';
import mapKeys from 'lodash/mapKeys';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';

import { now } from 'src/modules/dates';
import { now } from 'src/utils/dates';
import {
addDangerToast as addDangerToastAction,
addInfoToast as addInfoToastAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
epochTimeXHoursAgo,
epochTimeXDaysAgo,
epochTimeXYearsAgo,
} from 'src/modules/dates';
} from 'src/utils/dates';
import AsyncSelect from 'src/components/AsyncSelect';
import { Query } from 'src/SqlLab/types';
import { STATUS_OPTIONS, TIME_OPTIONS } from 'src/SqlLab/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { t, useTheme } from '@superset-ui/core';
import { useSelector } from 'react-redux';
import TableView from 'src/components/TableView';
import Button from 'src/components/Button';
import { fDuration } from 'src/modules/dates';
import { fDuration } from 'src/utils/dates';
import Icons from 'src/components/Icons';
import { Tooltip } from 'src/components/Tooltip';
import { Query, RootState } from 'src/SqlLab/types';
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/reducers/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { t } from '@superset-ui/core';

import getInitialState from './getInitialState';
import * as actions from '../actions/sqlLab';
import { now } from '../../modules/dates';
import { now } from '../../utils/dates';
import {
addToObject,
alterInObject,
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/reducers/sqlLab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import sqlLabReducer from 'src/SqlLab/reducers/sqlLab';
import * as actions from 'src/SqlLab/actions/sqlLab';
import { now } from 'src/modules/dates';
import { now } from 'src/utils/dates';
import { table, initialState as mockState } from '../fixtures';

const initialState = mockState.sqlLab;
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/Chart/chartReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { HYDRATE_DASHBOARD } from 'src/dashboard/actions/hydrate';
import { DatasourcesAction } from 'src/dashboard/actions/datasources';
import { ChartState } from 'src/explore/types';
import { getFormDataFromControls } from 'src/explore/controlUtils';
import { now } from 'src/modules/dates';
import { now } from 'src/utils/dates';
import * as actions from './chartAction';

export const chart: ChartState = {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/Timer/Timer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import React from 'react';
import { render, sleep, waitFor } from 'spec/helpers/testing-library';
import Timer, { TimerProps } from 'src/components/Timer';
import { now } from 'src/modules/dates';
import { now } from 'src/utils/dates';

function parseTime(text?: string | null) {
return !!text && Number(text.replace(/:/g, ''));
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/Timer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { styled } from '@superset-ui/core';
import Label, { Type } from 'src/components/Label';

import { now, fDuration } from 'src/modules/dates';
import { now, fDuration } from 'src/utils/dates';

export interface TimerProps {
endTime?: number;
Expand Down
5 changes: 4 additions & 1 deletion superset-frontend/src/dashboard/actions/sliceEntities.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { t, SupersetClient } from '@superset-ui/core';
import rison from 'rison';

import { addDangerToast } from 'src/components/MessageToasts/actions';
import { getDatasourceParameter } from 'src/modules/utils';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';

export const SET_ALL_SLICES = 'SET_ALL_SLICES';
Expand All @@ -39,6 +38,10 @@ export function fetchAllSlicesFailed(error) {
return { type: FETCH_ALL_SLICES_FAILED, payload: { error } };
}

export function getDatasourceParameter(datasourceId, datasourceType) {
return `${datasourceId}__${datasourceType}`;
}

const FETCH_SLICES_PAGE_SIZE = 200;
export function fetchAllSlices(userId, excludeFilterBox = false) {
return (dispatch, getState) => {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/explore/controlPanels/Separator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { formatSelectOptions } from 'src/modules/utils';
import { formatSelectOptions } from 'src/explore/exploreUtils';

export default {
controlPanelSections: [
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/explore/controlPanels/sections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React from 'react';
import { t } from '@superset-ui/core';
import { ControlPanelSectionConfig } from '@superset-ui/chart-controls';
import { formatSelectOptions } from 'src/modules/utils';
import { formatSelectOptions } from 'src/explore/exploreUtils';

export const druidTimeSeries: ControlPanelSectionConfig = {
label: t('Time'),
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
legacyValidateInteger,
validateNonEmpty,
} from '@superset-ui/core';
import { formatSelectOptions } from 'src/modules/utils';
import { formatSelectOptions } from 'src/explore/exploreUtils';
import { TIME_FILTER_LABELS } from './constants';
import { StyledColumnOption } from './components/optionRenderers';

Expand Down
4 changes: 4 additions & 0 deletions superset-frontend/src/explore/exploreUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,7 @@ export const getSimpleSQLExpression = (subject, operator, comparator) => {
}
return expression;
};

export function formatSelectOptions(options) {
return options.map(opt => [opt, opt.toString()]);
}
43 changes: 0 additions & 43 deletions superset-frontend/src/modules/utils.js

This file was deleted.

40 changes: 0 additions & 40 deletions superset-frontend/src/modules/utils.test.jsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
epochTimeXHoursAgo,
epochTimeXDaysAgo,
epochTimeXYearsAgo,
} from 'src/modules/dates';
} from 'src/utils/dates';

describe('fDuration', () => {
it('is a function', () => {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/views/CRUD/alert/ExecutionLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import ListView from 'src/components/ListView';
import { Tooltip } from 'src/components/Tooltip';
import SubMenu from 'src/views/components/SubMenu';
import withToasts from 'src/components/MessageToasts/withToasts';
import { fDuration } from 'src/modules/dates';
import { fDuration } from 'src/utils/dates';
import AlertStatusIcon from 'src/views/CRUD/alert/components/AlertStatusIcon';
import {
useListViewResource,
Expand Down