fix: fixed color pickers that were broken in minified builds, fixes #9549

This commit is contained in:
Torkel Ödegaard 2017-10-17 10:51:42 +02:00
parent b86ae3f0e8
commit 574afe8568
10 changed files with 40 additions and 52 deletions

View File

@ -7,6 +7,11 @@
- UX changes to nav & side menu - UX changes to nav & side menu
- New dashboard grid layout system - New dashboard grid layout system
# 4.6.0-beta2 (2017-10-17)
## Fixes
* **ColorPicker**: Fix for color picker not showing [#9549](https://github.com/grafana/grafana/issues/9549)
# 4.6.0-beta1 (2017-10-13) # 4.6.0-beta1 (2017-10-13)
## New Features ## New Features

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import coreModule from '../core_module'; import { react2AngularDirective } from 'app/core/utils/react2angular';
export interface IProps { export interface IProps {
password: string; password: string;
@ -33,7 +33,5 @@ export class PasswordStrength extends React.Component<IProps, any> {
} }
} }
coreModule.directive('passwordStrength', function(reactDirective) { react2AngularDirective('passwordStrength', PasswordStrength, ['password']);
return reactDirective(PasswordStrength, ['password']);
});

View File

@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import coreModule from 'app/core/core_module';
import { sortedColors } from 'app/core/utils/colors'; import { sortedColors } from 'app/core/utils/colors';
export interface IProps { export interface IProps {
@ -23,12 +22,15 @@ export class GfColorPalette extends React.Component<IProps, any> {
} }
render() { render() {
const colorPaletteItems = this.paletteColors.map((paletteColor) => { const colorPaletteItems = this.paletteColors.map(paletteColor => {
const cssClass = paletteColor.toLowerCase() === this.props.color.toLowerCase() ? 'fa-circle-o' : 'fa-circle'; const cssClass = paletteColor.toLowerCase() === this.props.color.toLowerCase() ? 'fa-circle-o' : 'fa-circle';
return ( return (
<i key={paletteColor} className={"pointer fa " + cssClass} <i
style={{'color': paletteColor}} key={paletteColor}
onClick={this.onColorSelect(paletteColor)}>&nbsp; className={'pointer fa ' + cssClass}
style={{ color: paletteColor }}
onClick={this.onColorSelect(paletteColor)}>
&nbsp;
</i> </i>
); );
}); });
@ -40,6 +42,3 @@ export class GfColorPalette extends React.Component<IProps, any> {
} }
} }
coreModule.directive('gfColorPalette', function (reactDirective) {
return reactDirective(GfColorPalette, ['color', 'onColorSelect']);
});

View File

@ -2,8 +2,8 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import $ from 'jquery'; import $ from 'jquery';
import Drop from 'tether-drop'; import Drop from 'tether-drop';
import coreModule from 'app/core/core_module';
import { ColorPickerPopover } from './ColorPickerPopover'; import { ColorPickerPopover } from './ColorPickerPopover';
import { react2AngularDirective } from 'app/core/utils/react2angular';
export interface IProps { export interface IProps {
color: string; color: string;
@ -27,9 +27,7 @@ export class ColorPicker extends React.Component<IProps, any> {
} }
openColorPicker() { openColorPicker() {
const dropContent = ( const dropContent = <ColorPickerPopover color={this.props.color} onColorSelect={this.onColorSelect} />;
<ColorPickerPopover color={this.props.color} onColorSelect={this.onColorSelect} />
);
let dropContentElem = document.createElement('div'); let dropContentElem = document.createElement('div');
ReactDOM.render(dropContent, dropContentElem); ReactDOM.render(dropContent, dropContentElem);
@ -38,12 +36,12 @@ export class ColorPicker extends React.Component<IProps, any> {
target: this.pickerElem[0], target: this.pickerElem[0],
content: dropContentElem, content: dropContentElem,
position: 'top center', position: 'top center',
classes: 'drop-popover drop-popover--form', classes: 'drop-popover',
openOn: 'hover', openOn: 'click',
hoverCloseDelay: 200, hoverCloseDelay: 200,
tetherOptions: { tetherOptions: {
constraints: [{ to: 'scrollParent', attachment: "none both" }] constraints: [{ to: 'scrollParent', attachment: 'none both' }],
} },
}); });
drop.on('close', this.closeColorPicker); drop.on('close', this.closeColorPicker);
@ -68,17 +66,14 @@ export class ColorPicker extends React.Component<IProps, any> {
return ( return (
<div className="sp-replacer sp-light" onClick={this.openColorPicker} ref={this.setPickerElem}> <div className="sp-replacer sp-light" onClick={this.openColorPicker} ref={this.setPickerElem}>
<div className="sp-preview"> <div className="sp-preview">
<div className="sp-preview-inner" style={{backgroundColor: this.props.color}}> <div className="sp-preview-inner" style={{ backgroundColor: this.props.color }} />
</div>
</div> </div>
</div> </div>
); );
} }
} }
coreModule.directive('colorPicker', function (reactDirective) { react2AngularDirective('colorPicker', ColorPicker, [
return reactDirective(ColorPicker, [
'color', 'color',
['onChange', { watchDepth: 'reference', wrapApply: true }] ['onChange', { watchDepth: 'reference', wrapApply: true }],
]); ]);
});

