(obj, path, fallback)\n}\n","import {createBrowserHistory} from 'history'\nimport {getBrowserBasepath} from 'src/utils/basepath'\n\nconst basepath = getBrowserBasepath()\n// Older method used for pre-IE 11 compatibility\nwindow.basepath = basepath\n\nexport const history = createBrowserHistory({basename: basepath})\n","// Libraries\nimport React from 'react'\n\n// Types\nimport {ErrorMessageComponent} from 'src/types'\n\nconst DefaultErrorMessage: ErrorMessageComponent = () => {\n return (\n \n An InfluxDB error has occurred. Please report the issue \n \n here\n \n .\n
\n )\n}\n\nexport default DefaultErrorMessage\n","import {OPTION_NAME} from 'src/variables/constants/index'\nimport {formatExpression} from 'src/variables/utils/formatExpression'\nimport {VariableAssignment, Variable} from 'src/types'\nimport {asAssignment} from 'src/variables/selectors'\n\nexport const formatVarsOption = (\n variables: VariableAssignment[] | Variable[]\n): string => {\n if (!variables.length) {\n return ''\n }\n\n const lines = getAssignmentVariables(variables).map(\n v => `${v.id.name}: ${formatExpression(v.init)}`\n )\n\n const option = `option ${OPTION_NAME} = {\n ${lines.join(',\\n ')}\n}`\n\n return option\n}\n\nconst getAssignmentVariables = (\n variables: Variable[] | VariableAssignment[]\n): VariableAssignment[] => {\n const assignments = []\n\n // Looping over instead of map to get around ts interface signature incompatibility error\n variables.forEach(v => {\n if (!!v) {\n v.type === 'VariableAssignment'\n ? assignments.push(v)\n : assignments.push(asAssignment(v))\n }\n })\n\n return assignments.filter(v => !!v)\n}\n","// Libraries\nimport React, {FC} from 'react'\nimport {Link} from 'react-router-dom'\nimport {Button, ComponentSize} from '@influxdata/clockface'\nimport {useDispatch} from 'react-redux'\n\n// Utils\nimport {setFunctions} from 'src/timeMachine/actions/queryBuilder'\n\n// Types\nimport {NotificationDismiss} from 'src/types'\n\nexport const getDeleteAccountWarningButton = (\n url: string,\n onDismiss: NotificationDismiss\n): JSX.Element => {\n return (\n \n Go to Users page\n \n )\n}\n\ninterface AggregateTypeErrorButtonProps {\n onDismiss: NotificationDismiss\n}\n\nexport const AggregateTypeErrorButton: FC = ({\n onDismiss,\n}) => {\n const dispatch = useDispatch()\n const onClick = () => {\n dispatch(setFunctions(['last']))\n onDismiss()\n }\n\n return (\n \n )\n}\n\nexport const getAggregateTypeErrorButton = (\n onDismiss: NotificationDismiss\n): JSX.Element => {\n return \n}\n","module.exports = __webpack_public_path__ + \"ef38e44f38.svg\";","// Types\nimport {RemoteDataState, ViewEntities} from 'src/types'\nimport {NormalizedSchema} from 'normalizr'\nimport {CellSchema} from 'src/cells/actions/creators'\n\n// Actions\nimport {setDashboard} from 'src/dashboards/actions/creators'\n\nexport type Action =\n | ReturnType\n | ReturnType\n | ReturnType\n | ReturnType\n | ReturnType\n | ReturnType\n\nexport const REMOVE_VIEW = 'REMOVE_VIEW'\nexport const RESET_VIEWS = 'RESET_VIEWS'\nexport const SET_VIEW = 'SET_VIEW'\nexport const SET_VIEWS = 'SET_VIEWS'\nexport const SET_VIEWS_AND_CELLS = 'SET_VIEWS_AND_CELLS'\n\ntype ViewSchema = NormalizedSchema\n\nexport const removeView = (id: string) =>\n ({\n type: REMOVE_VIEW,\n id,\n } as const)\n\nexport const resetViews = () =>\n ({\n type: RESET_VIEWS,\n } as const)\n\nexport const setViews = (\n status: RemoteDataState,\n schema?: ViewSchema\n) =>\n ({\n type: SET_VIEWS,\n status,\n schema,\n } as const)\n\nexport const setView = (\n id: string,\n status: RemoteDataState,\n schema?: ViewSchema\n) =>\n ({\n type: SET_VIEW,\n id,\n status,\n schema,\n } as const)\n\nexport const setViewsAndCells = (\n status: RemoteDataState,\n cellsArray: CellSchema[],\n viewsArray: ViewSchema[]\n) =>\n ({\n type: SET_VIEWS_AND_CELLS,\n cellsArray,\n viewsArray,\n status,\n } as const)\n","import {\n setRequestHandler,\n setResponseHandler,\n postSignout,\n} from './generatedRoutes'\nimport {getAPIBasepath} from 'src/utils/basepath'\n\nsetRequestHandler((url: string, query: string, init: RequestInit) => {\n return {\n url: `${getAPIBasepath()}${url}`,\n query,\n init,\n }\n})\n\nsetResponseHandler((status, headers, data) => {\n // if the user is inactive log them out\n // influxdb/http/authentication_middleware.go\n if (status === 403 && data.message === 'User is inactive') {\n postSignout({})\n window.location.href = '/signin'\n }\n\n return {status, headers, data}\n})\n\nexport * from './generatedRoutes'\n","// TODO: handle these any types\n\nimport {TimeZone} from 'src/types'\n\nconst dateTimeOptions: any = {\n hourCycle: 'h23',\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n}\n\nconst timeOptions: any = {\n hourCycle: 'h23',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n}\n\ninterface Division {\n ms: number\n scale: Intl.RelativeTimeFormatUnit\n}\n\nconst relativeDivisions: Division[] = [\n {scale: 'years', ms: 31536000000},\n {scale: 'months', ms: 2628000000},\n {scale: 'days', ms: 86400000},\n {scale: 'hours', ms: 3600000},\n {scale: 'minutes', ms: 60000},\n {scale: 'seconds', ms: 1000},\n]\n\nexport const createRelativeFormatter = (\n numeric: Intl.RelativeTimeFormatNumeric = 'always'\n) => {\n const formatter = new Intl.RelativeTimeFormat('en-us', {\n numeric,\n })\n\n const formatDateRelative = (date: Date) => {\n const millisecondsAgo = date.getTime() - Date.now()\n\n for (const {scale, ms} of relativeDivisions) {\n if (Math.abs(millisecondsAgo) >= ms || scale === 'seconds') {\n return formatter.format(Math.round(millisecondsAgo / ms), scale)\n }\n }\n }\n\n return {\n formatRelative: formatDateRelative,\n }\n}\n\nexport const createDateTimeFormatter = (\n format: string,\n timeZone: TimeZone = 'Local'\n) => {\n switch (format) {\n default: {\n if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development') {\n console.warn(\n 'createDateTimeFormatter: the format argument provided is either invalid or not supported at the moment.'\n )\n }\n break\n }\n\n case 'YYYY-MM-DD': {\n const options = {\n ...dateTimeOptions,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}-${dateParts.month}-${dateParts.day}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'YYYY-MM-DD hh:mm:ss a': {\n const options = {\n ...dateTimeOptions,\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n\n const formatter = Intl.DateTimeFormat('en-us', options)\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}-${dateParts.month}-${dateParts.day} ${dateParts.hour}:${dateParts.minute}:${dateParts.second} ${dateParts.dayPeriod}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'YYYY-MM-DD hh:mm:ss a ZZ': {\n const options = {\n ...dateTimeOptions,\n timeZoneName: 'short',\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}-${dateParts.month}-${dateParts.day} ${dateParts.hour}:${dateParts.minute}:${dateParts.second} ${dateParts.dayPeriod} ${dateParts.timeZoneName}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'YYYY-MM-DD HH:mm:ss': {\n const options = {\n ...dateTimeOptions,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}-${dateParts.month}-${dateParts.day} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'YYYY-MM-DD HH:mm:ss.sss': {\n const options = {\n ...dateTimeOptions,\n fractionalSecondDigits: 3,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}-${dateParts.month}-${dateParts.day} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}.${dateParts.fractionalSecond}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'YYYY-MM-DD HH:mm': {\n const options = {\n ...dateTimeOptions,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}-${dateParts.month}-${dateParts.day} ${dateParts.hour}:${dateParts.minute}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'DD/MM/YYYY HH:mm:ss.sss': {\n const options = {\n ...dateTimeOptions,\n fractionalSecondDigits: 3,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.day}/${dateParts.month}/${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}.${dateParts.fractionalSecond}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'DD/MM/YYYY hh:mm:ss.sss a': {\n const options = {\n ...dateTimeOptions,\n fractionalSecondDigits: 3,\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.day}/${dateParts.month}/${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}.${dateParts.fractionalSecond} ${dateParts.dayPeriod}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'MM/DD/YYYY HH:mm:ss.sss': {\n const options = {\n ...dateTimeOptions,\n fractionalSecondDigits: 3,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.month}/${dateParts.day}/${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}.${dateParts.fractionalSecond}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'MM/DD/YYYY hh:mm:ss.sss a': {\n const options = {\n ...dateTimeOptions,\n fractionalSecondDigits: 3,\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.month}/${dateParts.day}/${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}.${dateParts.fractionalSecond} ${dateParts.dayPeriod}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'YYYY/MM/DD HH:mm:ss': {\n const options = {\n ...dateTimeOptions,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}/${dateParts.month}/${dateParts.day} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'YYYY/MM/DD hh:mm:ss a': {\n const options = {\n ...dateTimeOptions,\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.year}/${dateParts.month}/${dateParts.day} ${dateParts.hour}:${dateParts.minute}:${dateParts.second} ${dateParts.dayPeriod}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n /** ****************** LONG DATE FORMATTING ********************/\n\n case 'MMMM D, YYYY HH:mm:ss': {\n const options = {\n ...dateTimeOptions,\n month: 'long',\n day: 'numeric',\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.month} ${dateParts.day}, ${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'MMMM D, YYYY hh:mm:ss a': {\n const options = {\n ...dateTimeOptions,\n month: 'long',\n day: 'numeric',\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.month} ${dateParts.day}, ${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second} ${dateParts.dayPeriod}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'dddd, MMMM D, YYYY HH:mm:ss': {\n const options = {\n ...dateTimeOptions,\n month: 'long',\n day: 'numeric',\n weekday: 'long',\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.weekday}, ${dateParts.month} ${dateParts.day}, ${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n case 'dddd, MMMM D, YYYY hh:mm:ss a': {\n const options = {\n ...dateTimeOptions,\n month: 'long',\n day: 'numeric',\n weekday: 'long',\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatDate = date => {\n const parts = formatter.formatToParts(date)\n const dateParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n dateParts[part.type] = part.value\n })\n\n return `${dateParts.weekday}, ${dateParts.month} ${dateParts.day}, ${dateParts.year} ${dateParts.hour}:${dateParts.minute}:${dateParts.second} ${dateParts.dayPeriod}`\n }\n\n return {\n format: formatDate,\n }\n }\n\n /** ****************** TIME FORMATTING ********************/\n\n case 'HH:mm': {\n const options = {\n ...timeOptions,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute}`\n }\n\n return {\n format: formatTime,\n }\n }\n\n case 'hh:mm a': {\n const options = {\n ...timeOptions,\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute} ${timeParts.dayPeriod}`\n }\n\n return {\n format: formatTime,\n }\n }\n\n case 'HH:mm:ss': {\n const options = {\n ...timeOptions,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute}:${timeParts.second}`\n }\n\n return {\n format: formatTime,\n }\n }\n\n case 'hh:mm:ss a': {\n const options = {\n ...timeOptions,\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute}:${timeParts.second} ${timeParts.dayPeriod}`\n }\n\n return {\n format: formatTime,\n }\n }\n\n case 'HH:mm:ss ZZ': {\n const options = {\n ...timeOptions,\n timeZoneName: 'short',\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute}:${timeParts.second} ${timeParts.timeZoneName}`\n }\n\n return {\n format: formatTime,\n }\n }\n\n case 'hh:mm:ss a ZZ': {\n const options = {\n ...timeOptions,\n timeZoneName: 'short',\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute}:${timeParts.second} ${timeParts.dayPeriod} ${timeParts.timeZoneName}`\n }\n\n return {\n format: formatTime,\n }\n }\n\n case 'HH:mm:ss.sss': {\n const options = {\n ...timeOptions,\n fractionalSecondDigits: 3,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute}:${timeParts.second}.${timeParts.fractionalSecond}`\n }\n\n return {\n format: formatTime,\n }\n }\n\n case 'hh:mm:ss.sss a': {\n const options = {\n ...timeOptions,\n fractionalSecondDigits: 3,\n hour12: true,\n }\n\n if (timeZone === 'UTC') {\n options.timeZone = 'UTC'\n }\n const formatter = Intl.DateTimeFormat('en-us', options)\n\n const formatTime = date => {\n const parts = formatter.formatToParts(date)\n const timeParts: any = {}\n\n parts\n .filter(part => part.type !== 'literal')\n .forEach(part => {\n timeParts[part.type] = part.value\n })\n\n return `${timeParts.hour}:${timeParts.minute}:${timeParts.second}.${timeParts.fractionalSecond} ${timeParts.dayPeriod}`\n }\n\n return {\n format: formatTime,\n }\n }\n }\n}\n","import {Dispatch, Action, Middleware} from 'redux'\n\n// Trigger resize event to re-layout the React Layout plugin\nexport const resizeLayout: Middleware = () => (next: Dispatch) => (\n action: Action\n) => {\n next(action)\n\n if (\n action.type === 'ENABLE_PRESENTATION_MODE' ||\n action.type === 'DISABLE_PRESENTATION_MODE'\n ) {\n // Uses longer event object creation method due to IE compatibility.\n const evt = document.createEvent('HTMLEvents')\n evt.initEvent('resize', false, true)\n window.dispatchEvent(evt)\n }\n}\n","import {Middleware, Dispatch, Action} from 'redux'\n// Middleware generally used for actions needing parsed queryStrings\nimport qs from 'qs'\n\nimport {enablePresentationMode} from 'src/shared/actions/app'\n\nexport const queryStringConfig: Middleware = () => (\n dispatch: Dispatch\n) => (action: Action) => {\n dispatch(action)\n\n const urlQueryParams = qs.parse(window.location.search, {\n ignoreQueryPrefix: true,\n })\n\n if (urlQueryParams.present === 'true') {\n dispatch(enablePresentationMode())\n }\n}\n","import {combineReducers} from 'redux'\n\n// Types\nimport {ActionTypes, Action} from 'src/shared/actions/app'\nimport {AUTOREFRESH_DEFAULT_INTERVAL} from 'src/shared/constants'\nimport {TimeZone, NavBarState, Theme, VersionInfo, FlowsCTA} from 'src/types'\n\nexport interface AppState {\n ephemeral: {\n inPresentationMode: boolean\n hasUpdatedTimeRangeInVEO: boolean\n }\n persisted: {\n autoRefresh: number\n showTemplateControlBar: boolean\n timeZone: TimeZone\n navBarState: NavBarState\n theme: Theme\n versionInfo: VersionInfo\n flowsCTA: FlowsCTA\n }\n}\n\nconst initialState: AppState = {\n ephemeral: {\n inPresentationMode: false,\n hasUpdatedTimeRangeInVEO: false,\n },\n persisted: {\n theme: 'dark',\n autoRefresh: AUTOREFRESH_DEFAULT_INTERVAL,\n showTemplateControlBar: false,\n timeZone: 'Local',\n navBarState: 'collapsed',\n versionInfo: {version: '', commit: ''},\n flowsCTA: {explorer: true, tasks: true, alerts: true},\n },\n}\n\nconst {\n ephemeral: initialAppEphemeralState,\n persisted: initialAppPersistedState,\n} = initialState\n\nconst appEphemeralReducer = (\n state = initialAppEphemeralState,\n action: Action\n): AppState['ephemeral'] => {\n switch (action.type) {\n case ActionTypes.EnablePresentationMode: {\n return {\n ...state,\n inPresentationMode: true,\n }\n }\n\n case ActionTypes.DisablePresentationMode: {\n return {\n ...state,\n inPresentationMode: false,\n }\n }\n\n case ActionTypes.EnableUpdatedTimeRangeInVEO: {\n return {\n ...state,\n hasUpdatedTimeRangeInVEO: true,\n }\n }\n\n case ActionTypes.DisableUpdatedTimeRangeInVEO: {\n return {\n ...state,\n hasUpdatedTimeRangeInVEO: false,\n }\n }\n\n default:\n return state\n }\n}\n\nconst appPersistedReducer = (\n state = initialAppPersistedState,\n action: Action\n): AppState['persisted'] => {\n switch (action.type) {\n case 'SET_THEME': {\n return {...state, theme: action.theme}\n }\n\n case ActionTypes.SetAutoRefresh: {\n return {\n ...state,\n autoRefresh: action.payload.milliseconds,\n }\n }\n\n case ActionTypes.SetVersionInfo: {\n return {\n ...state,\n versionInfo: action.payload.versionInfo,\n }\n }\n\n case ActionTypes.SetTimeZone: {\n const {timeZone} = action.payload\n\n return {...state, timeZone}\n }\n\n case 'SET_NAV_BAR_STATE': {\n const navBarState = action.navBarState\n return {\n ...state,\n navBarState,\n }\n }\n\n case ActionTypes.SetFlowsCTA: {\n return {\n ...state,\n flowsCTA: {\n ...state.flowsCTA,\n ...action.payload.flowsCTA,\n },\n }\n }\n\n default:\n return state\n }\n}\n\nconst appReducer = combineReducers({\n ephemeral: appEphemeralReducer,\n persisted: appPersistedReducer,\n})\n\nexport default appReducer\n","import {\n Action,\n SET_CURRENT_DASHBOARD,\n} from 'src/shared/actions/currentDashboard'\n\nexport interface CurrentDashboardState {\n id: string\n}\n\nexport const initialState: CurrentDashboardState = {\n id: '',\n}\n\nconst reducer = (\n state: CurrentDashboardState = initialState,\n action: Action\n): CurrentDashboardState => {\n switch (action.type) {\n case SET_CURRENT_DASHBOARD:\n state.id = action.id\n return {...state}\n default:\n return state\n }\n}\n\nexport default reducer\n","import {produce} from 'immer'\nimport uuid from 'uuid'\nimport {Action} from 'src/shared/actions/notifications'\nimport {Notification} from 'src/types'\n\nexport const initialState: Notification[] = []\n\nexport const notificationsReducer = (\n state = initialState,\n action: Action\n): Notification[] =>\n produce(state, draftState => {\n switch (action.type) {\n case 'PUBLISH_NOTIFICATION': {\n const {notification} = action.payload\n const publishedNotification = {\n ...notification,\n id: uuid.v4(),\n }\n const matchIndex = state.findIndex(\n n =>\n (n.type && notification.type && n.type === notification.type) ||\n (n.message && n.message === notification.message)\n )\n const isUnique = matchIndex === -1\n if (isUnique) {\n draftState.unshift(publishedNotification)\n }\n return\n }\n\n case 'DISMISS_NOTIFICATION': {\n const {id} = action.payload\n return draftState.filter(n => n.id !== id)\n }\n\n case 'DISMISS_ALL_NOTIFICATIONS': {\n return []\n }\n }\n })\n","import app from 'src/shared/reducers/app'\nimport currentDashboard from 'src/shared/reducers/currentDashboard'\nimport {notificationsReducer} from 'src/shared/reducers/notifications'\n\nexport default {\n app,\n currentDashboard,\n notifications: notificationsReducer,\n}\n","import {\n Actions,\n SET_FEATURE_FLAGS,\n SET_PUBLIC_FEATURE_FLAGS,\n RESET_FEATURE_FLAGS,\n CLEAR_FEATURE_FLAG_OVERRIDES,\n SET_FEATURE_FLAG_OVERRIDE,\n SET_FEATURE_FLAG_OVERRIDES,\n FlagMap,\n} from 'src/shared/actions/flags'\nimport {RemoteDataState} from 'src/types'\n\nexport interface FlagState {\n status: RemoteDataState\n original: FlagMap\n override: FlagMap\n}\n\nconst defaultState: FlagState = {\n status: RemoteDataState.NotStarted,\n original: {},\n override: {},\n}\n\nexport default (state = defaultState, action: Actions): FlagState => {\n switch (action.type) {\n case SET_FEATURE_FLAGS:\n // just setting the loading state\n if (!action.payload.flags) {\n const newState = {\n ...state,\n status: action.payload.status,\n }\n\n if (!state.hasOwnProperty('original')) {\n newState.original = defaultState.original\n }\n\n return newState\n }\n return {\n ...state,\n status: action.payload.status,\n original: action.payload.flags,\n }\n case SET_PUBLIC_FEATURE_FLAGS:\n // just setting the loading state\n if (!action.payload.flags) {\n const newState = {\n ...state,\n }\n\n if (!state.hasOwnProperty('original')) {\n newState.original = defaultState.original\n }\n\n return newState\n }\n return {\n ...state,\n original: action.payload.flags,\n }\n case RESET_FEATURE_FLAGS:\n return {\n ...defaultState,\n }\n case CLEAR_FEATURE_FLAG_OVERRIDES:\n return {\n ...state,\n override: {},\n }\n case SET_FEATURE_FLAG_OVERRIDE:\n const override = {\n ...(state.override || {}),\n ...action.payload,\n }\n return {\n ...state,\n override,\n }\n case SET_FEATURE_FLAG_OVERRIDES:\n return {\n ...state,\n override: action.payload.flags,\n }\n default:\n return state\n }\n}\n","import {Action, SET_IS_AUTO_FUNCTION} from 'src/shared/actions/currentExplorer'\n\nexport interface CurrentExplorerState {\n isAutoFunction: boolean\n}\n\nexport const initialState: CurrentExplorerState = {\n isAutoFunction: true,\n}\n\nconst reducer = (\n state: CurrentExplorerState = initialState,\n action: Action\n): CurrentExplorerState => {\n switch (action.type) {\n case SET_IS_AUTO_FUNCTION:\n state.isAutoFunction = action.isAutoFunction\n return {...state}\n default:\n return state\n }\n}\n\nexport default reducer\n","import {\n RemoteDataState,\n ResourceState,\n TaskOptions,\n TaskSchedule,\n} from 'src/types'\n\nexport const initialState = (): ResourceState['tasks'] => ({\n allIDs: [],\n byID: {},\n status: RemoteDataState.NotStarted,\n newScript: '',\n currentTask: null,\n currentScript: '',\n searchTerm: '',\n showInactive: true,\n taskOptions: defaultOptions,\n runStatus: RemoteDataState.NotStarted,\n runs: [],\n logs: [],\n currentPage: 'TasksPage',\n})\n\nexport const defaultOptions: TaskOptions = {\n name: '',\n interval: '',\n offset: '',\n cron: '',\n taskScheduleType: TaskSchedule.unselected,\n orgID: '',\n toBucketName: '',\n toOrgName: '',\n}\n","// Libraries\nimport {get} from 'lodash'\n\n// Types\nimport {ResourceType, NormalizedState, RemoteDataState} from 'src/types'\n\nexport const setResourceAtID = (\n draftState: NormalizedState,\n action,\n resource: ResourceType\n) => {\n const {schema, status, id} = action\n\n const prevResource = get(draftState, ['byID', id], {})\n const currentResource = get(schema, ['entities', resource, id], {})\n\n if (!draftState.allIDs.includes(id)) {\n draftState.allIDs.push(id)\n }\n\n draftState.byID[id] = {...prevResource, ...currentResource, status}\n}\n\nexport const setResource = (\n draftState: NormalizedState,\n action,\n resource: ResourceType\n) => {\n const {status, schema} = action\n draftState.status = status\n if (get(schema, ['entities', resource])) {\n draftState.byID = schema.entities[resource]\n draftState.allIDs = schema.result\n }\n\n return\n}\n\nexport const addResource = (\n draftState: NormalizedState,\n action,\n resource: ResourceType\n) => {\n const {result, entities} = action.schema\n\n draftState.byID[result] = entities[resource][result]\n draftState.allIDs.push(result)\n}\n\nexport const editResource = (\n draftState: NormalizedState,\n action,\n resource: ResourceType\n) => {\n const {entities, result} = action.schema\n\n draftState.byID[result] = entities[resource][result]\n}\n\ninterface RemoveAction {\n type: string\n id: string\n}\n\nexport const removeResource = (\n draftState: NormalizedState,\n action: RemoveAction\n) => {\n const {id} = action\n delete draftState.byID[id]\n draftState.allIDs = draftState.allIDs.filter(uuid => uuid !== id)\n\n return\n}\n\nexport const setRelation = (\n draftState: NormalizedState,\n childType: ResourceType,\n childID: string,\n parentID: string\n) => {\n const resource = draftState.byID[parentID]\n\n if (!resource) {\n return\n }\n\n const child = draftState.byID[parentID][childType]\n\n if (!child) {\n return\n }\n\n draftState.byID[parentID][childType].push(childID)\n}\n","// Libraries\nimport {produce} from 'immer'\n\n// Types\nimport {\n Action,\n ADD_TASK,\n SET_TASKS,\n CLEAR_TASK,\n CLEAR_CURRENT_TASK,\n SET_RUNS,\n SET_TASK_OPTION,\n SET_ALL_TASK_OPTIONS,\n SET_NEW_SCRIPT,\n SET_CURRENT_SCRIPT,\n SET_CURRENT_TASK,\n SET_SEARCH_TERM,\n SET_SHOW_INACTIVE,\n SET_LOGS,\n EDIT_TASK,\n REMOVE_TASK,\n SET_CURRENT_TASKS_PAGE,\n} from 'src/tasks/actions/creators'\nimport {ResourceType, ResourceState, TaskSchedule, Task} from 'src/types'\n\n// Utils\nimport {initialState, defaultOptions} from 'src/tasks/reducers/helpers'\nimport {\n setResource,\n editResource,\n removeResource,\n addResource,\n} from 'src/resources/reducers/helpers'\n\ntype TasksState = ResourceState['tasks']\n\nexport default (\n state: TasksState = initialState(),\n action: Action\n): TasksState =>\n produce(state, draftState => {\n switch (action.type) {\n case SET_TASKS: {\n setResource(draftState, action, ResourceType.Tasks)\n\n return\n }\n\n case EDIT_TASK: {\n editResource(draftState, action, ResourceType.Tasks)\n\n return\n }\n\n case REMOVE_TASK: {\n removeResource(draftState, action)\n\n return\n }\n\n case ADD_TASK: {\n addResource(draftState, action, ResourceType.Tasks)\n\n return\n }\n\n case CLEAR_TASK: {\n draftState.taskOptions = defaultOptions\n draftState.currentScript = ''\n draftState.newScript = ''\n\n return\n }\n\n case CLEAR_CURRENT_TASK: {\n draftState.currentScript = ''\n draftState.currentTask = null\n\n return\n }\n\n case SET_ALL_TASK_OPTIONS: {\n const {schema} = action\n const {entities, result} = schema\n const {name, every, cron, orgID, offset} = entities.tasks[result]\n let taskScheduleType = TaskSchedule.interval\n\n if (cron) {\n taskScheduleType = TaskSchedule.cron\n }\n\n draftState.taskOptions = {\n ...state.taskOptions,\n name,\n cron,\n interval: every,\n orgID,\n taskScheduleType,\n offset,\n }\n\n return\n }\n\n case SET_TASK_OPTION: {\n const {key, value} = action\n\n draftState.taskOptions[`${key}`] = value\n\n return\n }\n\n case SET_NEW_SCRIPT: {\n draftState.newScript = action.script\n\n return\n }\n\n case SET_CURRENT_SCRIPT: {\n draftState.currentScript = action.script\n\n return\n }\n\n case SET_CURRENT_TASK: {\n const {schema} = action\n const {entities, result} = schema\n\n const task = entities.tasks[result]\n\n const currentScript = task.flux || ''\n\n draftState.currentScript = currentScript\n draftState.currentTask = task\n\n return\n }\n\n case SET_SEARCH_TERM: {\n const {searchTerm} = action\n\n draftState.searchTerm = searchTerm\n\n return\n }\n\n case SET_SHOW_INACTIVE: {\n draftState.showInactive = !state.showInactive\n\n return\n }\n\n case SET_RUNS: {\n const {runs, runStatus} = action\n\n draftState.runs = runs\n draftState.runStatus = runStatus\n\n return\n }\n\n case SET_LOGS: {\n draftState.logs = action.logs\n\n return\n }\n\n case SET_CURRENT_TASKS_PAGE: {\n draftState.currentPage = action.tasksPage\n\n return\n }\n }\n })\n","import {TimeRange} from 'src/types'\nimport {Action, ActionTypes} from 'src/dashboards/actions/ranges'\n\nexport type RangeState = {\n [contextID: string]: TimeRange\n}\n\nconst initialState: RangeState = {}\n\nexport default (\n state: RangeState = initialState,\n action: Action\n): RangeState => {\n switch (action.type) {\n case ActionTypes.DeleteTimeRange: {\n const {dashboardID} = action.payload\n const {[dashboardID]: _, ...filteredRanges} = state\n\n return filteredRanges\n }\n\n case ActionTypes.RetainRangesDashboardTimeV1: {\n const {dashboardIDs} = action.payload\n const ranges = {}\n for (const key in state) {\n if (dashboardIDs.includes(key)) {\n ranges[key] = state[key]\n }\n }\n return ranges\n }\n\n case ActionTypes.SetDashboardTimeRange: {\n const {dashboardID, timeRange} = action.payload\n return {...state, [dashboardID]: timeRange}\n }\n }\n\n return state\n}\n","// Libraries\nimport {produce} from 'immer'\n\n// Types\nimport {\n RemoteDataState,\n ResourceState,\n Dashboard,\n ResourceType,\n} from 'src/types'\n\n// Actions\nimport {\n Action,\n SET_DASHBOARD,\n SET_DASHBOARD_SORT,\n REMOVE_DASHBOARD,\n SET_DASHBOARDS,\n REMOVE_DASHBOARD_LABEL,\n EDIT_DASHBOARD,\n SET_DASHBOARDS_SEARCH_TERM,\n} from 'src/dashboards/actions/creators'\nimport {\n SET_CELLS,\n REMOVE_CELL,\n SET_CELL,\n Action as CellAction,\n} from 'src/cells/actions/creators'\nimport {SET_LABEL_ON_RESOURCE} from 'src/labels/actions/creators'\n\n// Utils\nimport {\n setResource,\n setResourceAtID,\n removeResource,\n editResource,\n setRelation,\n} from 'src/resources/reducers/helpers'\n\nimport {DEFAULT_DASHBOARD_SORT_OPTIONS} from 'src/dashboards/constants'\n\ntype DashboardsState = ResourceState['dashboards']\n\nconst initialState = (): DashboardsState => ({\n byID: {},\n allIDs: [],\n status: RemoteDataState.NotStarted,\n sortOptions: DEFAULT_DASHBOARD_SORT_OPTIONS,\n searchTerm: '',\n})\n\nexport const dashboardsReducer = (\n state: DashboardsState = initialState(),\n action: Action | CellAction\n): DashboardsState => {\n return produce(state, draftState => {\n switch (action.type) {\n case SET_DASHBOARDS: {\n setResource(draftState, action, ResourceType.Dashboards)\n\n return\n }\n\n case REMOVE_DASHBOARD: {\n removeResource(draftState, action)\n\n return\n }\n\n case SET_DASHBOARD: {\n setResourceAtID(draftState, action, ResourceType.Dashboards)\n\n return\n }\n\n case SET_DASHBOARD_SORT: {\n const {sortOptions} = action\n\n draftState.sortOptions = sortOptions\n\n return\n }\n\n case EDIT_DASHBOARD: {\n editResource(draftState, action, ResourceType.Dashboards)\n\n return\n }\n\n case REMOVE_CELL: {\n const {dashboardID, id} = action\n\n const {cells} = draftState.byID[dashboardID]\n\n draftState.byID[dashboardID].cells = cells.filter(cID => cID !== id)\n\n return\n }\n\n case SET_CELL: {\n const {schema} = action\n\n const cellID = schema.result\n const cell = schema.entities.cells[cellID]\n const dashboards = draftState.byID[cell.dashboardID]\n\n if (dashboards?.cells.includes(cellID)) {\n return\n }\n\n if (draftState.byID[cell.dashboardID]) {\n draftState.byID[cell.dashboardID].cells.push(cellID)\n }\n\n return\n }\n\n case SET_CELLS: {\n const {dashboardID, schema} = action\n\n const cellIDs = schema && schema.result\n\n if (!cellIDs) {\n return\n }\n\n draftState.byID[dashboardID].cells = cellIDs\n\n return\n }\n\n case SET_LABEL_ON_RESOURCE: {\n const {resourceID, schema} = action\n const labelID = schema.result\n\n setRelation(\n draftState,\n ResourceType.Labels,\n labelID,\n resourceID\n )\n\n return\n }\n\n case REMOVE_DASHBOARD_LABEL: {\n const {dashboardID, labelID} = action\n\n const {labels} = draftState.byID[dashboardID]\n\n draftState.byID[dashboardID].labels = labels.filter(\n label => label !== labelID\n )\n\n return\n }\n\n case SET_DASHBOARDS_SEARCH_TERM: {\n const {searchTerm} = action\n draftState.searchTerm = searchTerm\n\n return\n }\n }\n })\n}\n","// Libraries\nimport {produce} from 'immer'\nimport {get} from 'lodash'\n\n// Actions\nimport {\n SET_CELLS,\n REMOVE_CELL,\n SET_CELL,\n Action,\n} from 'src/cells/actions/creators'\nimport {\n SET_DASHBOARD,\n Action as DashboardAction,\n} from 'src/dashboards/actions/creators'\nimport {SET_VIEWS_AND_CELLS} from 'src/views/actions/creators'\n\n// Types\nimport {Cell, ResourceState, RemoteDataState} from 'src/types'\n\ntype CellsState = ResourceState['cells']\n\nconst initialState = () => ({\n byID: {},\n status: RemoteDataState.NotStarted,\n})\n\nexport const cellsReducer = (\n state: CellsState = initialState(),\n action: Action | DashboardAction\n) =>\n produce(state, draftState => {\n switch (action.type) {\n case SET_DASHBOARD: {\n const {schema, status} = action\n\n draftState.status = status\n\n if (get(schema, ['entities', 'cells'])) {\n draftState.byID = schema.entities.cells\n }\n\n return\n }\n\n case SET_CELLS: {\n const {status, schema} = action\n\n draftState.status = status\n\n if (get(schema, ['entities', 'cells'])) {\n draftState.byID = schema.entities['cells']\n }\n\n return\n }\n\n case SET_VIEWS_AND_CELLS: {\n const {status, cellsArray} = action\n\n cellsArray.forEach(cellSchema => {\n draftState.status = status\n\n if (get(cellSchema, ['entities', 'cells'])) {\n draftState.byID = cellSchema.entities['cells']\n }\n })\n\n return\n }\n\n case SET_CELL: {\n const {id, schema, status} = action\n\n const cell: Cell = get(schema, ['entities', 'cells', id])\n const cellExists = !!draftState.byID[id]\n\n if (cell || !cellExists) {\n draftState.byID[id] = {...cell, status}\n } else {\n draftState.byID[id].status = status\n }\n\n return\n }\n\n case REMOVE_CELL: {\n delete draftState.byID[action.id]\n\n return\n }\n }\n })\n","// Libraries\nimport {produce} from 'immer'\n\n// Types\nimport {\n REMOVE_VIEW,\n RESET_VIEWS,\n SET_VIEW,\n SET_VIEWS,\n SET_VIEWS_AND_CELLS,\n Action,\n} from 'src/views/actions/creators'\nimport {SET_DASHBOARD} from 'src/dashboards/actions/creators'\nimport {View, RemoteDataState, ResourceState, ResourceType} from 'src/types'\n\n// Helpers\nimport {\n setResource,\n setResourceAtID,\n removeResource,\n} from 'src/resources/reducers/helpers'\n\nexport type ViewsState = ResourceState['views']\n\nconst initialState = (): ViewsState => ({\n status: RemoteDataState.NotStarted,\n byID: {},\n allIDs: [],\n})\n\nconst viewsReducer = (\n state: ViewsState = initialState(),\n action: Action\n): ViewsState =>\n produce(state, draftState => {\n switch (action.type) {\n case SET_DASHBOARD: {\n setResource(draftState, action, ResourceType.Views)\n }\n\n case SET_VIEWS: {\n setResource(draftState, action, ResourceType.Views)\n\n return\n }\n case SET_VIEWS_AND_CELLS: {\n const {viewsArray} = action\n viewsArray.forEach(view => {\n setResource(draftState, view, ResourceType.Views)\n })\n\n return\n }\n case SET_VIEW: {\n setResourceAtID(draftState, action, ResourceType.Views)\n\n return\n }\n case RESET_VIEWS: {\n return initialState()\n }\n case REMOVE_VIEW: {\n removeResource(draftState, action)\n\n return\n }\n }\n })\n\nexport default viewsReducer\n","// Libraries\nimport {produce} from 'immer'\n\n// Types\nimport {\n SET_ORGS,\n SET_ORG,\n ADD_ORG,\n REMOVE_ORG,\n Action,\n EDIT_ORG,\n} from 'src/organizations/actions/creators'\nimport {\n ResourceState,\n Organization,\n ResourceType,\n RemoteDataState,\n} from 'src/types'\n\n// Utils\nimport {\n setResource,\n addResource,\n removeResource,\n editResource,\n} from 'src/resources/reducers/helpers'\n\nconst {Orgs} = ResourceType\ntype OrgsState = ResourceState['orgs']\n\nconst initialState = (): OrgsState => ({\n byID: {},\n allIDs: [],\n status: RemoteDataState.NotStarted,\n org: null,\n})\n\nexport const orgsReducer = (\n state: OrgsState = initialState(),\n action: Action\n) =>\n produce(state, draftState => {\n switch (action.type) {\n case SET_ORGS: {\n setResource(draftState, action, Orgs)\n\n return\n }\n case ADD_ORG: {\n addResource(draftState, action, Orgs)\n\n return\n }\n\n case REMOVE_ORG: {\n removeResource(draftState, action)\n\n return\n }\n\n case EDIT_ORG: {\n editResource(draftState, action, Orgs)\n\n // NOTE: this is a normalization issue because the current org\n // is being updated, but the selected org object isn't being\n // updated. Since we have only one org at a time in this app\n // i've taken some liberties here\n if (action.schema.result === draftState.org.id) {\n draftState.org = action.schema.entities.orgs[action.schema.result]\n }\n\n return\n }\n\n case SET_ORG: {\n draftState.org = action.org\n\n return\n }\n }\n })\n","// Libraries\nimport {produce} from 'immer'\n\n// Types\nimport {ActionTypes, Actions} from 'src/overlays/actions/overlays'\nimport {OverlayParams} from 'src/types'\n\nexport type OverlayID =\n | 'add-note'\n | 'edit-note'\n | 'add-master-token'\n | 'access-token'\n | 'add-custom-token'\n | 'add-token'\n | 'telegraf-config'\n | 'telegraf-output'\n | 'switch-organizations'\n | 'create-bucket'\n | 'asset-limit'\n | 'rate-limit'\n | 'write-limit'\n | 'create-annotation-stream'\n | 'update-annotation-stream'\n | 'add-annotation'\n | 'edit-annotation'\n | 'toggle-auto-refresh'\n | 'cell-copy-overlay'\n | 'bucket-schema-show'\n\nexport interface OverlayState {\n id: OverlayID | null\n params: OverlayParams\n onClose: () => void\n}\n\nconst nullParams = {}\n\nconst defaultState: OverlayState = {\n id: null,\n params: nullParams,\n onClose: () => {},\n}\n\nexport const overlaysReducer = (\n state = defaultState,\n action: Actions\n): OverlayState =>\n produce(state, draftState => {\n switch (action.type) {\n case ActionTypes.ShowOverlay: {\n const {overlayID, overlayParams, onClose} = action.payload\n draftState.id = overlayID\n draftState.params = overlayParams\n draftState.onClose = onClose\n return\n }\n case ActionTypes.DismissOverlay: {\n draftState.id = null\n draftState.params = nullParams\n draftState.onClose = () => {}\n return\n }\n case ActionTypes.SetOverlayParams: {\n const {overlayParams} = action.payload\n draftState.params = overlayParams\n return\n }\n }\n })\n\nexport default overlaysReducer\n","// Constants\nimport {StepStatus} from 'src/clockface/constants/wizard'\n\n// Types\nimport {Action} from 'src/onboarding/actions'\nimport {OnboardingRequest} from 'src/client'\n\nexport interface OnboardingState {\n stepStatuses: StepStatus[]\n setupParams: OnboardingRequest\n orgID: string\n bucketID: string\n}\n\nconst INITIAL_STATE: OnboardingState = {\n stepStatuses: new Array(3).fill(StepStatus.Incomplete),\n setupParams: null,\n orgID: '',\n bucketID: '',\n}\n\nexport default (state = INITIAL_STATE, action: Action): OnboardingState => {\n switch (action.type) {\n case 'SET_SETUP_PARAMS':\n return {...state, setupParams: action.payload.setupParams}\n case 'SET_STEP_STATUS':\n const stepStatuses = [...state.stepStatuses]\n stepStatuses[action.payload.index] = action.payload.status\n return {...state, stepStatuses}\n case 'SET_ORG_ID':\n return {...state, orgID: action.payload.orgID}\n case 'SET_ONBOARDING_BUCKET_ID':\n return {...state, bucketID: action.payload.bucketID}\n default:\n return state\n }\n}\n","import {Action} from 'src/dashboards/actions/notes'\nimport {NoteEditorMode} from 'src/types/dashboards'\n\nexport interface NoteEditorState {\n mode: NoteEditorMode\n note: string\n showNoteWhenEmpty: boolean\n isPreviewing: boolean\n viewID?: string\n}\n\nconst initialState = (): NoteEditorState => ({\n mode: NoteEditorMode.Adding,\n note: '',\n showNoteWhenEmpty: false,\n isPreviewing: false,\n})\n\nconst noteEditorReducer = (\n state: NoteEditorState = initialState(),\n action: Action\n) => {\n switch (action.type) {\n case 'RESET_NOTE_STATE': {\n return initialState()\n }\n case 'SET_NOTE_STATE': {\n const initialState = action.payload\n\n return {\n ...state,\n ...initialState,\n isPreviewing: false,\n }\n }\n\n case 'CLOSE_NOTE_EDITOR': {\n return {...state, overlayVisible: false}\n }\n\n case 'SET_IS_PREVIEWING': {\n const {isPreviewing} = action.payload\n\n return {...state, isPreviewing}\n }\n\n case 'TOGGLE_SHOW_NOTE_WHEN_EMPTY': {\n const {showNoteWhenEmpty} = state\n\n return {...state, showNoteWhenEmpty: !showNoteWhenEmpty}\n }\n\n case 'SET_NOTE': {\n const {note} = action.payload\n\n return {...state, note}\n }\n }\n\n return state\n}\n\nexport default noteEditorReducer\n","// Libraries\nimport {uniqBy, sortBy, get, isEmpty} from 'lodash'\n\n// Utils\nimport {\n createNewPlugin,\n updateConfigFields,\n isPluginInBundle,\n isPluginUniqueToBundle,\n getConfigFields,\n} from 'src/dataLoaders/utils/pluginConfigs'\nimport {getDeep} from 'src/utils/wrappers'\nimport {validateURI} from 'src/shared/utils/validateURI'\n\n// Types\nimport {Action} from 'src/dataLoaders/actions/dataLoaders'\nimport {\n DataLoaderType,\n DataLoadersState,\n ConfigurationState,\n ConfigFieldType,\n Plugin,\n} from 'src/types/dataLoaders'\nimport {QUICKSTART_SCRAPER_TARGET_URL} from 'src/dataLoaders/constants/pluginConfigs'\n\nexport const INITIAL_STATE: DataLoadersState = {\n telegrafPlugins: [],\n type: DataLoaderType.Empty,\n telegrafConfigID: null,\n pluginBundles: [],\n scraperTarget: {\n bucket: '',\n url: QUICKSTART_SCRAPER_TARGET_URL,\n name: 'Name this Scraper Target',\n },\n telegrafConfigName: 'Name this Configuration',\n telegrafConfigDescription: '',\n token: '',\n}\n\nexport default (state = INITIAL_STATE, action: Action): DataLoadersState => {\n switch (action.type) {\n case 'CLEAR_DATA_LOADERS':\n return {...INITIAL_STATE}\n case 'SET_DATA_LOADERS_TYPE':\n return {\n ...state,\n type: action.payload.type,\n }\n case 'SET_TELEGRAF_CONFIG_ID':\n return {\n ...state,\n telegrafConfigID: action.payload.id,\n }\n case 'ADD_PLUGIN_BUNDLE':\n return {\n ...state,\n pluginBundles: [...state.pluginBundles, action.payload.bundle],\n }\n case 'REMOVE_PLUGIN_BUNDLE':\n return {\n ...state,\n pluginBundles: state.pluginBundles.filter(\n b => b !== action.payload.bundle\n ),\n }\n case 'REMOVE_BUNDLE_PLUGINS':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.filter(tp => {\n if (isPluginInBundle(tp.name, action.payload.bundle)) {\n return !isPluginUniqueToBundle(\n tp.name,\n action.payload.bundle,\n state.pluginBundles\n )\n }\n\n return true\n }),\n }\n case 'ADD_TELEGRAF_PLUGINS':\n return {\n ...state,\n telegrafPlugins: sortBy(\n uniqBy(\n [...state.telegrafPlugins, ...action.payload.telegrafPlugins],\n 'name'\n ),\n ['name']\n ),\n }\n\n case 'ADD_TELEGRAF_PLUGINS_telegrafUiRefresh':\n const telegrafPlugins = [action.payload.telegrafPlugins]\n return {\n ...state,\n telegrafPlugins,\n }\n\n case 'UPDATE_TELEGRAF_PLUGIN':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.map(tp => {\n if (tp.name === action.payload.plugin.name) {\n return {\n ...tp,\n plugin: action.payload.plugin,\n }\n }\n\n return tp\n }),\n }\n case 'UPDATE_TELEGRAF_PLUGIN_CONFIG':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.map(tp => {\n if (tp.name === action.payload.name) {\n const plugin = get(tp, 'plugin', createNewPlugin(tp))\n\n return {\n ...tp,\n plugin: updateConfigFields(\n plugin,\n action.payload.field,\n action.payload.value\n ),\n }\n }\n return tp\n }),\n }\n case 'ADD_TELEGRAF_PLUGIN_CONFIG_VALUE':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.map(tp => {\n if (tp.name === action.payload.pluginName) {\n const plugin = get(tp, 'plugin', createNewPlugin(tp))\n\n const config = get(plugin, ['config', action.payload.fieldName], [])\n\n const updatedConfigFieldValue: string[] = [\n ...config,\n action.payload.value,\n ]\n\n return {\n ...tp,\n plugin: updateConfigFields(\n plugin,\n action.payload.fieldName,\n updatedConfigFieldValue\n ),\n }\n }\n return tp\n }),\n }\n case 'REMOVE_TELEGRAF_PLUGIN_CONFIG_VALUE':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.map(tp => {\n if (tp.name === action.payload.pluginName) {\n const plugin = get(tp, 'plugin', createNewPlugin(tp))\n\n const configFieldValues = get(\n plugin,\n `config.${action.payload.fieldName}`,\n []\n )\n const filteredConfigFieldValue = configFieldValues.filter(\n v => v !== action.payload.value\n )\n\n return {\n ...tp,\n plugin: updateConfigFields(\n plugin,\n action.payload.fieldName,\n filteredConfigFieldValue\n ),\n }\n }\n return tp\n }),\n }\n case 'SET_TELEGRAF_PLUGIN_CONFIG_VALUE':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.map(tp => {\n if (tp.name === action.payload.pluginName) {\n const plugin = get(tp, 'plugin', createNewPlugin(tp))\n const configValues = get(\n plugin,\n `config.${action.payload.field}`,\n []\n )\n configValues[action.payload.valueIndex] = action.payload.value\n return {\n ...tp,\n plugin: updateConfigFields(plugin, action.payload.field, [\n ...configValues,\n ]),\n }\n }\n return tp\n }),\n }\n case 'SET_ACTIVE_TELEGRAF_PLUGIN':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.map(tp => {\n if (tp.name === action.payload.telegrafPlugin) {\n return {...tp, active: true}\n }\n return {...tp, active: false}\n }),\n }\n case 'SET_PLUGIN_CONFIGURATION_STATE':\n return {\n ...state,\n telegrafPlugins: state.telegrafPlugins.map(tp => {\n const name = get(tp, 'name')\n if (name === action.payload.telegrafPlugin) {\n const configFields = getConfigFields(name)\n if (!configFields) {\n return {...tp, configured: ConfigurationState.Configured}\n }\n\n const plugin = getDeep(tp, 'plugin', createNewPlugin(tp))\n const config = get(plugin, 'config', {})\n\n let isValidConfig = true\n\n Object.entries(configFields).forEach(\n ([fieldName, {type: fieldType, isRequired}]) => {\n if (isRequired) {\n const fieldValue = config[fieldName]\n\n switch (fieldType) {\n case ConfigFieldType.Uri:\n isValidConfig = validateURI(fieldValue as string)\n break\n case ConfigFieldType.String:\n isValidConfig = (fieldValue as string) !== ''\n break\n case ConfigFieldType.StringArray:\n isValidConfig = !!(fieldValue as string[]).length\n break\n case ConfigFieldType.UriArray:\n isValidConfig =\n !!(fieldValue as string[]).length &&\n !fieldValue.find(uri => !validateURI(uri))\n break\n }\n }\n }\n )\n\n if (!isValidConfig || isEmpty(config)) {\n return {\n ...tp,\n configured: ConfigurationState.InvalidConfiguration,\n }\n } else {\n return {...tp, configured: ConfigurationState.Configured}\n }\n }\n\n return {...tp}\n }),\n }\n case 'SET_TELEGRAF_CONFIG_NAME':\n return {\n ...state,\n telegrafConfigName: action.payload.name,\n }\n case 'SET_TELEGRAF_CONFIG_DESCRIPTION':\n return {\n ...state,\n telegrafConfigDescription: action.payload.description,\n }\n case 'SET_SCRAPER_TARGET_NAME':\n const {name} = action.payload\n return {\n ...state,\n scraperTarget: {...state.scraperTarget, name},\n }\n case 'SET_SCRAPER_TARGET_BUCKET':\n const {bucket} = action.payload\n return {\n ...state,\n scraperTarget: {...state.scraperTarget, bucket},\n }\n case 'SET_SCRAPER_TARGET_URL':\n const {url} = action.payload\n return {\n ...state,\n scraperTarget: {\n ...state.scraperTarget,\n url,\n },\n }\n case 'SET_SCRAPER_TARGET_ID':\n const {id} = action.payload\n return {\n ...state,\n scraperTarget: {\n ...state.scraperTarget,\n id,\n },\n }\n case 'SET_TOKEN':\n return {\n ...state,\n token: action.payload.token,\n }\n default:\n return state\n }\n}\n","// Types\nimport {Action} from 'src/dataLoaders/actions/steps'\nimport {Substep} from 'src/types/dataLoaders'\n\nexport interface DataLoadersStepsState {\n currentStep: number\n substep?: Substep\n orgID: string\n bucketID: string\n org: string\n bucket: string\n}\n\nconst INITIAL_STATE: DataLoadersStepsState = {\n org: '',\n bucket: '',\n orgID: '',\n bucketID: '',\n currentStep: 0,\n}\n\nexport default (\n state = INITIAL_STATE,\n action: Action\n): DataLoadersStepsState => {\n switch (action.type) {\n case 'CLEAR_STEPS':\n return {...INITIAL_STATE}\n case 'INCREMENT_CURRENT_STEP_INDEX':\n return {...state, currentStep: state.currentStep + 1}\n case 'DECREMENT_CURRENT_STEP_INDEX':\n return {...state, currentStep: state.currentStep - 1}\n case 'SET_CURRENT_STEP_INDEX':\n return {...state, currentStep: action.payload.index}\n case 'SET_SUBSTEP_INDEX':\n return {\n ...state,\n currentStep: action.payload.stepIndex,\n substep: action.payload.substep,\n }\n case 'SET_BUCKET_INFO':\n return {...state, ...action.payload}\n case 'SET_BUCKET_ID':\n return {...state, bucketID: action.payload.bucketID}\n default:\n return state\n }\n}\n","// Libraries\nimport {combineReducers} from 'redux'\n\n// Reducers\nimport dataLoadersReducer from 'src/dataLoaders/reducers/dataLoaders'\nimport {DataLoadersState} from 'src/types/dataLoaders'\nimport stepsReducer, {\n DataLoadersStepsState,\n} from 'src/dataLoaders/reducers/steps'\n\nexport interface DataLoadingState {\n steps: DataLoadersStepsState\n dataLoaders: DataLoadersState\n}\n\nexport default combineReducers({\n steps: stepsReducer,\n dataLoaders: dataLoadersReducer,\n})\n","// Libraries\nimport {produce} from 'immer'\n\n// Types\nimport {VariableEditorState} from 'src/types'\nimport {\n EditorAction,\n CLEAR_VARIABLE_EDITOR,\n CHANGE_VARIABLE_EDITOR_TYPE,\n UPDATE_VARIABLE_EDITOR_NAME,\n UPDATE_VARIABLE_EDITOR_QUERY,\n UPDATE_VARIABLE_EDITOR_MAP,\n UPDATE_VARIABLE_EDITOR_CONSTANT,\n} from 'src/variables/actions/creators'\n\nexport const initialEditorState = (): VariableEditorState => ({\n name: '',\n selected: 'query',\n argsQuery: null,\n argsMap: null,\n argsConstant: null,\n})\n\nexport const variableEditorReducer = (\n state: VariableEditorState = initialEditorState(),\n action: EditorAction\n): VariableEditorState =>\n produce(state, draftState => {\n switch (action.type) {\n case CLEAR_VARIABLE_EDITOR: {\n return initialEditorState()\n }\n case CHANGE_VARIABLE_EDITOR_TYPE: {\n draftState.selected = action.editorType\n return\n }\n case UPDATE_VARIABLE_EDITOR_NAME: {\n draftState.name = action.name\n return\n }\n case UPDATE_VARIABLE_EDITOR_QUERY: {\n draftState.argsQuery = action.payload\n return\n }\n case UPDATE_VARIABLE_EDITOR_MAP: {\n draftState.argsMap = action.payload\n return\n }\n case UPDATE_VARIABLE_EDITOR_CONSTANT: {\n draftState.argsConstant = action.payload\n return\n }\n default:\n return\n }\n })\n","// Libraries\nimport {produce} from 'immer'\nimport {get} from 'lodash'\n\n// Types\nimport {\n Variable,\n RemoteDataState,\n VariablesState,\n ResourceType,\n} from 'src/types'\nimport {\n Action,\n SET_VARIABLES,\n SET_VARIABLE,\n REMOVE_VARIABLE,\n MOVE_VARIABLE,\n SELECT_VARIABLE_VALUE,\n} from 'src/variables/actions/creators'\n\n// Utils\nimport {setResource, removeResource} from 'src/resources/reducers/helpers'\n\nexport const initialState = (): VariablesState => ({\n status: RemoteDataState.NotStarted,\n byID: {},\n allIDs: [],\n values: {},\n})\n\nexport const variablesReducer = (\n state: VariablesState = initialState(),\n action: Action\n): VariablesState =>\n produce(state, draftState => {\n switch (action.type) {\n case SET_VARIABLES: {\n setResource(draftState, action, ResourceType.Variables)\n\n return\n }\n\n case SET_VARIABLE: {\n const {id, status, schema} = action\n\n const variable = get(schema, ['entities', 'variables', id])\n const variableExists = !!draftState.byID[id]\n\n if (variable) {\n draftState.byID[id] = {...variable, status}\n\n if (!variableExists) {\n draftState.allIDs.push(id)\n }\n } else {\n draftState.byID[id].status = status\n }\n\n return\n }\n\n case REMOVE_VARIABLE: {\n removeResource(draftState, action)\n\n return\n }\n\n case SELECT_VARIABLE_VALUE: {\n const {contextID, variableID, selectedValue} = action\n\n if (!draftState.values[contextID]) {\n draftState.values[contextID] = {\n status: RemoteDataState.Done,\n order: draftState.allIDs,\n values: {},\n }\n }\n\n if (!draftState.values[contextID].values[variableID]) {\n draftState.values[contextID].values[variableID] = {\n selected: [selectedValue],\n }\n\n return\n }\n\n draftState.values[contextID].values[variableID].selected = [\n selectedValue,\n ]\n\n return\n }\n\n case MOVE_VARIABLE: {\n const {contextID, newVariableOrder} = action\n\n draftState.values[contextID] = {\n ...(draftState.values[contextID] || {\n status: RemoteDataState.NotStarted,\n values: {},\n }),\n order: newVariableOrder,\n }\n\n return\n }\n }\n })\n\nexport {variableEditorReducer} from 'src/variables/reducers/editor'\n","// Libraries\nimport {produce} from 'immer'\n\n// Types\nimport {RemoteDataState, ResourceState, Label, ResourceType} from 'src/types'\nimport {\n Action,\n SET_LABELS,\n SET_LABEL,\n REMOVE_LABEL,\n} from 'src/labels/actions/creators'\n\n// Utils\nimport {\n setResource,\n setResourceAtID,\n removeResource,\n} from 'src/resources/reducers/helpers'\n\ntype LabelsState = ResourceState['labels']\n\nexport const initialState = (): LabelsState => ({\n status: RemoteDataState.NotStarted,\n byID: {},\n allIDs: [],\n})\n\nexport const labelsReducer = (\n state: LabelsState = initialState(),\n action: Action\n): LabelsState =>\n produce(state, draftState => {\n switch (action.type) {\n case SET_LABELS: {\n setResource