Skip to content
Snippets Groups Projects
Unverified Commit d3466c9f authored by Dalton's avatar Dalton Committed by GitHub
Browse files

Disable sample dataset engine form field (#20458)

* Disable sample dataset engine form field

* e2e test
parent 0a80b825
No related branches found
No related tags found
No related merge requests found
......@@ -144,7 +144,10 @@ export default class DatabaseEditApp extends Component {
<DatabaseEditContent>
<DatabaseEditForm>
<Form>
<FormField name="engine" />
<FormField
name="engine"
disabled={database.is_sample}
/>
<DriverWarning
engine={values.engine}
onChange={engine =>
......
......@@ -3,12 +3,13 @@ import React from "react";
import Select, { Option } from "metabase/core/components/Select";
const FormSelectWidget = ({ placeholder, options = [], field }) => (
const FormSelectWidget = ({ placeholder, options = [], field, disabled }) => (
<Select
placeholder={placeholder}
{...field}
// react-redux expects to be raw value
onChange={e => field.onChange(e.target.value)}
disabled={disabled}
buttonProps={{ style: { minWidth: 200 } }}
>
{options.map(({ name, value, icon }) => (
......
......@@ -33,6 +33,7 @@ export default class Select extends Component {
onChange: PropTypes.func.isRequired,
multiple: PropTypes.bool,
placeholder: PropTypes.string,
disabled: PropTypes.bool,
// PopoverWithTrigger props
isInitiallyOpen: PropTypes.bool,
......@@ -191,6 +192,7 @@ export default class Select extends Component {
hideEmptySectionsInSearch,
isInitiallyOpen,
onClose,
disabled,
} = this.props;
const sections = this._getSections();
......@@ -210,6 +212,7 @@ export default class Select extends Component {
ref={this.selectButtonRef}
className="flex-full"
hasValue={selectedNames.length > 0}
disabled={disabled}
{...buttonProps}
>
{selectedNames.length > 0
......@@ -226,6 +229,7 @@ export default class Select extends Component {
onClose={composeEventHandlers(onClose, this.handleClose)}
triggerClasses={cx("flex", className)}
isInitiallyOpen={isInitiallyOpen}
disabled={disabled}
verticalAttachments={["top", "bottom"]}
// keep the popover from jumping around one its been opened,
// this can happen when filtering items via search
......
......@@ -15,6 +15,15 @@ describe("scenarios > admin > databases > edit", () => {
cy.route("PUT", "/api/database/*").as("databaseUpdate");
});
describe("Database type", () => {
it("should be disabled for the Sample Dataset (metabase#16382)", () => {
cy.visit("/admin/databases/1");
cy.findByText("H2")
.parentsUntil("a")
.should("be.disabled");
});
});
describe("Connection settings", () => {
it("shows the connection settings for sample database correctly", () => {
cy.visit("/admin/databases/1");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment