This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch omnibar in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/omnibar by this push: new fbff762 move code into omni container fbff762 is described below commit fbff762bd3a04cbf276701756392f653ae32b5e1 Author: hughhhh <hmi...@lyft.com> AuthorDate: Tue Jan 22 12:38:31 2019 -0800 move code into omni container --- superset/assets/src/components/OmniContainer.jsx | 55 ++++++++++++++++++++++ .../src/dashboard/components/DashboardBuilder.jsx | 16 +------ 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/superset/assets/src/components/OmniContainer.jsx b/superset/assets/src/components/OmniContainer.jsx new file mode 100644 index 0000000..9947f0d --- /dev/null +++ b/superset/assets/src/components/OmniContainer.jsx @@ -0,0 +1,55 @@ +/** + * 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'; +import PropTypes from 'prop-types'; +import Select from 'react-select'; +import { SupersetClient } from '@superset-ui/connection'; + +import Omnibar from 'omnibar'; + +function MathExtension(query) { + SupersetClient.get({ + endpoint: '/dashboardasync/api/read?_oc_DashboardModelViewAsync=changed_on&_od_DashboardModelViewAsync=desc', + }) + .then(({ json }) => { + console.log(json.result); + }) + .catch(() => { + console.log('An error occurred while fethching Dashboards'); + }); + try { + return [ + { + title: query, + subtitle: "Calculate: " + query + } + ]; + } catch (err) { + return []; + } +} + +export default class OmniContianer extends React.Component { + render() { + return <Omnibar placeholder="Enter an expression" extensions={[MathExtension]} />; + } +} + +OmniContianer.propTypes = {}; +OmniContianer.defaultProps = {}; diff --git a/superset/assets/src/dashboard/components/DashboardBuilder.jsx b/superset/assets/src/dashboard/components/DashboardBuilder.jsx index d30b71f..0c83097 100644 --- a/superset/assets/src/dashboard/components/DashboardBuilder.jsx +++ b/superset/assets/src/dashboard/components/DashboardBuilder.jsx @@ -35,19 +35,7 @@ import DashboardComponent from '../containers/DashboardComponent'; import ToastPresenter from '../../messageToasts/containers/ToastPresenter'; import WithPopoverMenu from './menu/WithPopoverMenu'; -import Omnibar from 'omnibar'; -function MathExtension(query) { - try { - return [ - { - title: query, - subtitle: "Calculate: " + query - } - ]; - } catch (err) { - return []; - } -} +import OmniContianer from '../../components/OmniContainer'; import getDragDropManager from '../util/getDragDropManager'; @@ -130,7 +118,7 @@ class DashboardBuilder extends React.Component { className={cx('dashboard', editMode && 'dashboard--editing')} > <div style={{paddingBottom: 500}}> - <Omnibar placeholder="Enter an expression" extensions={[MathExtension]} /> + <OmniContianer/> </div> <Sticky> {({ style }) => (