Skip to content

Commit

Permalink
feat: Send editor feedback (#23980)
Browse files Browse the repository at this point in the history
* feat: Send editor feedback

Collecting feedback from users while in editor may uncover valuable
insights.

* docs: Add release note

* feat: Prefix editor feedback with tag

Indicate the context for feedback submissions originating from the
editor.
  • Loading branch information
dcalhoun authored Jan 16, 2025
1 parent e0a82f9 commit 95e3c22
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* [*] Fix an issue with small tap area of the ellipsis in the post list [#23973]
* [*] Avoid unexpectedly marking post content as unsaved. [#23969]
* [*] Fix an issue with Mastodon connection not working [#23981]
* [**] Send feedback from within the experimental editor "more" options menu. [#23980]

25.6
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import WordPressShared

final class SubmitFeedbackViewController: UIViewController {
private var source: String
private var feedbackPrefix: String?

init(source: String) {
init(source: String, feedbackPrefix: String? = nil) {
self.source = source
self.feedbackPrefix = feedbackPrefix
super.init(nibName: nil, bundle: nil)
self.modalPresentationStyle = .formSheet
}
Expand All @@ -18,7 +20,7 @@ final class SubmitFeedbackViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

let viewController = UIHostingController(rootView: SubmitFeedbackView(presentingViewController: self, source: source))
let viewController = UIHostingController(rootView: SubmitFeedbackView(presentingViewController: self, source: source, feedbackPrefix: feedbackPrefix))

let navigationController = UINavigationController(rootViewController: viewController)

Expand All @@ -33,6 +35,7 @@ final class SubmitFeedbackViewController: UIViewController {
private struct SubmitFeedbackView: View {
weak var presentingViewController: UIViewController?
let source: String
let feedbackPrefix: String?

@State private var text = ""
@State private var isSubmitting = false
Expand Down Expand Up @@ -141,9 +144,10 @@ private struct SubmitFeedbackView: View {

isSubmitting = true

let descriptionPrefix = feedbackPrefix.map { "[\($0)] " } ?? ""
ZendeskUtils.sharedInstance.createNewRequest(
in: presentingViewController,
description: text.trim(),
description: descriptionPrefix + text.trim(),
tags: ["appreview_jetpack", "in_app_feedback"],
attachments: attachmentsViewModel.attachments.compactMap(\.response),
alertOptions: nil
Expand Down Expand Up @@ -195,6 +199,6 @@ private enum Strings {

#Preview {
NavigationView {
SubmitFeedbackView(source: "preview")
SubmitFeedbackView(source: "preview", feedbackPrefix: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
guard let url = URL(string: "https://wordpress.com/support/wordpress-editor/") else { return }
present(SFSafariViewController(url: url), animated: true)
}

func showFeedbackView() {
self.present(SubmitFeedbackViewController(source: "gutenberg_kit", feedbackPrefix: "Editor"), animated: true)
}
}

extension NewGutenbergViewController: GutenbergKit.EditorViewControllerDelegate {
Expand Down Expand Up @@ -706,6 +710,9 @@ extension NewGutenbergViewController {
actions.append(UIAction(title: helpTitle, image: UIImage(systemName: "questionmark.circle")) { [weak self] _ in
self?.showEditorHelp()
})
actions.append(UIAction(title: Strings.sendFeedback, image: UIImage(systemName: "envelope")) { [weak self] _ in
self?.showFeedbackView()
})
return actions
}

Expand Down Expand Up @@ -745,6 +752,7 @@ private enum Strings {
static let postSettings = NSLocalizedString("postEditor.moreMenu.postSettings", value: "Post Settings", comment: "Post Editor / Button in the 'More' menu")
static let helpAndSupport = NSLocalizedString("postEditor.moreMenu.helpAndSupport", value: "Help & Support", comment: "Post Editor / Button in the 'More' menu")
static let help = NSLocalizedString("postEditor.moreMenu.help", value: "Help", comment: "Post Editor / Button in the 'More' menu")
static let sendFeedback = NSLocalizedString("postEditor.moreMenu.sendFeedback", value: "Send Feedback", comment: "Post Editor / Button in the 'More' menu")
static let saveDraft = NSLocalizedString("postEditor.moreMenu.saveDraft", value: "Save Draft", comment: "Post Editor / Button in the 'More' menu")
static let contentStructure = NSLocalizedString("postEditor.moreMenu.contentStructure", value: "Blocks: %li, Words: %li, Characters: %li", comment: "Post Editor / 'More' menu details labels with 'Blocks', 'Words' and 'Characters' counts as parameters (in that order)")
}
Expand Down

0 comments on commit 95e3c22

Please sign in to comment.