Skip to content

Commit

Permalink
NMC 1933 - Collabora customisation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TSI-amrutwaghmare committed Aug 27, 2024
1 parent 7a4bb44 commit 5821533
Show file tree
Hide file tree
Showing 9 changed files with 1,142 additions and 5 deletions.
142 changes: 142 additions & 0 deletions Tests/NextcloudUnitTests/CollaboraTestCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//
// CollaboraTestCase.swift
// NextcloudTests
//
// Created by A200073704 on 06/05/23.
// Copyright © 2023 Marino Faggiana. All rights reserved.
//

@testable import Nextcloud
import XCTest
import NextcloudKit

class CollaboraTestCase: XCTestCase {


override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testCollaboraDocumentIsPresent() {

var viewForDocument: NCMenuAction?

if let image = UIImage(named: "create_file_document") {
viewForDocument = NCMenuAction(title: NSLocalizedString("_create_new_document_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_new_document_", comment: "")
})
}

XCTAssertNotNil(viewForDocument)

}

func testCollaboraPresentationIsPresent() {

var viewForPresentation: NCMenuAction?

if let image = UIImage(named: "create_file_ppt") {
viewForPresentation = NCMenuAction(title: NSLocalizedString("_create_new_presentation_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
})
}

XCTAssertNotNil(viewForPresentation)

}

func testCollaboraSpreadsheetIsPresent() {

var viewForSpreadsheet: NCMenuAction?

if let image = UIImage(named: "create_file_xls") {
viewForSpreadsheet = NCMenuAction(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
})
}

XCTAssertNotNil(viewForSpreadsheet)

}

func testTextDocumentIsPresent() {

var textMenu: NCMenuAction?

if let image = UIImage(named: "file_txt_menu") {
textMenu = NCMenuAction(title: NSLocalizedString("_create_nextcloudtext_document_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
})
}

XCTAssertNotNil(textMenu)

}

func testTextDocumentAction() {

let text = NCGlobal.shared.actionTextDocument
XCTAssertNotNil(text, "Text Editor Should be opened")
}

func testTextFieldIsPresent() {

let storyboard = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? NCCreateFormUploadDocuments else {
return
}

// Verify that a text field is present in the view controller
let textFields = viewController.view.subviews.filter { $0 is UITextField }
XCTAssertFalse(textFields.isEmpty, "No text field found in NCCreateFormUploadDocuments")
}

func testSavePathFolder() {

let viewController = NCCreateFormUploadDocuments()

let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow

var row : XLFormRowDescriptor

// the section with the title "Folder Destination"

row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: "kNMCFolderCustomCellType", title: "")
row.action.formSelector = #selector(viewController.changeDestinationFolder(_:))

// Verify that section was found
XCTAssertNotNil(row, "Expected save path section to exist in form.")

}






}
2 changes: 1 addition & 1 deletion iOSClient/BrowserWeb/NCBrowserWeb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NCBrowserWeb: UIViewController {
buttonExit.isHidden = true
} else {
self.view.bringSubviewToFront(buttonExit)
let image = NCUtility().loadImage(named: "xmark", colors: [.systemBlue])
let image = NCUtility().loadImage(named: "xmark", colors: [NCBrandColor.shared.customer])
buttonExit.setImage(image, for: .normal)
}

Expand Down
41 changes: 37 additions & 4 deletions iOSClient/Data/NCManageDatabase+Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ extension tableMetadata {

// Return if is sharable
func isSharable() -> Bool {
if !NCGlobal.shared.capabilityFileSharingApiEnabled || (NCGlobal.shared.capabilityE2EEEnabled && isDirectoryE2EE) {
return false
}
guard NCGlobal.shared.capabilityE2EEEnabled, !isDirectoryE2EE, !e2eEncrypted else { return false }
return true
}
}
Expand Down Expand Up @@ -356,7 +354,14 @@ extension NCManageDatabase {
metadata.fileNameView = file.fileName
metadata.hasPreview = file.hasPreview
metadata.hidden = file.hidden
metadata.iconName = file.iconName
switch (file.fileName as NSString).pathExtension {
case "odg":
metadata.iconName = "diagram"
case "csv", "xlsm" :
metadata.iconName = "file_xls"
default:
metadata.iconName = file.iconName
}
metadata.mountType = file.mountType
metadata.name = file.name
metadata.note = file.note
Expand Down Expand Up @@ -1172,4 +1177,32 @@ extension NCManageDatabase {
}
return nil
}

func getMediaMetadatas(predicate: NSPredicate, sorted: String? = nil, ascending: Bool = false) -> ThreadSafeArray<tableMetadata>? {

do {
let realm = try Realm()
if let sorted {
var results: [tableMetadata] = []
switch NCKeychain().mediaSortDate {
case "date":
results = realm.objects(tableMetadata.self).filter(predicate).sorted { ($0.date as Date) > ($1.date as Date) }
case "creationDate":
results = realm.objects(tableMetadata.self).filter(predicate).sorted { ($0.creationDate as Date) > ($1.creationDate as Date) }
case "uploadDate":
results = realm.objects(tableMetadata.self).filter(predicate).sorted { ($0.uploadDate as Date) > ($1.uploadDate as Date) }
default:
let results = realm.objects(tableMetadata.self).filter(predicate)
return ThreadSafeArray(results.map { tableMetadata.init(value: $0) })
}
return ThreadSafeArray(results.map { tableMetadata.init(value: $0) })
} else {
let results = realm.objects(tableMetadata.self).filter(predicate)
return ThreadSafeArray(results.map { tableMetadata.init(value: $0) })
}
} catch let error as NSError {
NextcloudKit.shared.nkCommonInstance.writeLog("Could not access database: \(error)")
}
return nil
}
}
Loading

0 comments on commit 5821533

Please sign in to comment.