Skip to content

[devtools_app] Integrate the file_selector plugin #2506

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

Merged
merged 11 commits into from
Jan 22, 2021

Conversation

tugorez
Copy link
Contributor

@tugorez tugorez commented Nov 16, 2020

Fix #2505

@kenzieschmoll
Copy link
Member

Fixes #2149

@tugorez tugorez force-pushed the file_selector branch 3 times, most recently from b9fa43c to 451f60a Compare January 14, 2021 16:58
@tugorez
Copy link
Contributor Author

tugorez commented Jan 14, 2021

@kenzieschmoll I added support for web, linux and macOS. I manually tested web and it works.
It should be the same for linux and macOS: Can you help me to try those platforms integration?

}

// Only show the import button in linux, macOS and web.
bool get _shouldShowImportButton =>
Copy link
Member

Choose a reason for hiding this comment

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

can this just be true? what will happen if someone tries to build devtools and run on windows? defaultTargetPlatform == TargetPlatform.macOS is false when I tested on my mac.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can this just be true? what will happen if someone tries to build devtools and run on windows?

If someone presses the import button in a platform that is not supported by file_selector then an Unimplemented error will be thrown.

defaultTargetPlatform == TargetPlatform.macOS is false when I tested on my mac.

Oh then I should find another way to discover the platform the project is running on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some reason you're not using file_selector_windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there some reason you're not using file_selector_windows?

That's a good point. Let me add it and remove the platform validation. @kenzieschmoll does that sounds good to you?

Copy link
Member

Choose a reason for hiding this comment

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

making it work on all platforms sgtm 👍

Copy link
Member

Choose a reason for hiding this comment

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

end users won't be hit by this anyway - they use DevTools on web. We mostly develop on Mac and Linux and none of us to my knowledge develop on windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added windows and removed the platform validation. Thanks to both :)!

@kenzieschmoll
Copy link
Member

Tested on MacOs and it appears that only directories are selectable when finder is launched. See this screenshot with all the .json files disabled.
Screen Shot 2021-01-14 at 9 37 03 AM

@tugorez
Copy link
Contributor Author

tugorez commented Jan 14, 2021

Tested on MacOs and it appears that only directories are selectable when finder is launched. See this screenshot with all the .json files disabled.
Screen Shot 2021-01-14 at 9 37 03 AM

@stuartmorgan do you know why this might be happening? I'm providing this XTypeGroup to the plugin.

@stuartmorgan-g
Copy link
Contributor

stuartmorgan-g commented Jan 14, 2021

I'm providing this XTypeGroup to the plugin.

You want XTypeGroup(extensions: ['json']). The extension of 'foo.json' is json, not .json; . is a separator.

I'm surprised it worked on web. Maybe there's fixup happening there?

Edit: Looks like there is:
https://github.com/flutter/plugins/blob/master/packages/file_selector/file_selector_web/lib/src/utils.dart#L35-L38
as a side-effect of converting to the format expected by the underlying web specification. Filed flutter/flutter#73959

@tugorez
Copy link
Contributor Author

tugorez commented Jan 14, 2021

I'm providing this XTypeGroup to the plugin.

You want XTypeGroup(extensions: ['json']). The extension of 'foo.json' is json, not .json; . is a separator.

I'm surprised it worked on web. Maybe there's fixup happening there?

Oh you are right. Prepending a "." to the extensions is a web only thing. It should be fine to change ".json" to "json" as the "normalization" should be handled by this.

@tugorez
Copy link
Contributor Author

tugorez commented Jan 14, 2021

I'm providing this XTypeGroup to the plugin.

You want XTypeGroup(extensions: ['json']). The extension of 'foo.json' is json, not .json; . is a separator.
I'm surprised it worked on web. Maybe there's fixup happening there?

Oh you are right. Prepending a "." to the extensions is a web only thing. It should be fine to change ".json" to "json" as the "normalization" should be handled by this.

