Skip to content

feat(metadata-sidebar): Add handler for Autofill button - #3700

Merged
mergify[bot] merged 7 commits into
box:masterfrom
jankowiakdawid:handle-autofill
Oct 10, 2024
Merged

mergify[bot] merged 7 commits into
box:masterfrom
jankowiakdawid:handle-autofill

Conversation

@jankowiakdawid

Copy link
Copy Markdown
Contributor

No description provided.

@jankowiakdawid
jankowiakdawid requested review from a team as code owners October 7, 2024 16:59
Comment thread src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts Outdated
Comment thread src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts Outdated
Comment thread src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts Outdated
Comment thread src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
Comment thread src/elements/content-sidebar/MetadataInstanceEditor.tsx Outdated
@jankowiakdawid
jankowiakdawid force-pushed the handle-autofill branch 2 times, most recently from 0bed1bb to 21d879a Compare October 9, 2024 14:50
Comment thread src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts Outdated
And bump metadata-editor package
Wrap MetadataInstanceList and MetadataInstanceForm in Autofill provider

Co-authored-by: Wiola (wpiesiak)
async (templateKey: string, fields: MetadataTemplateField[]) => {
const aiAPI = api.getIntelligenceAPI();

await wait(1000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have a setTimeout here? We should have a constant for the delay time as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I was using it to test loading state, and forgot to delete

async (templateKey: string, fields: MetadataTemplateField[]) => {
const aiAPI = api.getIntelligenceAPI();

await wait(1000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason for this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I was using it to test loading state, and forgot to delete

Comment thread src/test-utils/testing-library.tsx Outdated
Comment on lines 19 to 22
<AutofillContextProvider
isAiSuggestionsFeatureEnabled={isAiSuggestionsFeatureEnabled}
fetchSuggestions={fetchSuggestions}
isAiSuggestionsFeatureEnabled={isAiSuggestionsFeatureEnabled}
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after looking at this again and noticed we are passing props specifically for it, think we need to consider moving this out of the testing-library into the metadata-editor tests directly, all the tests in the repo will use this wrapper eventually, i cant imagine that provider being used that much to warrant being in the wrapper. the other providers where are more generic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. AutofillContextProvider is needed only for MetadataInstanceEditor tests.
I did tried moving it out but it resulted in failing tests

    TypeError: (0 , _reactIntl.useIntl) is not a function

Not quite sure what's happening. But I needed to move the whole wrapper component to MetadataInstanceEditor test.

Comment thread src/api/Intelligence.js
suggestionsResponse = await this.xhr.post({
url,
data: request,
id: `file_${request.items[0].id}`,

@tjuanitas tjuanitas Oct 10, 2024 •

Copy link
Copy Markdown
Contributor

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 this id field? if items has multiple files would this cause conflicts or unexpected behavior since we always look at the first index?

Copy link
Copy Markdown
Contributor Author

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.

}

const MetadataInstanceEditor: React.FC<MetadataInstanceEditorProps> = ({
export const MetadataInstanceEditor: React.FC<MetadataInstanceEditorProps> = ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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:

export { MetadataInstanceEditor as MetadataInstanceEditorComponent };

example:

export { Sidebar as SidebarComponent };
export default flow([withCurrentUser, withFeatureConsumer, withRouter])(Sidebar);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually don't need the withApiWrapper so I will restore the old way we were exporting here.

async (templateKey: string, fields: MetadataTemplateField[]) => {
const aiAPI = api.getIntelligenceAPI();

await wait(1000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reasoning for this? are we adding an artificial loading time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I was using it to test loading state, and forgot to delete

tjuanitas
tjuanitas previously approved these changes Oct 10, 2024

@tjuanitas tjuanitas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment but approved. please address in follow up if not fixed in this PR

Comment thread src/test-utils/testing-library.tsx Outdated

type RenderConnectedOptions = Omit<RenderOptions, 'wrapper'> & {
type RenderConnectedOptions = RenderOptions & {
// Omit<RenderOptions, 'wrapper'> & {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncomment or remove?

@mergify
mergify Bot merged commit 95735e0 into box:master Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants