From 2fec5c7577caa09e83333861763992c00fb2d078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Dec 2018 12:27:43 +0100 Subject: [PATCH] Grafana ui lib is starting to work --- packages/grafana-ui/package.json | 3 +-- .../DeleteButton/DeleteButton.test.tsx | 0 .../components/DeleteButton/DeleteButton.tsx | 14 +++++----- packages/grafana-ui/src/components/index.ts | 1 + packages/grafana-ui/src/index.ts | 27 +------------------ packages/grafana-ui/src/other.ts | 5 ---- packages/grafana-ui/types/index.ts | 4 --- public/app/features/api-keys/ApiKeysPage.tsx | 4 +-- .../dashboard/dashgrid/DashboardGrid.tsx | 3 --- .../dashboard/dashgrid/VisualizationTab.tsx | 1 - public/app/features/plugins/plugin_loader.ts | 2 +- public/app/features/teams/TeamList.tsx | 4 +-- public/app/features/teams/TeamMembers.tsx | 4 +-- 13 files changed, 17 insertions(+), 55 deletions(-) rename {public/app/core => packages/grafana-ui/src}/components/DeleteButton/DeleteButton.test.tsx (100%) rename {public/app/core => packages/grafana-ui/src}/components/DeleteButton/DeleteButton.tsx (81%) create mode 100644 packages/grafana-ui/src/components/index.ts delete mode 100644 packages/grafana-ui/src/other.ts delete mode 100644 packages/grafana-ui/types/index.ts diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json index 73eff40d3d7..1466e0de80a 100644 --- a/packages/grafana-ui/package.json +++ b/packages/grafana-ui/package.json @@ -2,8 +2,7 @@ "name": "@grafana/ui", "version": "1.0.0", "description": "", - "main": "dist/index.js", - "types": "dist/types", + "main": "src/index.ts", "scripts": { "test": "tsc --noEmit" }, diff --git a/public/app/core/components/DeleteButton/DeleteButton.test.tsx b/packages/grafana-ui/src/components/DeleteButton/DeleteButton.test.tsx similarity index 100% rename from public/app/core/components/DeleteButton/DeleteButton.test.tsx rename to packages/grafana-ui/src/components/DeleteButton/DeleteButton.test.tsx diff --git a/public/app/core/components/DeleteButton/DeleteButton.tsx b/packages/grafana-ui/src/components/DeleteButton/DeleteButton.tsx similarity index 81% rename from public/app/core/components/DeleteButton/DeleteButton.tsx rename to packages/grafana-ui/src/components/DeleteButton/DeleteButton.tsx index a83ce6097ad..de2db07aa04 100644 --- a/public/app/core/components/DeleteButton/DeleteButton.tsx +++ b/packages/grafana-ui/src/components/DeleteButton/DeleteButton.tsx @@ -1,15 +1,15 @@ import React, { PureComponent } from 'react'; -export interface DeleteButtonProps { - onConfirmDelete(); +interface Props { + onConfirm(); } -export interface DeleteButtonStates { +interface State { showConfirm: boolean; } -export default class DeleteButton extends PureComponent { - state: DeleteButtonStates = { +export class DeleteButton extends PureComponent { + state: State = { showConfirm: false, }; @@ -33,7 +33,7 @@ export default class DeleteButton extends PureComponent Cancel - + Confirm Delete diff --git a/packages/grafana-ui/src/components/index.ts b/packages/grafana-ui/src/components/index.ts new file mode 100644 index 00000000000..b57b9bcfdb7 --- /dev/null +++ b/packages/grafana-ui/src/components/index.ts @@ -0,0 +1 @@ +export { DeleteButton } from './DeleteButton/DeleteButton'; diff --git a/packages/grafana-ui/src/index.ts b/packages/grafana-ui/src/index.ts index 015fff3bca8..07635cbbc8e 100644 --- a/packages/grafana-ui/src/index.ts +++ b/packages/grafana-ui/src/index.ts @@ -1,26 +1 @@ -export { Other } from './other'; -import { TimeSeries } from '../types'; - -export class Google { - data: TimeSeries; - - hello() { - return 'hello'; - } -} - -class Singleton { - constructor(private state: string) {} - - hello() { - return this.state; - } - - change() { - this.state = 'mod2'; - } -} - -const singletonSrv = new Singleton('hello'); - -export { singletonSrv }; +export * from './components'; diff --git a/packages/grafana-ui/src/other.ts b/packages/grafana-ui/src/other.ts deleted file mode 100644 index cbc1390dd05..00000000000 --- a/packages/grafana-ui/src/other.ts +++ /dev/null @@ -1,5 +0,0 @@ -export class Other { - static hello() { - return "hello from other"; - } -} diff --git a/packages/grafana-ui/types/index.ts b/packages/grafana-ui/types/index.ts deleted file mode 100644 index ed86915b4cf..00000000000 --- a/packages/grafana-ui/types/index.ts +++ /dev/null @@ -1,4 +0,0 @@ - -export interface TimeSeries { - name: string; -} diff --git a/public/app/features/api-keys/ApiKeysPage.tsx b/public/app/features/api-keys/ApiKeysPage.tsx index d2aa1f24c57..e14873fa9f6 100644 --- a/public/app/features/api-keys/ApiKeysPage.tsx +++ b/public/app/features/api-keys/ApiKeysPage.tsx @@ -13,7 +13,7 @@ import ApiKeysAddedModal from './ApiKeysAddedModal'; import config from 'app/core/config'; import appEvents from 'app/core/app_events'; import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; -import DeleteButton from 'app/core/components/DeleteButton/DeleteButton'; +import { DeleteButton } from '@grafana/ui'; export interface Props { navModel: NavModel; @@ -224,7 +224,7 @@ export class ApiKeysPage extends PureComponent { {key.name} {key.role} - this.onDeleteApiKey(key)} /> + this.onDeleteApiKey(key)} /> ); diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx index ad15eca8654..a401505b787 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx @@ -7,9 +7,6 @@ import { DashboardModel } from '../dashboard_model'; import { PanelModel } from '../panel_model'; import classNames from 'classnames'; import sizeMe from 'react-sizeme'; -import { Google } from 'grafana-ui'; - -console.log(Google); let lastGridWidth = 1200; let ignoreNextWidthChange = false; diff --git a/public/app/features/dashboard/dashgrid/VisualizationTab.tsx b/public/app/features/dashboard/dashgrid/VisualizationTab.tsx index 53364502383..42d9bf6a6eb 100644 --- a/public/app/features/dashboard/dashgrid/VisualizationTab.tsx +++ b/public/app/features/dashboard/dashgrid/VisualizationTab.tsx @@ -15,7 +15,6 @@ import { PanelOptionSection } from './PanelOptionSection'; import { PanelModel } from '../panel_model'; import { DashboardModel } from '../dashboard_model'; import { PanelPlugin } from 'app/types/plugins'; -import { TimeSeries } from '@grafana/ui/types'; interface Props { panel: PanelModel; diff --git a/public/app/features/plugins/plugin_loader.ts b/public/app/features/plugins/plugin_loader.ts index 2c394cb77e7..775cf9507fe 100644 --- a/public/app/features/plugins/plugin_loader.ts +++ b/public/app/features/plugins/plugin_loader.ts @@ -72,7 +72,7 @@ function exposeToPlugin(name: string, component: any) { }); } -exposeToPlugin('grafana-ui', grafanaUI); +exposeToPlugin('@grafana/ui', grafanaUI); exposeToPlugin('lodash', _); exposeToPlugin('moment', moment); exposeToPlugin('jquery', jquery); diff --git a/public/app/features/teams/TeamList.tsx b/public/app/features/teams/TeamList.tsx index d8e12e338e9..d1551d6baa6 100644 --- a/public/app/features/teams/TeamList.tsx +++ b/public/app/features/teams/TeamList.tsx @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import { hot } from 'react-hot-loader'; import PageHeader from 'app/core/components/PageHeader/PageHeader'; -import DeleteButton from 'app/core/components/DeleteButton/DeleteButton'; +import { DeleteButton } from '@grafana/ui'; import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; import PageLoader from 'app/core/components/PageLoader/PageLoader'; import { NavModel, Team } from '../../types'; @@ -58,7 +58,7 @@ export class TeamList extends PureComponent { {team.memberCount} - this.deleteTeam(team)} /> + this.deleteTeam(team)} /> ); diff --git a/public/app/features/teams/TeamMembers.tsx b/public/app/features/teams/TeamMembers.tsx index 0e20f4be664..a25f1786a5b 100644 --- a/public/app/features/teams/TeamMembers.tsx +++ b/public/app/features/teams/TeamMembers.tsx @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import SlideDown from 'app/core/components/Animations/SlideDown'; import { UserPicker } from 'app/core/components/Select/UserPicker'; -import DeleteButton from 'app/core/components/DeleteButton/DeleteButton'; +import { DeleteButton } from '@grafana/ui'; import { TagBadge } from 'app/core/components/TagFilter/TagBadge'; import { TeamMember, User } from 'app/types'; import { loadTeamMembers, addTeamMember, removeTeamMember, setSearchMemberQuery } from './state/actions'; @@ -76,7 +76,7 @@ export class TeamMembers extends PureComponent { {member.email} {syncEnabled && this.renderLabels(member.labels)} - this.onRemoveMember(member)} /> + this.onRemoveMember(member)} /> );