View File

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import $ from 'jquery'; import $ from 'jquery';
import tinycolor from 'tinycolor2'; import tinycolor from 'tinycolor2';
import coreModule from 'app/core/core_module';
import { GfColorPalette } from './ColorPalette'; import { GfColorPalette } from './ColorPalette';
import { GfSpectrumPicker } from './SpectrumPicker'; import { GfSpectrumPicker } from './SpectrumPicker';
@ -115,7 +114,3 @@ export class ColorPickerPopover extends React.Component<IProps, any> {
); );
} }
} }
coreModule.directive('gfColorPickerPopover', function (reactDirective) {
return reactDirective(ColorPickerPopover, ['color', 'onColorSelect']);
});

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import coreModule from 'app/core/core_module';
import { ColorPickerPopover } from './ColorPickerPopover'; import { ColorPickerPopover } from './ColorPickerPopover';
import { react2AngularDirective } from 'app/core/utils/react2angular';
export interface IProps { export interface IProps {
series: any; series: any;
@ -50,6 +50,4 @@ export class SeriesColorPicker extends React.Component<IProps, any> {
} }
} }
coreModule.directive('seriesColorPicker', function(reactDirective) { react2AngularDirective('seriesColorPicker', SeriesColorPicker, ['series', 'onColorChange', 'onToggleAxis']);
return reactDirective(SeriesColorPicker, ['series', 'onColorChange', 'onToggleAxis']);
});

View File

@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import coreModule from 'app/core/core_module';
import _ from 'lodash'; import _ from 'lodash';
import $ from 'jquery'; import $ from 'jquery';
import 'vendor/spectrum'; import 'vendor/spectrum';
@ -71,6 +70,3 @@ export class GfSpectrumPicker extends React.Component<IProps, any> {
} }
} }
coreModule.directive('gfSpectrumPicker', function (reactDirective) {
return reactDirective(GfSpectrumPicker, ['color', 'options', 'onColorSelect']);
});

View File

@ -5,6 +5,7 @@
*/ */
import coreModule from '../../core_module'; import coreModule from '../../core_module';
/** @ngInject */
export function spectrumPicker() { export function spectrumPicker() {
return { return {
restrict: 'E', restrict: 'E',

View File

@ -0,0 +1,10 @@
import coreModule from 'app/core/core_module';
export function react2AngularDirective(name: string, component: any, options: any) {
coreModule.directive(name, ['reactDirective', reactDirective => {
return reactDirective(component, options);
}]);
}

View File

@ -211,15 +211,6 @@
margin-right: 0px; margin-right: 0px;
line-height: initial; line-height: initial;
} }
.close {
margin-right: 5px;
color: $link-color;
opacity: 0.7;
text-shadow: none;
}
.editor-row {
padding: 5px;
}
} }
.annotation-tags { .annotation-tags {