From f382540a6d494be6d5bd665b1578f7023e515151 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 2 Nov 2020 17:25:14 +0000 Subject: [PATCH] indicate ability to browse collections in search results --- .../muwire/core/search/ResultsParser.groovy | 5 +++++ .../muwire/core/search/ResultsSender.groovy | 2 ++ .../muwire/core/search/UIResultEvent.groovy | 1 + .../com/muwire/gui/SearchTabController.groovy | 5 +++++ gui/griffon-app/i18n/messages.properties | 3 ++- .../com/muwire/gui/SearchTabModel.groovy | 1 + .../views/com/muwire/gui/SearchTabView.groovy | 18 +++++++++++++----- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy index b44f9a38..7662cfc5 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy @@ -101,6 +101,10 @@ class ResultsParser { if (json.browse != null) browse = json.browse + boolean browseCollections = false + if (json.browseCollections != null) + browseCollections = json.browseCollections + int certificates = 0 if (json.certificates != null) certificates = json.certificates @@ -121,6 +125,7 @@ class ResultsParser { sources : sources, comment : comment, browse : browse, + browseCollections : browseCollections, uuid: uuid, certificates : certificates, collections : collections) diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy index 5524ea66..4680fde1 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy @@ -90,6 +90,7 @@ class ResultsSender { pieceSize : pieceSize, uuid : uuid, browse : settings.browseFiles, + browseCollections : settings.browseFiles, sources : suggested, comment : comment, certificates : certificates, @@ -197,6 +198,7 @@ class ResultsSender { obj.comment = sf.getComment() obj.browse = browseFiles + obj.browseCollections = browseFiles obj.certificates = certificates obj.collections = collections.collect { Base64.encode(it.getRoot()) } obj diff --git a/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy b/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy index 23f4801a..a88eb3d4 100644 --- a/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy @@ -16,6 +16,7 @@ class UIResultEvent extends Event { int pieceSize String comment boolean browse + boolean browseCollections int certificates boolean chat boolean feed diff --git a/gui/griffon-app/controllers/com/muwire/gui/SearchTabController.groovy b/gui/griffon-app/controllers/com/muwire/gui/SearchTabController.groovy index 8c3bc4a7..57e74f5c 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/SearchTabController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/SearchTabController.groovy @@ -109,6 +109,11 @@ class SearchTabController { mvcGroup.createMVCGroup("browse", groupId, params) } + @ControllerAction + void browseCollections() { + + } + @ControllerAction void subscribe() { def sender = view.selectedSender() diff --git a/gui/griffon-app/i18n/messages.properties b/gui/griffon-app/i18n/messages.properties index e8eda691..c6cae0f1 100644 --- a/gui/griffon-app/i18n/messages.properties +++ b/gui/griffon-app/i18n/messages.properties @@ -226,7 +226,8 @@ DISTRUST_SEARCHER=Distrust searcher # Uploads popup menu SHOW_IN_LIBRARY=Show in library -BROWSE_HOST=Browse Host +BROWSE_HOST=Browse Files +BROWSE_COLLECTIONS=Browse Collections # Share files prompt SELECT_FILES_OR_DIRECTORIES_TO_SHARE=Select files or folders to share diff --git a/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy b/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy index 0a5d8faf..2d84c174 100644 --- a/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy @@ -22,6 +22,7 @@ class SearchTabModel { @Observable boolean downloadActionEnabled @Observable boolean trustButtonsEnabled @Observable boolean browseActionEnabled + @Observable boolean browseCollectionsActionEnabled @Observable boolean viewCommentActionEnabled @Observable boolean viewCertificatesActionEnabled @Observable boolean chatActionEnabled diff --git a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy index 81e65a83..d0b8e07d 100644 --- a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy @@ -75,6 +75,7 @@ class SearchTabView { closureColumn(header : trans("SENDER"), preferredWidth : 500, type: String, read : {row -> row.getHumanReadableName()}) closureColumn(header : trans("RESULTS"), preferredWidth : 20, type: Integer, read : {row -> model.sendersBucket[row].size()}) closureColumn(header : trans("BROWSE"), preferredWidth : 20, type: Boolean, read : {row -> model.sendersBucket[row].first().browse}) + closureColumn(header : trans("COLLECTIONS"), preferredWidth : 20, type: Boolean, read : {row -> model.sendersBucket[row].first().browseCollections}) closureColumn(header : trans("FEED"), preferredWidth : 20, type : Boolean, read : {row -> model.sendersBucket[row].first().feed}) closureColumn(header : trans("CHAT"), preferredWidth : 20, type : Boolean, read : {row -> model.sendersBucket[row].first().chat}) closureColumn(header : trans("TRUST_NOUN"), preferredWidth : 50, type: String, read : { row -> @@ -87,6 +88,7 @@ class SearchTabView { gridLayout(rows: 1, cols : 2) panel (border : etchedBorder()){ button(text : trans("BROWSE_HOST"), enabled : bind {model.browseActionEnabled}, browseAction) + button(text : trans("BROWSE_COLLECTIONS"), enabled : bind {model.browseCollectionsActionEnabled}, browseCollectionsAction) button(text : trans("SUBSCRIBE"), enabled : bind {model.subscribeActionEnabled}, subscribeAction) button(text : trans("CHAT"), enabled : bind{model.chatActionEnabled}, chatAction) } @@ -223,11 +225,12 @@ class SearchTabView { panel (border : etchedBorder()) { gridBagLayout() button(text : trans("BROWSE_HOST"), enabled : bind {model.browseActionEnabled}, constraints : gbc(gridx : 0, gridy : 0), browseAction) - button(text : trans("SUBSCRIBE"), enabled : bind {model.subscribeActionEnabled}, constraints : gbc(gridx : 1, gridy : 0), subscribeAction) - button(text : trans("CHAT"), enabled : bind{model.chatActionEnabled}, constraints : gbc(gridx : 2, gridy : 0), chatAction) - button(text : trans("VIEW_COMMENT"), enabled : bind {model.viewCommentActionEnabled}, constraints : gbc(gridx : 3, gridy : 0), showCommentAction) - button(text : trans("VIEW_CERTIFICATES"), enabled : bind {model.viewCertificatesActionEnabled}, constraints : gbc(gridx : 4, gridy : 0), viewCertificatesAction) - button(text : trans("VIEW_COLLECTIONS"), enabled : bind {model.viewCollectionsActionEnabled}, constraints : gbc(gridx : 5, gridy : 0), viewCollectionsAction) + button(text : trans("BROWSE_COLLECTIONS"), enabled : bind {model.browseCollectionsActionEnabled}, constraints : gbc(gridx : 1, gridy : 0), browseCollectionsAction) + button(text : trans("SUBSCRIBE"), enabled : bind {model.subscribeActionEnabled}, constraints : gbc(gridx : 2, gridy : 0), subscribeAction) + button(text : trans("CHAT"), enabled : bind{model.chatActionEnabled}, constraints : gbc(gridx : 3, gridy : 0), chatAction) + button(text : trans("VIEW_COMMENT"), enabled : bind {model.viewCommentActionEnabled}, constraints : gbc(gridx : 4, gridy : 0), showCommentAction) + button(text : trans("VIEW_CERTIFICATES"), enabled : bind {model.viewCertificatesActionEnabled}, constraints : gbc(gridx : 5, gridy : 0), viewCertificatesAction) + button(text : trans("VIEW_COLLECTIONS"), enabled : bind {model.viewCollectionsActionEnabled}, constraints : gbc(gridx : 6, gridy : 0), viewCollectionsAction) } panel (border : etchedBorder()) { button(text : trans("TRUST_VERB"), enabled: bind {model.trustButtonsEnabled }, trustAction) @@ -355,10 +358,12 @@ class SearchTabView { model.trustButtonsEnabled = false model.browseActionEnabled = false model.subscribeActionEnabled = false + model.browseCollectionsActionEnabled = false return } else { Persona sender = model.senders[row] model.browseActionEnabled = model.sendersBucket[sender].first().browse + model.browseCollectionsActionEnabled = model.sendersBucket[sender].first().browseCollections model.chatActionEnabled = model.sendersBucket[sender].first().chat model.subscribeActionEnabled = model.sendersBucket[sender].first().feed && model.core.feedManager.getFeed(sender) == null @@ -381,6 +386,7 @@ class SearchTabView { if (e == null) { model.trustButtonsEnabled = false model.browseActionEnabled = false + model.browseCollectionsActionEnabled = false model.chatActionEnabled = false model.viewCertificatesActionEnabled = false model.viewCollectionsActionEnabled = false @@ -416,6 +422,7 @@ class SearchTabView { int row = selectedSenderRow() if (row < 0 || model.senders2[row] == null) { model.browseActionEnabled = false + model.browseCollectionsActionEnabled = false model.chatActionEnabled = false model.subscribeActionEnabled = false model.viewCertificatesActionEnabled = false @@ -426,6 +433,7 @@ class SearchTabView { } UIResultEvent e = model.senders2[row] model.browseActionEnabled = e.browse + model.browseCollectionsActionEnabled = e.browseCollections model.chatActionEnabled = e.chat model.subscribeActionEnabled = e.feed && model.core.feedManager.getFeed(e.getSender()) == null model.trustButtonsEnabled = true