2019-05-10 00:48:31 -05:00
|
|
|
// Libraries
|
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
|
2019-10-31 04:48:05 -05:00
|
|
|
import { PanelProps } from '@grafana/data';
|
2020-04-16 06:49:58 -05:00
|
|
|
import { Icon, IconName } from '@grafana/ui';
|
2019-05-10 00:48:31 -05:00
|
|
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
2020-01-21 03:08:07 -06:00
|
|
|
import { backendSrv } from 'app/core/services/backend_srv';
|
2019-05-10 00:48:31 -05:00
|
|
|
import { contextSrv } from 'app/core/core';
|
|
|
|
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
|
|
|
|
|
|
|
|
interface Step {
|
|
|
|
title: string;
|
|
|
|
cta?: string;
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: IconName;
|
2019-05-10 00:48:31 -05:00
|
|
|
href: string;
|
|
|
|
target?: string;
|
|
|
|
note?: string;
|
|
|
|
check: () => Promise<boolean>;
|
|
|
|
done?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface State {
|
|
|
|
checksDone: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class GettingStarted extends PureComponent<PanelProps, State> {
|
|
|
|
stepIndex = 0;
|
|
|
|
readonly steps: Step[];
|
|
|
|
|
|
|
|
constructor(props: PanelProps) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
checksDone: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.steps = [
|
|
|
|
{
|
|
|
|
title: 'Install Grafana',
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'check',
|
2019-05-10 00:48:31 -05:00
|
|
|
href: 'http://docs.grafana.org/',
|
|
|
|
target: '_blank',
|
|
|
|
note: 'Review the installation docs',
|
|
|
|
check: () => Promise.resolve(true),
|
|
|
|
},
|
|
|
|
{
|
2020-01-17 02:43:17 -06:00
|
|
|
title: 'Create a data source',
|
2019-05-10 00:48:31 -05:00
|
|
|
cta: 'Add data source',
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'database',
|
2019-05-10 00:48:31 -05:00
|
|
|
href: 'datasources/new?gettingstarted',
|
|
|
|
check: () => {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
resolve(
|
|
|
|
getDatasourceSrv()
|
|
|
|
.getMetricSources()
|
|
|
|
.filter(item => {
|
|
|
|
return item.meta.builtIn !== true;
|
|
|
|
}).length > 0
|
|
|
|
);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-01-17 02:43:17 -06:00
|
|
|
title: 'Build a dashboard',
|
2019-05-10 00:48:31 -05:00
|
|
|
cta: 'New dashboard',
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'apps',
|
2019-05-10 00:48:31 -05:00
|
|
|
href: 'dashboard/new?gettingstarted',
|
|
|
|
check: () => {
|
2020-01-21 03:08:07 -06:00
|
|
|
return backendSrv.search({ limit: 1 }).then(result => {
|
|
|
|
return result.length > 0;
|
|
|
|
});
|
2019-05-10 00:48:31 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Invite your team',
|
|
|
|
cta: 'Add Users',
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'users-alt',
|
2019-05-10 00:48:31 -05:00
|
|
|
href: 'org/users?gettingstarted',
|
|
|
|
check: () => {
|
2020-01-21 03:08:07 -06:00
|
|
|
return backendSrv.get('/api/org/users/lookup').then((res: any) => {
|
|
|
|
/* return res.length > 1; */
|
|
|
|
return false;
|
|
|
|
});
|
2019-05-10 00:48:31 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Install apps & plugins',
|
|
|
|
cta: 'Explore plugin repository',
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'plug',
|
2019-05-10 00:48:31 -05:00
|
|
|
href: 'https://grafana.com/plugins?utm_source=grafana_getting_started',
|
|
|
|
check: () => {
|
2020-01-21 03:08:07 -06:00
|
|
|
return backendSrv.get('/api/plugins', { embedded: 0, core: 0 }).then((plugins: any[]) => {
|
|
|
|
return plugins.length > 0;
|
|
|
|
});
|
2019-05-10 00:48:31 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.stepIndex = -1;
|
|
|
|
return this.nextStep().then((res: any) => {
|
|
|
|
this.setState({ checksDone: true });
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-06-27 08:56:02 -05:00
|
|
|
nextStep(): any {
|
2019-05-10 00:48:31 -05:00
|
|
|
if (this.stepIndex === this.steps.length - 1) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.stepIndex += 1;
|
|
|
|
const currentStep = this.steps[this.stepIndex];
|
|
|
|
return currentStep.check().then(passed => {
|
|
|
|
if (passed) {
|
|
|
|
currentStep.done = true;
|
|
|
|
return this.nextStep();
|
|
|
|
}
|
|
|
|
return Promise.resolve();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
dismiss = () => {
|
|
|
|
const { id } = this.props;
|
|
|
|
const dashboard = getDashboardSrv().getCurrent();
|
|
|
|
const panel = dashboard.getPanelById(id);
|
|
|
|
dashboard.removePanel(panel);
|
2020-01-21 03:08:07 -06:00
|
|
|
backendSrv
|
2019-05-10 00:48:31 -05:00
|
|
|
.request({
|
|
|
|
method: 'PUT',
|
|
|
|
url: '/api/user/helpflags/1',
|
|
|
|
showSuccessAlert: false,
|
|
|
|
})
|
|
|
|
.then((res: any) => {
|
|
|
|
contextSrv.user.helpFlags1 = res.helpFlags1;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { checksDone } = this.state;
|
|
|
|
if (!checksDone) {
|
|
|
|
return <div>checking...</div>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="progress-tracker-container">
|
|
|
|
<button className="progress-tracker-close-btn" onClick={this.dismiss}>
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
<Icon name="times" />
|
2019-05-10 00:48:31 -05:00
|
|
|
</button>
|
|
|
|
<div className="progress-tracker">
|
2019-05-10 13:48:27 -05:00
|
|
|
{this.steps.map((step, index) => {
|
2019-05-10 00:48:31 -05:00
|
|
|
return (
|
2019-05-10 13:48:27 -05:00
|
|
|
<div key={index} className={step.done ? 'progress-step completed' : 'progress-step active'}>
|
2019-05-10 00:48:31 -05:00
|
|
|
<a className="progress-link" href={step.href} target={step.target} title={step.note}>
|
2019-05-10 13:48:27 -05:00
|
|
|
<span className="progress-marker">
|
2020-04-16 06:49:58 -05:00
|
|
|
<Icon name={step.icon} size="xxl" />
|
2019-05-10 00:48:31 -05:00
|
|
|
</span>
|
|
|
|
<span className="progress-text">{step.title}</span>
|
|
|
|
</a>
|
|
|
|
<a className="btn-small progress-step-cta" href={step.href} target={step.target}>
|
|
|
|
{step.cta}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|