I changed the extension, @kenzieschmoll PTAL :)

@tugorez
Copy link
Contributor Author

tugorez commented Jan 14, 2021

cc @ditman

Copy link
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

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

tested manually on Mac and it works great! I assume linux would work too - maybe @jacob314 or @terrylucas could do a quick check since you already have a linux dev environment set up?

color: Theme.of(context).textTheme.headline1.color,
),
textAlign: TextAlign.left,
Widget _buildImportedFileDisplay() => Text(
Copy link
Member

Choose a reason for hiding this comment

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

can you add overflow: TextOverflow.ellipsis, to this text widget? thanks.

Comment on lines 144 to 146
final acceptedTypeGroups = [
XTypeGroup(extensions: ['json']),
];
Copy link
Member

Choose a reason for hiding this comment

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

can you make List<String> acceptedTypeGroups an optional parameter in the FileImportContainer constructor that defaults to ['json'], and use that here instead?

@@ -11,23 +11,27 @@ version: 0.9.6
homepage: https://github.com/flutter/devtools

environment:
sdk: '>=2.10.0 <3.0.0'
sdk: ">=2.10.0 <3.0.0"
Copy link
Member

@kenzieschmoll kenzieschmoll Jan 14, 2021

Choose a reason for hiding this comment

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

any reason for changing from ' to " ? if not, can we leave as single quotes? here, and elsewhere in pubspec.yaml

Comment on lines 118 to 127
dependency_overrides:
# The "#OVERRIDE_FOR_DEVELOPMENT" lines are stripped out when we publish.
# All overriden dependencies are published together so there is no harm
# in treating them like they are part of a mono-repo while developing.
# The "#OVERRIDE_FOR_DEVELOPMENT" lines are stripped out when we publish.
# All overriden dependencies are published together so there is no harm
# in treating them like they are part of a mono-repo while developing.
devtools_server: #OVERRIDE_FOR_DEVELOPMENT
path: ../devtools_server #OVERRIDE_FOR_DEVELOPMENT
devtools_shared: #OVERRIDE_FOR_DEVELOPMENT
path: ../devtools_shared #OVERRIDE_FOR_DEVELOPMENT
devtools_testing: #OVERRIDE_FOR_DEVELOPMENT
path: ../devtools_testing #OVERRIDE_FOR_DEVELOPMENT
path: ../devtools_server #OVERRIDE_FOR_DEVELOPMENT
devtools_shared: #OVERRIDE_FOR_DEVELOPMENT
path: ../devtools_shared #OVERRIDE_FOR_DEVELOPMENT
devtools_testing: #OVERRIDE_FOR_DEVELOPMENT
path: ../devtools_testing #OVERRIDE_FOR_DEVELOPMENT
Copy link
Member

Choose a reason for hiding this comment

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

please revert these white space changes as well. Thank you.

Comment on lines 179 to 181
final acceptedTypeGroups = [
XTypeGroup(extensions: ['json'])
];
Copy link
Member

@ditman ditman Jan 16, 2021

Choose a reason for hiding this comment

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

Echoing kenz's earlier review:

can you make List<String> acceptedTypeGroups an optional parameter in the FileImportContainer constructor that defaults to ['json'], and use that here instead?

acceptedTypeGroups should be defined in line ~20 of this file, and be an optional named parameter to FileImportContainer, which defaults to the current XTypeGroup of json, so they can use the FileImportContainer in other places of the App (to select TXT files or PNG or whatever) :)

Copy link
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

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

One nit - then LGTM. Thanks for your work on this!

@tugorez tugorez marked this pull request as ready for review January 22, 2021 17:05
@kenzieschmoll kenzieschmoll merged commit 22c4657 into flutter:master Jan 22, 2021
@ditman
Copy link
Member

ditman commented Jan 22, 2021

👏 bravo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

P2: [devtools_app] Make the "Import File" button works.
4 participants