From 2651aab502880a7681f41d853d0447bbb2626b20 Mon Sep 17 00:00:00 2001 From: ankur12-1610 Date: Tue, 16 Aug 2022 13:51:17 +0530 Subject: [PATCH] Resolved linting errors --- cypress/e2e/knocking/knocking.spec.ts | 12 ++++++++---- cypress/support/labs.ts | 8 ++++++++ src/TextForEvent.tsx | 4 ++++ src/components/views/dialogs/CreateRoomDialog.tsx | 3 +++ src/i18n/strings/en_EN.json | 1 + 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/knocking/knocking.spec.ts b/cypress/e2e/knocking/knocking.spec.ts index 800596bf1797..a2f9e9ea3bbf 100644 --- a/cypress/e2e/knocking/knocking.spec.ts +++ b/cypress/e2e/knocking/knocking.spec.ts @@ -14,7 +14,6 @@ limitations under the License. /// import { SynapseInstance } from "../../plugins/synapsedocker"; -import { MatrixClient } from "../../global"; import Chainable = Cypress.Chainable; function openCreateRoomDialog(): Chainable> { @@ -54,19 +53,24 @@ describe("Knocking", () => { cy.get(".mx_Dialog_primary").click(); }); - // Change room settings + // The room settings initially are set to Ask to join cy.openRoomSettings("Security & Privacy"); - cy.get(".mx_StyledRadioButton_content").contains("Ask to join").click(); cy.closeDialog(); //Check if the room settings are visible if labs flag is disabled cy.openUserSettings("Labs").within(() => { //disables labs flag feature cy.get("[aria-label='Knocking']").click(); + // cy.disableLabsFeature("feature_knocking"); }); cy.closeDialog(); - //the default joinRule is set to Private (invite only) + + //the default joinRule is set to Private (invite only) when the labs flag is disabled cy.openRoomSettings("Security & Privacy"); + cy.closeDialog(); + + // Click the expand link button to get more detailed view + cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").click(); cy.stopMeasuring("from-submit-to-room"); cy.get(".mx_RoomHeader_nametext").contains(name); diff --git a/cypress/support/labs.ts b/cypress/support/labs.ts index 3fff154e140c..16e6f038cde7 100644 --- a/cypress/support/labs.ts +++ b/cypress/support/labs.ts @@ -28,6 +28,7 @@ declare global { * @param feature labsFeature to enable (e.g. "feature_spotlight") */ enableLabsFeature(feature: string): Chainable; + disableLabsFeature(feature: string): Chainable; } } } @@ -38,5 +39,12 @@ Cypress.Commands.add("enableLabsFeature", (feature: string): Chainable => }).then(() => null); }); +Cypress.Commands.add("disableLabsFeature", (feature: string): Chainable => { + return cy.window({ log: false }).then(win => { + win.localStorage.removeItem(`mx_labs_feature_${feature}`); + win.localStorage.setItem(`mx_labs_feature_${feature}`, "false"); + }).then(() => null); +}); + // Needed to make this file a module export { }; diff --git a/src/TextForEvent.tsx b/src/TextForEvent.tsx index 9310391e3e22..c4fefc1e851a 100644 --- a/src/TextForEvent.tsx +++ b/src/TextForEvent.tsx @@ -235,6 +235,10 @@ function textForJoinRulesEvent(ev: MatrixEvent, allowJSX: boolean): () => Render return () => _t('%(senderDisplayName)s made the room invite only.', { senderDisplayName, }); + case JoinRule.Knock: + return () => _t('%(senderDisplayName)s made the room knock only.', { + senderDisplayName, + }); case JoinRule.Restricted: if (allowJSX) { return () => diff --git a/src/components/views/dialogs/CreateRoomDialog.tsx b/src/components/views/dialogs/CreateRoomDialog.tsx index 7c4ae3282893..53364d3f3bef 100644 --- a/src/components/views/dialogs/CreateRoomDialog.tsx +++ b/src/components/views/dialogs/CreateRoomDialog.tsx @@ -123,6 +123,9 @@ export default class CreateRoomDialog extends React.Component { opts.joinRule = JoinRule.Restricted; } + if (this.state.joinRule === JoinRule.Knock) { + opts.joinRule = JoinRule.Knock; + } return opts; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 0824d97271a9..6b822b08dd34 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -496,6 +496,7 @@ "%(senderDisplayName)s upgraded this room.": "%(senderDisplayName)s upgraded this room.", "%(senderDisplayName)s made the room public to whoever knows the link.": "%(senderDisplayName)s made the room public to whoever knows the link.", "%(senderDisplayName)s made the room invite only.": "%(senderDisplayName)s made the room invite only.", + "%(senderDisplayName)s made the room knock only.": "%(senderDisplayName)s made the room knock only.", "%(senderDisplayName)s changed who can join this room. View settings.": "%(senderDisplayName)s changed who can join this room. View settings.", "%(senderDisplayName)s changed who can join this room.": "%(senderDisplayName)s changed who can join this room.", "%(senderDisplayName)s changed the join rule to %(rule)s": "%(senderDisplayName)s changed the join rule to %(rule)s",