From d703d0e87f5fa67184cd563b79acb96f1afac998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Fri, 3 May 2024 17:51:25 +0200 Subject: [PATCH] feat(CreateChannelPopup): inherit the channel color from community color - if there's a valid community info and the color is non-empty, inherit it when creating a new channel - also fix the color picker button height - adjust the SB page with separate "create" and "edit" options Fixes #14570 --- storybook/pages/CreateChannelPopupPage.qml | 64 +++++++++++-------- .../Communities/controls/ColorPicker.qml | 1 + .../models/ChannelPermissionsModelEditor.qml | 2 +- .../Communities/popups/CreateChannelPopup.qml | 19 ++---- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/storybook/pages/CreateChannelPopupPage.qml b/storybook/pages/CreateChannelPopupPage.qml index 386b834772..2644ce3f79 100644 --- a/storybook/pages/CreateChannelPopupPage.qml +++ b/storybook/pages/CreateChannelPopupPage.qml @@ -49,18 +49,17 @@ SplitView { id: dialog anchors.centerIn: parent destroyOnClose: true - isEdit: true + isEdit: ctrlIsEdit.checked isDeleteable: isDeleteableCheckBox.checked isDiscordImport: isDiscordCheckBox.checked - chatId: "_general" - channelName: "general" - channelDescription: "general discussion" - channelColor: "#4360DF" + chatId: isEdit ? "_general" : "" + channelName: isEdit ? "general" : "" + channelDescription: isEdit ? "general discussion" : "" activeCommunity: QtObject { readonly property string id: "0x039c47e9837a1a7dcd00a6516399d0eb521ab0a92d512ca20a44ac6278bfdbb5c5" readonly property string name: "test-1" readonly property string image: ModelsData.icons.superRare - readonly property string color: "#4360DF" + readonly property string color: dialog.isEdit ? "#4360DF" : "green" readonly property int memberRole: 0 } assetsModel: AssetsModel {} @@ -68,9 +67,13 @@ SplitView { collectiblesModel: CollectiblesModel {} permissionsModel: ListModel { - id: permissionsModel + function belongsToChat(permissionId, chatId) { + return chatId === dialog.chatId + } + Component.onCompleted: { - append(PermissionsModel.channelsOnlyPermissionsModelData) + if (dialog.isEdit) + append(PermissionsModel.channelsOnlyPermissionsModelData) } } @@ -159,19 +162,19 @@ SplitView { } - onCreateCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId) { + onCreateCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet) { logs.logEvent("onCreateCommunityChannel", - ["chName", "chDescription", "chEmoji", "chColor", "chCategoryId"], arguments) + ["chName", "chDescription", "chEmoji", "chColor", "chCategoryId", + "viewOnlyCanAddReaction", "hideIfPermissionsNotMet"], arguments) } - onEditCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId) { + onEditCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet) { logs.logEvent("onEditCommunityChannel", - ["chName", "chDescription", "chEmoji", "chColor", "chCategoryId"], arguments) + ["chName", "chDescription", "chEmoji", "chColor", "chCategoryId", + "viewOnlyCanAddReaction", "hideIfPermissionsNotMet"], arguments) } - onDeleteCommunityChannel: () => { - logs.logEvent("onDeleteCommunityChannel") - } + onDeleteCommunityChannel: () => { logs.logEvent("onDeleteCommunityChannel") } } } } @@ -182,18 +185,29 @@ SplitView { logsView.logText: logs.logText - RowLayout { - CheckBox { + ColumnLayout { + RowLayout { + RadioButton { + text: "Create mode" + checked: true + } + RadioButton { + id: ctrlIsEdit + text: "Edit mode" + } + RadioButton { + id: isDiscordCheckBox + text: "isDiscordImport" + onToggled: { + if (!!dialog && dialog.opened) + dialog.close() + } + } + } + Switch { id: isDeleteableCheckBox text: "isDeleteable" - } - CheckBox { - id: isDiscordCheckBox - text: "isDiscordImport" - onToggled: { - if (!!dialog && dialog.opened) - dialog.close() - } + enabled: ctrlIsEdit.checked } } } diff --git a/ui/app/AppLayouts/Communities/controls/ColorPicker.qml b/ui/app/AppLayouts/Communities/controls/ColorPicker.qml index 7d0fa5db9c..86593dc600 100644 --- a/ui/app/AppLayouts/Communities/controls/ColorPicker.qml +++ b/ui/app/AppLayouts/Communities/controls/ColorPicker.qml @@ -28,6 +28,7 @@ ColumnLayout { StatusPickerButton { Layout.fillWidth: true + Layout.preferredHeight: 44 property string validationError: "" diff --git a/ui/app/AppLayouts/Communities/models/ChannelPermissionsModelEditor.qml b/ui/app/AppLayouts/Communities/models/ChannelPermissionsModelEditor.qml index 58e2b2594e..c9fb508b36 100644 --- a/ui/app/AppLayouts/Communities/models/ChannelPermissionsModelEditor.qml +++ b/ui/app/AppLayouts/Communities/models/ChannelPermissionsModelEditor.qml @@ -264,7 +264,7 @@ QtObject { // Channel permissions model containing the temporarely edited permissions property WritableProxyModel channelPermissionsModel: WritableProxyModel { - sourceModel: filteredPermissionsModel + sourceModel: d.filteredPermissionsModel } // Channels model containing the temporarely edited channel diff --git a/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml b/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml index 05daf48a50..bff0d6d623 100644 --- a/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml +++ b/ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml @@ -41,7 +41,7 @@ StatusStackModal { property string channelName: "" property string channelDescription: "" property string channelEmoji: "" - property string channelColor: "" + property string channelColor: d.communityDetails.color !== "" ? d.communityDetails.color : "" property bool emojiPopupOpened: false property var emojiPopup: null readonly property int communityColorValidator: Utils.Validate.NoEmpty @@ -103,7 +103,7 @@ StatusStackModal { d.hideIfPermissionsNotMet !== root.hideIfPermissionsNotMet || nameInput.input.text !== root.channelName || descriptionTextArea.text !== root.channelDescription || - colorPanel.color.toString().toUpperCase() !== root.channelColor || + !Qt.colorEqual(colorPanel.color, root.channelColor) || nameInput.input.asset.emoji !== root.channelEmoji property int currentPage: CreateChannelPopup.CurrentPage.ChannelDetails @@ -252,8 +252,6 @@ StatusStackModal { nextButton: StatusButton { objectName: "createOrEditCommunityChannelBtn" - font.weight: Font.Medium - height: 44 visible: !d.colorPickerOpened enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext text: !!currentItem.nextButtonText ? currentItem.nextButtonText : @@ -271,8 +269,6 @@ StatusStackModal { finishButton: StatusButton { objectName: "createChannelNextBtn" - font.weight: Font.Medium - height: 44 text: (typeof currentItem.nextButtonText !== "undefined") ? currentItem.nextButtonText : qsTr("Import chat history") enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext @@ -289,9 +285,7 @@ StatusStackModal { } readonly property StatusButton clearFilesButton: StatusButton { - font.weight: Font.Medium text: qsTr("Clear all") - height: 44 type: StatusBaseButton.Type.Danger visible: typeof currentItem.isFileListView !== "undefined" && currentItem.isFileListView enabled: !fileListView.fileListModelEmpty && !root.communitiesStore.discordDataExtractionInProgress @@ -348,7 +342,6 @@ StatusStackModal { if (root.channelEmoji) { nameInput.input.asset.emoji = root.channelEmoji } - colorPanel.color = root.channelColor } else { nameInput.input.asset.isLetterIdenticon = true; } @@ -452,7 +445,6 @@ StatusStackModal { horizontalAlignment: Qt.AlignHCenter text: qsTr("Refer to this documentation if you have any queries") onLinkActivated: Global.openLink(link) - onHoveredLinkChanged: print(hoveredLink) MouseArea { anchors.fill: parent acceptedButtons: Qt.NoButton @@ -705,7 +697,7 @@ StatusStackModal { input.letterIconName = text } } - input.asset.color: colorPanel.color.toString() + input.asset.color: colorPanel.color input.rightComponent: StatusRoundButton { objectName: "StatusChannelPopup_emojiButton" implicitWidth: 32 @@ -747,6 +739,7 @@ StatusStackModal { property string validationError: "" width: parent.width + height: 44 anchors.bottom: parent.bottom bgColor: colorPanel.colorSelected ? colorPanel.color : Theme.palette.baseColor2 contentColor: colorPanel.colorSelected ? Theme.palette.white : Theme.palette.baseColor1 @@ -909,8 +902,8 @@ StatusStackModal { leftPadding: 16 rightPadding: 16 height: Math.min(parent.height, 624) - property bool colorSelected: root.isEdit && root.channelColor - color: root.isEdit && root.channelColor ? root.channelColor : Theme.palette.primaryColor1 + property bool colorSelected: !!root.channelColor && root.channelColor != Theme.palette.primaryColor1 + color: root.channelColor || Theme.palette.primaryColor1 onAccepted: { colorSelected = true; d.colorPickerOpened = false; d.currentPage = CreateChannelPopup.CurrentPage.ChannelDetails; }