Skip to content

Commit

Permalink
address code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stacey-gammon committed May 17, 2017
1 parent 3bbd73b commit 694c5bf
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 90 deletions.
6 changes: 0 additions & 6 deletions src/core_plugins/kibana/public/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { DashboardState } from './dashboard_state';
import { notify } from 'ui/notify';
import { documentationLinks } from 'ui/documentation_links/documentation_links';
import { showCloneModal } from './top_nav/show_clone_modal';
import { DashboardCloneModal } from './top_nav/clone_modal';

const app = uiModules.get('app/dashboard', [
'elasticsearch',
Expand All @@ -33,13 +32,8 @@ const app = uiModules.get('app/dashboard', [
'kibana/config',
'kibana/notify',
'kibana/typeahead',
'react',
]);

app.directive('dashboardCloneModal', function (reactDirective) {
return reactDirective(DashboardCloneModal);
});

uiRoutes
.when(DashboardConstants.CREATE_NEW_DASHBOARD_URL, {
template: dashboardTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,68 @@

exports[`renders DashboardCloneModal 1`] = `
<div
aria-label="Clone a dashboard"
class="kuiModal dashboardCloneModal"
data-tests-subj="dashboardCloneModal"
class="kuiModalOverlay"
>
<div
class="kuiModalHeader"
aria-label="Clone a dashboard"
class="kuiModal dashboardCloneModal"
data-tests-subj="dashboardCloneModal"
>
<div
class="kuiModalHeader__title"
class="kuiModalHeader"
>
Clone Dashboard
<div
class="kuiModalHeader__title"
>
Clone Dashboard
</div>
</div>
</div>
<div
class="kuiModalBody"
>
<div
class="kuiModalBodyText kuiVerticalRhythm"
class="kuiModalBody"
>
Please enter a new name for your dashboard.
<div
class="kuiModalBodyText kuiVerticalRhythm"
>
Please enter a new name for your dashboard.
</div>
<div
class="kuiModalBodyText kuiVerticalRhythm"
>
<input
class="kuiTextInput kuiTextInput--large"
data-test-subj="clonedDashboardTitle"
value="dash title"
/>
</div>
</div>
<div
class="kuiModalBodyText kuiVerticalRhythm"
class="kuiModalFooter"
>
<input
class="kuiTextInput kuiTextInput--large"
data-test-subj="clonedDashboardTitle"
value="dash title"
/>
</div>
</div>
<div
class="kuiModalFooter"
>
<button
class="kuiButton kuiButton--hollow"
data-test-subj="cloneCancelButton"
>
<span
class="kuiButton__inner"
<button
class="kuiButton kuiButton--hollow"
data-test-subj="cloneCancelButton"
>
<span>
Cancel
<span
class="kuiButton__inner"
>
<span>
Cancel
</span>
</span>
</span>
</button>
<button
class="kuiButton kuiButton--primary"
data-test-subj="cloneConfirmButton"
>
<span
class="kuiButton__inner"
</button>
<button
class="kuiButton kuiButton--primary"
data-test-subj="cloneConfirmButton"
>
<span>
Confirm Clone
<span
class="kuiButton__inner"
>
<span>
Confirm Clone
</span>
</span>
</span>
</button>
</button>
</div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export class DashboardCloneModal extends React.Component {
};
}

componentDidMount() {
this.confirmButton.focus();
}

cloneDashboard = () => {
this.props.onClone(this.state.newDashboardName);
};
Expand All @@ -34,7 +30,7 @@ export class DashboardCloneModal extends React.Component {
};

onKeyDown = (event) => {
if (event.keyCode === 27) {
if (event.keyCode === 27) { // ESC key
this.props.onClose();
}
};
Expand All @@ -59,6 +55,7 @@ export class DashboardCloneModal extends React.Component {
</KuiModalBodyText>
<KuiModalBodyText className="kuiVerticalRhythm">
<input
autoFocus
data-test-subj="clonedDashboardTitle"
className="kuiTextInput kuiTextInput--large"
value={ this.state.newDashboardName }
Expand All @@ -78,7 +75,6 @@ export class DashboardCloneModal extends React.Component {
type="primary"
data-test-subj="cloneConfirmButton"
onClick={ this.cloneDashboard }
ref={ (button) => { this.confirmButton = button; } }
>
Confirm Clone
</KuiButton>
Expand Down
62 changes: 27 additions & 35 deletions ui_framework/components/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,42 +59,34 @@ const ContentWithIcon = ({ children, icon, iconPosition, isLoading }) => {
}
};

class KuiButton extends React.Component {
focus() {
this.kuiButton.focus();
}

render() {
const {
isLoading,
iconPosition = DEFAULT_ICON_POSITION,
className,
type,
icon,
children,
...rest
} = this.props;
return (
<button
ref={ (kuiButton) => { this.kuiButton = kuiButton; } }
className={getClassName({
className,
type,
hasIcon: icon || isLoading,
})}
{...rest}
const KuiButton = ({
isLoading,
iconPosition = DEFAULT_ICON_POSITION,
className,
type,
icon,
children,
...rest
}) => {
return (
<button
className={getClassName({
className,
type,
hasIcon: icon || isLoading,
})}
{...rest}
>
<ContentWithIcon
icon={icon}
iconPosition={iconPosition}
isLoading={isLoading}
>
<ContentWithIcon
icon={icon}
iconPosition={iconPosition}
isLoading={isLoading}
>
{children}
</ContentWithIcon>
</button>
);
}
}
{children}
</ContentWithIcon>
</button>
);
};

KuiButton.propTypes = {
icon: PropTypes.node,
Expand Down

0 comments on commit 694c5bf

Please sign in to comment.