UX: Automatically convert to lowercase in explorer-schema (#325)

* UX: Automatically convert to lowercase in explorer-schema

In the past, ExplorerSchema searches were case-sensitive, so if the
user's input method capitalized the first letter, it was likely that no
results would be found.

The new change allows you to enter uppercase letters, which will
automatically be converted to lowercase when searching.

meta topic: https://meta.discourse.org/t/can-the-data-explorer-search-input-be-converted-to-lower-case/323435
This commit is contained in:
Linca 2024-09-02 12:02:36 +08:00 committed by GitHub
parent 978431da02
commit 8a982beae9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 65 additions and 1 deletions

View File

@ -114,7 +114,7 @@ export default class ExplorerSchema extends Component {
@debounce(500) @debounce(500)
updateFilter(value) { updateFilter(value) {
this.filter = value; this.filter = value.toLowerCase();
this.loading = false; this.loading = false;
} }

View File

@ -0,0 +1,64 @@
import { fillIn, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
const schema = {
posts: [
{
column_name: "id",
data_type: "serial",
primary: true,
notes: "primary key",
havetypeinfo: true,
},
{
column_name: "raw",
data_type: "text",
column_desc: "The raw Markdown that the user entered into the composer.",
havepopup: true,
havetypeinfo: true,
},
],
categories: [
{
column_name: "id",
data_type: "serial",
primary: true,
notes: "primary key",
havetypeinfo: true,
},
{
column_name: "name",
data_type: "varchar(50)",
havetypeinfo: false,
},
],
};
module("Data Explorer Plugin | Component | explorer-schema", function (hooks) {
setupRenderingTest(hooks);
test("will automatically convert to lowercase", async function (assert) {
this.setProperties({
schema,
hideSchema: false,
updateHideSchema: () => {},
});
await render(hbs`
<ExplorerSchema
@schema={{this.schema}}
@hideSchema={{this.hideSchema}}
@updateHideSchema={{this.updateHideSchema}}
/>`);
await fillIn(`.schema-search input`, "Cat");
assert.dom(".schema-table").exists();
await fillIn(`.schema-search input`, "NotExist");
assert.dom(".schema-table").doesNotExist();
});
});