Skip to content

Commit

Permalink
Merge branch 'mondras-empty-cta-apikeys'
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelo committed Oct 31, 2018
2 parents 89cd15d + 95a8a59 commit 05dee9e
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 410 deletions.
17 changes: 12 additions & 5 deletions public/app/core/components/Animations/SlideDown.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import React from 'react';
import React from 'react';
import Transition from 'react-transition-group/Transition';

const defaultMaxHeight = '200px'; // When animating using max-height we need to use a static value.
interface Style {
transition?: string;
overflow?: string;
}

// When animating using max-height we need to use a static value.
// If this is not enough, pass in <SlideDown maxHeight="....
const defaultMaxHeight = '200px';
const defaultDuration = 200;
const defaultStyle = {

export const defaultStyle: Style = {
transition: `max-height ${defaultDuration}ms ease-in-out`,
overflow: 'hidden',
};

export default ({ children, in: inProp, maxHeight = defaultMaxHeight }) => {
export default ({ children, in: inProp, maxHeight = defaultMaxHeight, style = defaultStyle }) => {
// There are 4 main states a Transition can be in:
// ENTERING, ENTERED, EXITING, EXITED
// https://reactcommunity.org/react-transition-group/
Expand All @@ -25,7 +32,7 @@ export default ({ children, in: inProp, maxHeight = defaultMaxHeight }) => {
{state => (
<div
style={{
...defaultStyle,
...style,
...transitionStyles[state],
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const model = {
buttonIcon: 'ga css class',
buttonLink: 'http://url/to/destination',
buttonTitle: 'Click me',
onClick: jest.fn(),
proTip: 'This is a tip',
proTipLink: 'http://url/to/tip/destination',
proTipLinkTitle: 'Learn more',
Expand Down
3 changes: 2 additions & 1 deletion public/app/core/components/EmptyListCTA/EmptyListCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class EmptyListCTA extends Component<Props, any> {
buttonIcon,
buttonLink,
buttonTitle,
onClick,
proTip,
proTipLink,
proTipLinkTitle,
Expand All @@ -19,7 +20,7 @@ class EmptyListCTA extends Component<Props, any> {
return (
<div className="empty-list-cta">
<div className="empty-list-cta__title">{title}</div>
<a href={buttonLink} className="empty-list-cta__button btn btn-xlarge btn-success">
<a onClick={onClick} href={buttonLink} className="empty-list-cta__button btn btn-xlarge btn-success">
<i className={buttonIcon} />
{buttonTitle}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports[`EmptyListCTA renders correctly 1`] = `
<a
className="empty-list-cta__button btn btn-xlarge btn-success"
href="http://url/to/destination"
onClick={[MockFunction]}
>
<i
className="ga css class"
Expand Down
16 changes: 11 additions & 5 deletions public/app/features/api-keys/ApiKeysPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React from 'react';
import { shallow } from 'enzyme';
import { Props, ApiKeysPage } from './ApiKeysPage';
import { NavModel, ApiKey } from 'app/types';
Expand All @@ -14,6 +14,7 @@ const setup = (propOverrides?: object) => {
deleteApiKey: jest.fn(),
setSearchQuery: jest.fn(),
addApiKey: jest.fn(),
apiKeysCount: 0,
};

Object.assign(props, propOverrides);
Expand All @@ -28,14 +29,19 @@ const setup = (propOverrides?: object) => {
};

describe('Render', () => {
it('should render component', () => {
const { wrapper } = setup();
it('should render API keys table if there are any keys', () => {
const { wrapper } = setup({
apiKeys: getMultipleMockKeys(5),
apiKeysCount: 5,
});

expect(wrapper).toMatchSnapshot();
});

it('should render API keys table', () => {
it('should render CTA if there are no API keys', () => {
const { wrapper } = setup({
apiKeys: getMultipleMockKeys(5),
apiKeys: getMultipleMockKeys(0),
apiKeysCount: 0,
hasFetched: true,
});

Expand Down
Loading

0 comments on commit 05dee9e

Please sign in to comment.