-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove withAutoComplete, useCrud / useDatalist adjustments
- Loading branch information
Showing
31 changed files
with
292 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
export { default as getData } from "./getData"; | ||
export { default as getError } from "./getError"; | ||
export { default as getMeta } from "./getMeta"; | ||
export { default as searchDataByKey } from "./searchDataByKey"; |
15 changes: 6 additions & 9 deletions
15
packages/app-i18n/src/admin/views/I18NLocales/LocaleCodesAutoComplete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
// @flow | ||
import * as React from "react"; | ||
import { AutoComplete } from "@webiny/ui/AutoComplete"; | ||
import { withAutoComplete } from "@webiny/app/components"; | ||
import { get } from "lodash"; | ||
import { searchLocaleCodes } from "./graphql"; | ||
import { SEARCH_LOCALE_CODES } from "./graphql"; | ||
import { useAutocomplete } from "@webiny/app/hooks/useAutocomplete"; | ||
|
||
const LocaleCodesAutoComplete = props => { | ||
const options = [...props.options]; | ||
const autoComplete = useAutocomplete(SEARCH_LOCALE_CODES); | ||
const options = [...autoComplete.options]; | ||
if (props.value && !options.includes(props.value)) { | ||
options.push(props.value); | ||
} | ||
|
||
return <AutoComplete {...props} options={options} useSimpleValues />; | ||
return <AutoComplete {...props} {...autoComplete} options={options} useSimpleValues />; | ||
}; | ||
|
||
export default withAutoComplete({ | ||
response: data => get(data, "i18n.codes"), | ||
query: searchLocaleCodes | ||
})(LocaleCodesAutoComplete); | ||
export default LocaleCodesAutoComplete; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
packages/app-page-builder/src/admin/components/CategoriesAutoComplete.js
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
packages/app-page-builder/src/admin/components/CategoriesAutocomplete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// @flow | ||
import * as React from "react"; | ||
import { AutoComplete } from "@webiny/ui/AutoComplete"; | ||
import gql from "graphql-tag"; | ||
import { get } from "lodash"; | ||
import { Query } from "react-apollo"; | ||
import { useAutocomplete } from "@webiny/app/hooks/useAutocomplete"; | ||
|
||
const GET_CATEGORY = gql` | ||
query getCategory($id: ID!) { | ||
pageBuilder { | ||
getCategory(id: $id) { | ||
data { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const LIST_CATEGORIES = gql` | ||
query listCategories($search: PbSearchInput) { | ||
pageBuilder { | ||
categories: listCategories(search: $search) { | ||
data { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export function CategoriesAutocomplete(props) { | ||
const autoComplete = useAutocomplete({ | ||
search: query => ({ query, fields: ["name"] }), | ||
query: LIST_CATEGORIES | ||
}); | ||
|
||
return ( | ||
<Query skip={!props.value} variables={{ id: props.value }} query={GET_CATEGORY}> | ||
{({ data }) => ( | ||
<AutoComplete {...props} {...autoComplete} value={get(data, "pageBuilder.getCategory.data")}/> | ||
)} | ||
</Query> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
packages/app-page-builder/src/admin/components/TagsMultiAutoComplete.js
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
packages/app-page-builder/src/admin/components/TagsMultiAutocomplete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// @flow | ||
import * as React from "react"; | ||
import { MultiAutoComplete as UiMultiAutoComplete } from "@webiny/ui/AutoComplete"; | ||
import { useAutocomplete } from "@webiny/app/hooks/useAutocomplete"; | ||
import gql from "graphql-tag"; | ||
|
||
const SEARCH_TAGS = gql` | ||
query searchTags($search: String!) { | ||
pageBuilder { | ||
tags: searchTags(query: $search) { | ||
data | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export function TagsMultiAutocomplete(props) { | ||
const autoComplete = useAutocomplete({ | ||
search: query => query, | ||
query: SEARCH_TAGS | ||
}); | ||
return ( | ||
<UiMultiAutoComplete | ||
{...props} | ||
{...autoComplete} | ||
label="Tags" | ||
useSimpleValues | ||
allowFreeInput | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.