Skip to content
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

Skip prompt to copy URL on failure creating share. #15007

Merged
merged 1 commit into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public DescriptiveUrl run(final Session<?> session) throws BackgroundException {
}
}

@Override
public DescriptiveUrl initialize() {
return DescriptiveUrl.EMPTY;
}

@Override
public String getActivity() {
return MessageFormat.format(LocaleFactory.localizedString("Prepare {0} ({1})", "Status"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public DescriptiveUrl run(final Session<?> session) throws BackgroundException {
}
}

@Override
public DescriptiveUrl initialize() {
return DescriptiveUrl.EMPTY;
}

@Override
public String getActivity() {
return MessageFormat.format(LocaleFactory.localizedString("Prepare {0} ({1})", "Status"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2572,38 +2572,40 @@ public void shareFileButtonClicked(final ID sender) {
new DownloadShareWorker<Void>(file, null, PasswordCallbackFactory.get(this), new PromptShareeCallback(pool.getHost(), this)) {
@Override
public void cleanup(final DescriptiveUrl url) {
// Display
final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"),
MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()),
LocaleFactory.localizedString("Continue", "Credentials"),
null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null,
null)) {
@Override
public void callback(final int returncode) {
switch(returncode) {
case SheetCallback.CANCEL_OPTION:
final NSPasteboard pboard = NSPasteboard.generalPasteboard();
pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null);
if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) {
log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType));
}
if(null != url) {
// Display
final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"),
MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()),
LocaleFactory.localizedString("Continue", "Credentials"),
null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null,
null)) {
@Override
public void callback(final int returncode) {
switch(returncode) {
case SheetCallback.CANCEL_OPTION:
final NSPasteboard pboard = NSPasteboard.generalPasteboard();
pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null);
if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) {
log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType));
}
}
}
}

@Override
public NSView getAccessoryView(final NSAlert alert) {
if(null == url.getUrl()) {
return null;
@Override
public NSView getAccessoryView(final NSAlert alert) {
if(null == url.getUrl()) {
return null;
}
final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22));
field.setEditable(false);
field.setSelectable(true);
field.cell().setWraps(false);
field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES));
return field;
}
final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22));
field.setEditable(false);
field.setSelectable(true);
field.cell().setWraps(false);
field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES));
return field;
}
};
alert.beginSheet(BrowserController.this);
};
alert.beginSheet(BrowserController.this);
}
}
}
)
Expand All @@ -2617,37 +2619,39 @@ public void requestFilesButtonClicked(final ID sender) {
new UploadShareWorker<Void>(file, null, PasswordCallbackFactory.get(this), new PromptShareeCallback(pool.getHost(), this)) {
@Override
public void cleanup(final DescriptiveUrl url) {
final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"),
MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()),
LocaleFactory.localizedString("Continue", "Credentials"),
null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null,
null)) {
@Override
public void callback(final int returncode) {
switch(returncode) {
case SheetCallback.CANCEL_OPTION:
final NSPasteboard pboard = NSPasteboard.generalPasteboard();
pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null);
if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) {
log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType));
}
if(null != url) {
final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"),
MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()),
LocaleFactory.localizedString("Continue", "Credentials"),
null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null,
null)) {
@Override
public void callback(final int returncode) {
switch(returncode) {
case SheetCallback.CANCEL_OPTION:
final NSPasteboard pboard = NSPasteboard.generalPasteboard();
pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null);
if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) {
log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType));
}
}
}
}

@Override
public NSView getAccessoryView(final NSAlert alert) {
if(null == url.getUrl()) {
return null;
@Override
public NSView getAccessoryView(final NSAlert alert) {
if(null == url.getUrl()) {
return null;
}
final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22));
field.setEditable(false);
field.setSelectable(true);
field.cell().setWraps(false);
field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES));
return field;
}
final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22));
field.setEditable(false);
field.setSelectable(true);
field.cell().setWraps(false);
field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES));
return field;
}
};
alert.beginSheet(BrowserController.this);
};
alert.beginSheet(BrowserController.this);
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3682,11 +3682,11 @@ public override void cleanup(object result)
{
DescriptiveUrl url = (DescriptiveUrl)result;
// Display
if (!DescriptiveUrl.EMPTY.@equals(url))
if (null != url)
{
string title = LocaleFactory.localizedString("Share…", "Main");
string commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Continue", "Credentials"),
LocaleFactory.localizedString("Copy", "Main"));
null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null);
_controller.CommandBox(title, title, MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS") + "\n\n{1}", _file.getName(), url.getUrl()),
commandButtons,
false, null, TaskDialogIcon.Information,
Expand Down Expand Up @@ -3727,11 +3727,11 @@ public override void cleanup(object result)
{
DescriptiveUrl url = (DescriptiveUrl)result;
// Display
if (!DescriptiveUrl.EMPTY.@equals(url))
if (null != url)
{
string title = LocaleFactory.localizedString("Share…", "Main");
string commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Continue", "Credentials"),
LocaleFactory.localizedString("Copy", "Main"));
null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null);
_controller.CommandBox(title, title, MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS") + "\n\n{1}", _file.getName(), url.getUrl()),
commandButtons,
false, null, TaskDialogIcon.Information,
Expand Down