mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
c4fa64e6dc
commit
3b9105e1be
@ -7,6 +7,7 @@ const setup = (propOverrides?: object) => {
|
|||||||
isReadOnly: true,
|
isReadOnly: true,
|
||||||
onSubmit: jest.fn(),
|
onSubmit: jest.fn(),
|
||||||
onDelete: jest.fn(),
|
onDelete: jest.fn(),
|
||||||
|
onTest: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(props, propOverrides);
|
Object.assign(props, propOverrides);
|
||||||
|
@ -4,14 +4,20 @@ export interface Props {
|
|||||||
isReadOnly: boolean;
|
isReadOnly: boolean;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onSubmit: (event) => void;
|
onSubmit: (event) => void;
|
||||||
|
onTest: (event) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ButtonRow: FC<Props> = ({ isReadOnly, onDelete, onSubmit }) => {
|
const ButtonRow: FC<Props> = ({ isReadOnly, onDelete, onSubmit, onTest }) => {
|
||||||
return (
|
return (
|
||||||
<div className="gf-form-button-row">
|
<div className="gf-form-button-row">
|
||||||
<button type="submit" className="btn btn-success" disabled={isReadOnly} onClick={event => onSubmit(event)}>
|
<button type="submit" className="btn btn-success" disabled={isReadOnly} onClick={event => onSubmit(event)}>
|
||||||
Save & Test
|
Save & Test
|
||||||
</button>
|
</button>
|
||||||
|
{isReadOnly && (
|
||||||
|
<button type="submit" className="btn btn-success" onClick={onTest}>
|
||||||
|
Test
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<button type="submit" className="btn btn-danger" disabled={isReadOnly} onClick={onDelete}>
|
<button type="submit" className="btn btn-danger" disabled={isReadOnly} onClick={onDelete}>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
|
@ -72,6 +72,12 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
|
|||||||
this.testDataSource();
|
this.testDataSource();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onTest = async (evt: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
|
this.testDataSource();
|
||||||
|
};
|
||||||
|
|
||||||
onDelete = () => {
|
onDelete = () => {
|
||||||
appEvents.emit('confirm-modal', {
|
appEvents.emit('confirm-modal', {
|
||||||
title: 'Delete',
|
title: 'Delete',
|
||||||
@ -180,7 +186,8 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
|
|||||||
return (
|
return (
|
||||||
<Page navModel={navModel}>
|
<Page navModel={navModel}>
|
||||||
<Page.Contents isLoading={!this.hasDataSource}>
|
<Page.Contents isLoading={!this.hasDataSource}>
|
||||||
{this.hasDataSource && <div className="page-container page-body">
|
{this.hasDataSource && (
|
||||||
|
<div className="page-container page-body">
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={this.onSubmit}>
|
<form onSubmit={this.onSubmit}>
|
||||||
{this.isReadOnly() && this.renderIsReadOnlyMessage()}
|
{this.isReadOnly() && this.renderIsReadOnlyMessage()}
|
||||||
@ -222,10 +229,12 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
|
|||||||
onSubmit={event => this.onSubmit(event)}
|
onSubmit={event => this.onSubmit(event)}
|
||||||
isReadOnly={this.isReadOnly()}
|
isReadOnly={this.isReadOnly()}
|
||||||
onDelete={this.onDelete}
|
onDelete={this.onDelete}
|
||||||
|
onTest={event => this.onTest(event)}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>}
|
</div>
|
||||||
|
)}
|
||||||
</Page.Contents>
|
</Page.Contents>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
@ -12,6 +12,13 @@ exports[`Render should render component 1`] = `
|
|||||||
>
|
>
|
||||||
Save & Test
|
Save & Test
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-success"
|
||||||
|
onClick={[MockFunction]}
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
Test
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn btn-danger"
|
className="btn btn-danger"
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
@ -97,6 +97,7 @@ exports[`Render should render alpha info text 1`] = `
|
|||||||
isReadOnly={false}
|
isReadOnly={false}
|
||||||
onDelete={[Function]}
|
onDelete={[Function]}
|
||||||
onSubmit={[Function]}
|
onSubmit={[Function]}
|
||||||
|
onTest={[Function]}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -202,6 +203,7 @@ exports[`Render should render beta info text 1`] = `
|
|||||||
isReadOnly={false}
|
isReadOnly={false}
|
||||||
onDelete={[Function]}
|
onDelete={[Function]}
|
||||||
onSubmit={[Function]}
|
onSubmit={[Function]}
|
||||||
|
onTest={[Function]}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -302,6 +304,7 @@ exports[`Render should render component 1`] = `
|
|||||||
isReadOnly={false}
|
isReadOnly={false}
|
||||||
onDelete={[Function]}
|
onDelete={[Function]}
|
||||||
onSubmit={[Function]}
|
onSubmit={[Function]}
|
||||||
|
onTest={[Function]}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -407,6 +410,7 @@ exports[`Render should render is ready only message 1`] = `
|
|||||||
isReadOnly={true}
|
isReadOnly={true}
|
||||||
onDelete={[Function]}
|
onDelete={[Function]}
|
||||||
onSubmit={[Function]}
|
onSubmit={[Function]}
|
||||||
|
onTest={[Function]}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user