A dialog to handle opening .ics files
Categories
(Calendar :: Dialogs, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: pmorris, Assigned: pmorris)
References
Details
Attachments
(2 files, 7 obsolete files)
13.10 KB,
patch
|
darktrojan
:
review+
|
Details | Diff | Splinter Review |
9.60 KB,
patch
|
pmorris
:
review+
|
Details | Diff | Splinter Review |
Implement a dialog window that appears when opening .ics files, e.g. when passing .ics files to Thunderbird via the command line, like so: thunderbird -file example.ics
The dialog should present some options:
- import the file's events into an existing calendar (or possibly a newly created calendar?)
- subscribe to the file (as a separate new calendar)
Ideally detect when the calendar add-on is not installed and at least point the user in the right direction to install it.
See comment 55 on bug 357480:
"First of all it would be helpful to even allow importing or subscribing to calendar files using the command line."
"There are two paths to consider when passing a file to Thunderbird/Lightning. It can either be imported (e.g. copied to an existing calendar or a new storage calendar), or it can be subscribed to (e.g using the ics provider, just subscribe to the file so that changes are being made directly in that file)."
"Maybe it would make sense to create an import dialog that explains and provides these two options. We could use it for bug 167255 too, although it doesn't have to be a wizard as mentioned there. When Thunderbird is started with the command line flag, then this dialog would show up and allow to select how to handle the file."
Comment 1•6 years ago
|
||
I think it would be useful to see upfront what event is in the ics file. And if there's many, you'd also want to know.
I'm not sure there's much of a case for subscribing to a file:// local ics file. Then the question is, do we ever get an http url?
Assignee | ||
Comment 2•6 years ago
|
||
Refactor the import handling code to allow passing the file as an argument and skipping the file picker dialog. Then we can use it to open a given file from the command line (with the next patch).
Assignee | ||
Comment 3•6 years ago
|
||
WIP - allows importing an ics file from the command line, for example, in the comm/ dir:
$ ../obj-artifact/dist/bin/thunderbird -file calendar/test/browser/data/import.ics
There's more to do (like the subscribe button does not do anything yet, and needing to handle error cases in the dialog, etc.) but I wanted to put this up for feedback on the general approach.
Assignee | ||
Comment 4•6 years ago
|
||
(In reply to Magnus Melin [:mkmelin] from comment #1)
I think it would be useful to see upfront what event is in the ics file. And if there's many, you'd also want to know.
That would be nice to have. I'd suggest adding that in a follow-up once the basic functionality is in place.
I'm not sure there's much of a case for subscribing to a file:// local ics file. Then the question is, do we ever get an http url?
Good thought. I imagine there are cases where you would want to either import or subscribe to a http url file, so we'd want to offer both options there. But yeah, if we can make it smarter without limiting functionality then let's do it, but I'd say let's get the basics working first.
Assignee | ||
Updated•6 years ago
|
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Assignee | ||
Comment 7•6 years ago
•
|
||
I've made the changes to the docstrings. We should document that so the conventions/expectations are clear and simple to follow.
Not sure I see the point of passing around an import contractId. You'll be
handling ics and csv. You'd just check the filename extension and use
whatever needed at that point, no?
In the existing code the output of the file picker dialog includes both the file and what the user selected for the file type. At the code level the latter is a contractId. In this patch I'm just refactoring the code so it will work for importing an ics file passed via the command line. Relying on the filename extension would change what the code does and also seems unnecessary since we already know what kind of file it is (and likely in a more robust/reliable way), from the file picker dialog. I'd rather pass another argument than recalculate the same thing again in a way that might diverge from the current behavior.
Let's use something more js, like OS.File (see e.g. converterWorker.js)
I looked into this, but it does not look that feasible because calIImporter has an importFromStream method so we need a nsIFileInputStream to pass to it. Like I said above, my goal with this refactor is limited to the scope of this bug. If we want to do more, let's do it in a different bug.
Assignee | ||
Comment 8•6 years ago
|
||
(In reply to Magnus Melin [:mkmelin] from comment #6)
Comment on attachment 9115864 [details] [diff] [review]
part2-wip-import-ics-files-command-line-0.patchI think too early to give proper feedback here. It doesn't really work... at
least for me. I couldn't get it to actually import or subscribe. The dialog
comes up but the buttons do not work.
It works for me. Like I mentioned above, the "subscribe" button functionality is not yet implemented, but import should be functional and works for me.
I looked into the subscribe code a bit and it looks like it will be more involved to achieve than import, and import seems to be the primary use case. So I think the first step should be a dialog that just offers 'import' and then we can add subscribe in a follow-up.
Comment 9•6 years ago
|
||
I haven't reviewed this yet because the test is disabled. Hoping to get some action on bug 1605674.
Comment 10•6 years ago
|
||
Assignee | ||
Comment 11•5 years ago
|
||
1 of 2: Rebased, addressed review comments, improved a bit. No longer passing around a contractId, instead using file extension to detect file type.
Assignee | ||
Comment 12•5 years ago
|
||
2 of 2. Now using fluent for l10n and only offering import (not subscribe). We can add subscribe as an option in a follow-up if that makes sense (some UX discussion likely needed there). I wanted to start with import as that's the main use case. Simpler to offer this feature now that calendar is built in. To see it work, from the comm directory do:
$ ../obj-artifact/dist/bin/thunderbird -file calendar/test/browser/data/import.ics
Comment 13•5 years ago
|
||
Comment 14•5 years ago
|
||
Assignee | ||
Comment 15•5 years ago
|
||
Thanks for the review; I appreciate the helpful feedback. I've addressed the comments.
(In reply to Geoff Lankow (:darktrojan) from comment #13)
Rejecting here raises an exception in the calling function, which you
haven't handled. Also, how does this last case differ from the first, so
that you reject here but resolve with no argument there?
My thinking was to differentiate the "nothing went wrong, user just clicked cancel" case from the case where something went wrong and the file wasn't there when it really should have been. The previous code checked for that failure mode, so I assumed it was a potential problem. But I suppose we can trust the file picker to work as advertised.
(Side point: I don't think it's actually possible to be in this last case,
other than if returnValue == Ci.nsIFilePicker.returnReplace which would be
wrong anyway.)I think this block should just be this:
if (returnValue == Ci.nsIFilePicker.returnCancel) {
resolve();
}
resolve(picker.file);
That works for me.
I have a dream that we can be smarter about this than just checking the
extension, but it's good enough for now.
Yeah, it seems like there should be a more robust way. (That's one reason I was originally holding on to the contractId from the dialog, thinking that was likely to be more reliable. But this does the job for now.)
Assignee | ||
Comment 16•5 years ago
|
||
(In reply to Geoff Lankow (:darktrojan) from comment #14)
Don't use the extra1 button for this. For a yes/no question like this you
should use the accept and cancel buttons. If the user does click the accept
button, immediately disable both buttons for the duration of the import, and
for a minimum of, say, 1 second (a guess on my part) if the import is faster
than that. Then change the label back to OK (or maybe Close) and enable it.
Makes sense, and done. As it happens, Promise.allSettled
is really useful! (The extra1 button was partly left over from an earlier iteration that had both import and subscribe buttons.) I went with half a second since a full second seemed a little long when I was testing it out.
Updated•5 years ago
|
Comment 17•5 years ago
|
||
Comment 18•5 years ago
|
||
Assignee | ||
Comment 19•5 years ago
|
||
Thanks for the reviews and putting up with this ugly dialog. ;-) Just for context, on chat we discussed how:
"mkmelin has requested that in a future iteration it would show the user a preview of the events that will be imported before they click "import". Also, Fallen has discussed having it also handle 'subscribe' as well as 'import' options."
Another possibility would be to present the calendar selection part in this import dialog, so the user chooses a calendar and then clicks "import" rather than opening a second dialog for that as a separate step. Doing it that way probably makes sense in other places too, and then we wouldn't need the separate calendar selector dialog.
Assignee | ||
Comment 20•5 years ago
|
||
Okay, I've made the suggested changes (dropped minheight, used 29em for minwidth, the question disappears on success and failure).
The dialog is now sized to its content, even when the content changes/is added dynamically.
I also made the import button go away when there is an error. Seemed better to let the user start over in that case.
Comment 21•5 years ago
|
||
Assignee | ||
Comment 22•5 years ago
|
||
Fixes the nit. Thanks for the review. Try run:
https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=424e003589ce64598afacbdf383852e9abb22424
Assignee | ||
Updated•5 years ago
|
Comment 23•5 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/26e623746758
Refactor import-export.js to support opening a given ics file. r=darktrojan
https://hg.mozilla.org/comm-central/rev/d751725dce3a
Allow import of ICS files via the command line. r=darktrojan DONTBUILD
Updated•5 years ago
|
Description
•