mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Add "Create Log Post" command to Post menu (#243)
This commit is contained in:
parent
79b4301988
commit
579db0c889
@ -105,16 +105,8 @@ struct WriteFreely_MultiPlatformApp: App {
|
|||||||
SidebarCommands()
|
SidebarCommands()
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
PostCommands(model: model)
|
PostCommands(model: model)
|
||||||
|
HelpCommands(model: model)
|
||||||
#endif
|
#endif
|
||||||
CommandGroup(after: .help) {
|
|
||||||
Button("Visit Support Forum") {
|
|
||||||
#if os(macOS)
|
|
||||||
NSWorkspace().open(model.helpURL)
|
|
||||||
#else
|
|
||||||
UIApplication.shared.open(model.helpURL)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ToolbarCommands()
|
ToolbarCommands()
|
||||||
TextEditingCommands()
|
TextEditingCommands()
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@
|
|||||||
17DFDE8C251D309400A25F31 /* OpenSans-License.txt in Resources */ = {isa = PBXBuildFile; fileRef = 17DFDE86251D309400A25F31 /* OpenSans-License.txt */; };
|
17DFDE8C251D309400A25F31 /* OpenSans-License.txt in Resources */ = {isa = PBXBuildFile; fileRef = 17DFDE86251D309400A25F31 /* OpenSans-License.txt */; };
|
||||||
17E5DF8A2543610700DCDC9B /* PostTextEditingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17E5DF892543610700DCDC9B /* PostTextEditingView.swift */; };
|
17E5DF8A2543610700DCDC9B /* PostTextEditingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17E5DF892543610700DCDC9B /* PostTextEditingView.swift */; };
|
||||||
375A67E828FC555C007A1AC0 /* MultilineTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 375A67E728FC555C007A1AC0 /* MultilineTextView.swift */; };
|
375A67E828FC555C007A1AC0 /* MultilineTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 375A67E728FC555C007A1AC0 /* MultilineTextView.swift */; };
|
||||||
|
3779389729EC0C880032D6C1 /* HelpCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3779389629EC0C880032D6C1 /* HelpCommands.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -268,6 +269,7 @@
|
|||||||
17DFDE86251D309400A25F31 /* OpenSans-License.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "OpenSans-License.txt"; sourceTree = "<group>"; };
|
17DFDE86251D309400A25F31 /* OpenSans-License.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "OpenSans-License.txt"; sourceTree = "<group>"; };
|
||||||
17E5DF892543610700DCDC9B /* PostTextEditingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostTextEditingView.swift; sourceTree = "<group>"; };
|
17E5DF892543610700DCDC9B /* PostTextEditingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostTextEditingView.swift; sourceTree = "<group>"; };
|
||||||
375A67E728FC555C007A1AC0 /* MultilineTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultilineTextView.swift; sourceTree = "<group>"; };
|
375A67E728FC555C007A1AC0 /* MultilineTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultilineTextView.swift; sourceTree = "<group>"; };
|
||||||
|
3779389629EC0C880032D6C1 /* HelpCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpCommands.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -455,6 +457,7 @@
|
|||||||
children = (
|
children = (
|
||||||
17BC617825715068003363CA /* ActivePostToolbarView.swift */,
|
17BC617825715068003363CA /* ActivePostToolbarView.swift */,
|
||||||
1780F6EE25895EDB00FE45FF /* PostCommands.swift */,
|
1780F6EE25895EDB00FE45FF /* PostCommands.swift */,
|
||||||
|
3779389629EC0C880032D6C1 /* HelpCommands.swift */,
|
||||||
);
|
);
|
||||||
path = Navigation;
|
path = Navigation;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -970,6 +973,7 @@
|
|||||||
1727526728099802003D0A6A /* ErrorConstants.swift in Sources */,
|
1727526728099802003D0A6A /* ErrorConstants.swift in Sources */,
|
||||||
17479F152583D8E40072B7FB /* PostEditorSharingPicker.swift in Sources */,
|
17479F152583D8E40072B7FB /* PostEditorSharingPicker.swift in Sources */,
|
||||||
17480CA6251272EE00EB7765 /* Bundle+AppVersion.swift in Sources */,
|
17480CA6251272EE00EB7765 /* Bundle+AppVersion.swift in Sources */,
|
||||||
|
3779389729EC0C880032D6C1 /* HelpCommands.swift in Sources */,
|
||||||
17C42E662509237800072984 /* PostListFilteredView.swift in Sources */,
|
17C42E662509237800072984 /* PostListFilteredView.swift in Sources */,
|
||||||
17120DAD24E1B99F002B9F6C /* AccountLoginView.swift in Sources */,
|
17120DAD24E1B99F002B9F6C /* AccountLoginView.swift in Sources */,
|
||||||
17D4926727947D780035BD7E /* MacUpdatesViewModel.swift in Sources */,
|
17D4926727947D780035BD7E /* MacUpdatesViewModel.swift in Sources */,
|
||||||
@ -1278,7 +1282,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 707;
|
CURRENT_PROJECT_VERSION = 708;
|
||||||
DEVELOPMENT_TEAM = TPPAB4YBA6;
|
DEVELOPMENT_TEAM = TPPAB4YBA6;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
@ -1305,7 +1309,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 707;
|
CURRENT_PROJECT_VERSION = 708;
|
||||||
DEVELOPMENT_TEAM = TPPAB4YBA6;
|
DEVELOPMENT_TEAM = TPPAB4YBA6;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
47
macOS/Navigation/HelpCommands.swift
Normal file
47
macOS/Navigation/HelpCommands.swift
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct HelpCommands: Commands {
|
||||||
|
@ObservedObject var model: WriteFreelyModel
|
||||||
|
|
||||||
|
private let logger = Logging(for: String(describing: PostCommands.self))
|
||||||
|
|
||||||
|
var body: some Commands {
|
||||||
|
CommandGroup(replacing: .help) {
|
||||||
|
Button("Visit Support Forum") {
|
||||||
|
NSWorkspace().open(model.helpURL)
|
||||||
|
}
|
||||||
|
Button(action: createLogsPost, label: { Text("Generate Log for Support") })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func createLogsPost() {
|
||||||
|
logger.log("Generating local log post...")
|
||||||
|
|
||||||
|
// Show the spinner going in the post list
|
||||||
|
model.isProcessingRequest = true
|
||||||
|
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now()) {
|
||||||
|
// Unset selected post and collection and navigate to local drafts.
|
||||||
|
self.model.selectedPost = nil
|
||||||
|
self.model.selectedCollection = nil
|
||||||
|
self.model.showAllPosts = false
|
||||||
|
|
||||||
|
// Create the new log post.
|
||||||
|
let newLogPost = model.editor.generateNewLocalPost(withFont: 2)
|
||||||
|
newLogPost.title = "Logs For Support"
|
||||||
|
var postBody: [String] = [
|
||||||
|
"WriteFreely-Multiplatform v\(Bundle.main.appMarketingVersion) (\(Bundle.main.appBuildVersion))",
|
||||||
|
"Generated \(Date())",
|
||||||
|
""
|
||||||
|
]
|
||||||
|
postBody.append(contentsOf: logger.fetchLogs())
|
||||||
|
newLogPost.body = postBody.joined(separator: "\n")
|
||||||
|
|
||||||
|
// Hide the spinner in the post list and set the log post as active
|
||||||
|
self.model.isProcessingRequest = false
|
||||||
|
self.model.selectedPost = newLogPost
|
||||||
|
|
||||||
|
logger.log("Generated local log post.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user