-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(metadata-sidebar): Add handler for Autofill button #3700
Changes from 3 commits
d88af63
1a39b96
6243548
2bb0fc1
c6aba6d
3d8ba70
f449840
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,16 +1,18 @@ | ||||||
import { | ||||||
AutofillContextProvider, | ||||||
AutofillContextProviderProps, | ||||||
MetadataInstanceForm, | ||||||
withApiWrapper, | ||||||
type FormValues, | ||||||
type JSONPatchOperations, | ||||||
type MetadataTemplateInstance, | ||||||
type FetcherResponse, | ||||||
type BaseOptionType, | ||||||
} from '@box/metadata-editor'; | ||||||
import React from 'react'; | ||||||
|
||||||
const noopTaxonomyFetcher = () => Promise.resolve({ options: [] } satisfies FetcherResponse<BaseOptionType>); | ||||||
|
||||||
export interface MetadataInstanceEditorProps { | ||||||
areAiSuggestionsAvailable: boolean; | ||||||
fetchSuggestions: AutofillContextProviderProps['fetchSuggestions']; | ||||||
isBoxAiSuggestionsEnabled: boolean; | ||||||
isDeleteButtonDisabled: boolean; | ||||||
isUnsavedChangesModalOpen: boolean; | ||||||
|
@@ -22,9 +24,8 @@ export interface MetadataInstanceEditorProps { | |||||
template: MetadataTemplateInstance; | ||||||
} | ||||||
|
||||||
const MetadataInstanceEditor: React.FC<MetadataInstanceEditorProps> = ({ | ||||||
export const MetadataInstanceEditor: React.FC<MetadataInstanceEditorProps> = ({ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: if we're exporting for unit tests, we usually add the export at bottom with something like:
example: box-ui-elements/src/elements/content-sidebar/Sidebar.js Lines 342 to 343 in b6b61bf
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually don't need the |
||||||
areAiSuggestionsAvailable, | ||||||
fetchSuggestions, | ||||||
isBoxAiSuggestionsEnabled, | ||||||
isDeleteButtonDisabled, | ||||||
isUnsavedChangesModalOpen, | ||||||
|
@@ -35,29 +36,21 @@ const MetadataInstanceEditor: React.FC<MetadataInstanceEditorProps> = ({ | |||||
setIsUnsavedChangesModalOpen, | ||||||
template, | ||||||
}) => { | ||||||
const handleCancel = () => { | ||||||
onCancel(); | ||||||
}; | ||||||
|
||||||
return ( | ||||||
<AutofillContextProvider | ||||||
fetchSuggestions={fetchSuggestions} | ||||||
<MetadataInstanceForm | ||||||
areAiSuggestionsAvailable={areAiSuggestionsAvailable} | ||||||
isAiSuggestionsFeatureEnabled={isBoxAiSuggestionsEnabled} | ||||||
> | ||||||
<MetadataInstanceForm | ||||||
areAiSuggestionsAvailable={areAiSuggestionsAvailable} | ||||||
isAiSuggestionsFeatureEnabled={isBoxAiSuggestionsEnabled} | ||||||
isDeleteButtonDisabled={isDeleteButtonDisabled} | ||||||
isUnsavedChangesModalOpen={isUnsavedChangesModalOpen} | ||||||
onCancel={handleCancel} | ||||||
onDelete={onDelete} | ||||||
onDiscardUnsavedChanges={onDiscardUnsavedChanges} | ||||||
onSubmit={onSubmit} | ||||||
selectedTemplateInstance={template} | ||||||
setIsUnsavedChangesModalOpen={setIsUnsavedChangesModalOpen} | ||||||
/> | ||||||
</AutofillContextProvider> | ||||||
isDeleteButtonDisabled={isDeleteButtonDisabled} | ||||||
isUnsavedChangesModalOpen={isUnsavedChangesModalOpen} | ||||||
onCancel={onCancel} | ||||||
onDelete={onDelete} | ||||||
onDiscardUnsavedChanges={onDiscardUnsavedChanges} | ||||||
onSubmit={onSubmit} | ||||||
selectedTemplateInstance={template} | ||||||
setIsUnsavedChangesModalOpen={setIsUnsavedChangesModalOpen} | ||||||
taxonomyOptionsFetcher={noopTaxonomyFetcher} | ||||||
/> | ||||||
); | ||||||
}; | ||||||
|
||||||
export default MetadataInstanceEditor; | ||||||
export default withApiWrapper(MetadataInstanceEditor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see we do this in the
ask
method as well but how important is thisid
field? ifitems
has multiple files would this cause conflicts or unexpected behavior since we always look at the first index?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
is used internally by post to get auth token, it can by an array, but for this endpoint we only use one file. That is whybI take first element.