Skip to content

Commit

Permalink
Diff PR for tchap-4.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
estellecomment committed Mar 26, 2024
1 parent cfd5801 commit 04d353f
Show file tree
Hide file tree
Showing 65 changed files with 823 additions and 65 deletions.
4 changes: 4 additions & 0 deletions res/css/structures/_UserMenu.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ limitations under the License.
mask-image: url("$(res)/img/element-icons/settings.svg");
}

.mx_UserMenu_iconInfo::before {
mask-image: url("$(res)/img/element-icons/info.svg");
}

.mx_UserMenu_iconMessage::before {
mask-image: url("$(res)/img/element-icons/feedback.svg");
}
Expand Down
5 changes: 5 additions & 0 deletions res/css/views/auth/_CompleteSecurityBody.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ limitations under the License.
*/

.mx_CompleteSecurityBody {
/* :TCHAP:
width: 600px;
*/
width: 660px;
/* end :TCHAP: */

color: $authpage-primary-color;
background-color: $background;
border-radius: 4px;
Expand Down
3 changes: 3 additions & 0 deletions res/css/views/directory/_NetworkDropdown.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
.mx_NetworkDropdown_wrapper .mx_ContextualMenu {
.mx_GenericDropdownMenu_Option {
&.mx_GenericDropdownMenu_Option--header {
display:none;
padding-top: $spacing-12;
padding-bottom: $spacing-4;
min-width: 160px;
Expand Down Expand Up @@ -45,12 +46,14 @@ limitations under the License.
}

.mx_GenericDropdownMenu_divider {
display:none;
margin-top: $spacing-4;
margin-bottom: $spacing-4;
}
}

.mx_NetworkDropdown_addServer {
display:none;
font-weight: normal;
font-size: $font-15px;
}
Expand Down
14 changes: 14 additions & 0 deletions res/css/views/rooms/_RoomHeader.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,17 @@ limitations under the License.
.mx_RoomHeader .mx_BaseAvatar {
flex-shrink: 0;
}

/* :tchap: largely inspired from ;mx_RoomHeader_topic but I couldn't get this add-on to work with $variable */
.tc_RoomHeader_external {
color: var(--external-color);
width: 80px;
font-weight: 400;
font-size: 0.8125rem;
line-height: 0.8125rem;
max-height: calc(0.8125rem * 2);
overflow: hidden;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -webkit-box;
}
11 changes: 11 additions & 0 deletions src/IConfigOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,14 @@ export interface ISsoRedirectOptions {
immediate?: boolean;
on_welcome_page?: boolean;
}

/* :tchap:
* Add tchap specific options to IConfigOptions. Both interfaces get merged in compilation. https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces
* IConfigOptions declares which options can get retrieved with SdkConfig, if not declared SdkConfig complains it does not know the parameter.
*/
export interface IConfigOptions {
tchap_features?: {
feature_email_notification?:[string]//activate email notification on a list of home servers, ie : "dev01.tchap.incubateur.net"
}
}
//end :tchap:
13 changes: 13 additions & 0 deletions src/IdentityAuthClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from "./utils/IdentityServerUtils";
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
import { abbreviateUrl } from "./utils/UrlUtils";
import TchapUIFeature from "../../../src/tchap/util/TchapUIFeature";

export class AbortedIdentityActionError extends Error {}

Expand Down Expand Up @@ -135,6 +136,18 @@ export default class IdentityAuthClient {
throw e;
}

// :TCHAP: no need confirmation of Terms and Conditions to set a default identity server as we trust our backend servers
if (TchapUIFeature.autoAcceptTermsAndConditions){
if (
!this.tempClient &&
!doesAccountDataHaveIdentityServer(this.matrixClient)
) {
setToDefaultIdentityServer(this.matrixClient);
}
return;
}
// end :TCHAP:

if (
!this.tempClient &&
!doesAccountDataHaveIdentityServer(this.matrixClient) &&
Expand Down
14 changes: 14 additions & 0 deletions src/Terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import { logger } from "matrix-js-sdk/src/logger";

import Modal from "./Modal";
import TermsDialog from "./components/views/dialogs/TermsDialog";
import {
doesAccountDataHaveIdentityServer,
setToDefaultIdentityServer,
} from './utils/IdentityServerUtils';
import TchapUIFeature from "../../../src/tchap/util/TchapUIFeature";

export class TermsNotSignedError extends Error {}

Expand Down Expand Up @@ -83,6 +88,15 @@ export async function startTermsFlow(
services: Service[],
interactionCallback: TermsInteractionCallback = dialogTermsInteractionCallback,
): Promise<void> {
// :TCHAP: no need to go through Terms flow as we trust our backend servers
if (TchapUIFeature.autoAcceptTermsAndConditions){
if (!doesAccountDataHaveIdentityServer(client)) {
setToDefaultIdentityServer(client);
}
return;
}
// end :TCHAP:

const termsPromises = services.map((s) => client.getTerms(s.serviceType, s.baseUrl));

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,38 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
backupInfo ? await cli.getCrypto()?.isKeyBackupTrusted(backupInfo) : undefined;

const { forceReset } = this.props;
const phase = backupInfo && !forceReset ? Phase.Migrate : Phase.ChooseKeyPassphrase;
// :tchap: const phase = backupInfo && !forceReset ? Phase.Migrate : Phase.ChooseKeyPassphrase;
const phase = backupInfo && !forceReset ? Phase.Migrate : Phase.ShowKey;//:tchap: goes directly to showke

/* :TCHAP: remove
this.setState({
phase,
backupInfo,
backupTrustInfo,
});
end :TCHAP: */

// add :TCHAP:
if (phase === Phase.ShowKey) {
this.recoveryKey = await cli.createRecoveryKeyFromPassphrase();
this.setState({
phase,
backupInfo,
backupTrustInfo,
passPhraseKeySelected:SecureBackupSetupMethod.Key,
copied: false,
downloaded: false,
setPassphrase: false
});
} else {
//if phase is Phase.Migrate
this.setState({
phase,
backupInfo,
backupTrustInfo,
});
}
// end :TCHAP:

return backupTrustInfo;
} catch (e) {
Expand Down Expand Up @@ -744,10 +769,23 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
if (this.state.phase === Phase.ShowKey) {
continueButton = (
<DialogButtons
/* :TCHAP:
primaryButton={_t("action|continue")}
disabled={!this.state.downloaded && !this.state.copied && !this.state.setPassphrase}
*/
primaryButton={_t("I wrote down my code")}
primaryDisabled={!this.state.downloaded && !this.state.copied && !this.state.setPassphrase}
// end :TCHAP:

onPrimaryButtonClick={this.onShowKeyContinueClick}

/* :TCHAP:
hasCancel={false}
*/
hasCancel={true}
onCancel={this.onCancel}
cancelButtonClass="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_danger_outline"
// end :TCHAP:
/>
);
} else {
Expand All @@ -760,13 +798,18 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp

return (
<div>
{/* tchap: add this <p /> */}
<p>{_t("This is your recovery key")}</p>
<p><b>{_t("Warning: this is the only time this code will be displayed!")}</b></p>
{/* end tchap */}
<p>{_t("settings|key_backup|setup_secure_backup|security_key_safety_reminder")}</p>
<div className="mx_CreateSecretStorageDialog_primaryContainer mx_CreateSecretStorageDialog_recoveryKeyPrimarycontainer">
<div className="mx_CreateSecretStorageDialog_recoveryKeyContainer">
<div className="mx_CreateSecretStorageDialog_recoveryKey">
<code ref={this.recoveryKeyNode}>{this.recoveryKey?.encodedPrivateKey}</code>
</div>
<div className="mx_CreateSecretStorageDialog_recoveryKeyButtons">
{/* :TCHAP: remove
<AccessibleButton
kind="primary"
className="mx_Dialog_primary"
Expand All @@ -781,6 +824,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
copyButton: "",
})}
</span>
end :TCHAP: */}
<AccessibleButton
kind="primary"
className="mx_Dialog_primary mx_CreateSecretStorageDialog_recoveryKeyButtons_copyBtn"
Expand Down
10 changes: 10 additions & 0 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ import { checkSessionLockFree, getSessionLock } from "../../utils/SessionLock";
import { SessionLockStolenView } from "./auth/SessionLockStolenView";
import { ConfirmSessionLockTheftView } from "./auth/ConfirmSessionLockTheftView";
import { LoginSplashView } from "./auth/LoginSplashView";
import TchapUrls from "../../../../../src/tchap/util/TchapUrls"; // :TCHAP:

// legacy export
export { default as Views } from "../../Views";
Expand Down Expand Up @@ -1770,6 +1771,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
return;
}

//:tchap: add a screen to open user tab security
if (screen === TchapUrls.secureBackupFragment) {
//open the security tab
//there is no anchor to sauvegarde-automatique subection
const payload: OpenToTabPayload = { action: Action.ViewUserSettings, initialTabId: UserTab.Security };
dis.dispatch(payload);
} else
//:tchap: end

if (screen === "register") {
dis.dispatch({
action: "start_registration",
Expand Down
4 changes: 3 additions & 1 deletion src/components/structures/RoomSearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import ResizeNotifier from "../../utils/ResizeNotifier";
import MatrixClientContext from "../../contexts/MatrixClientContext";
import { RoomPermalinkCreator } from "../../utils/permalinks/Permalinks";
import RoomContext from "../../contexts/RoomContext";
import Tchapi18nUtils from "../../../../../src/tchap/i18n/Tchapi18nUtils";

const DEBUG = false;
let debuglog = function (msg: string): void {};
Expand Down Expand Up @@ -136,7 +137,8 @@ export const RoomSearchView = forwardRef<ScrollPanel, Props>(
logger.error("Search failed", error);
Modal.createDialog(ErrorDialog, {
title: _t("error_dialog|search_failed|title"),
description: error?.message ?? _t("error_dialog|search_failed|server_unavailable"),
// :TCHAP: description: error?.message ?? _t("error_dialog|search_failed|server_unavailable"),
description: error?.message ?? Tchapi18nUtils.getServerDownMessage(),
});
return false;
},
Expand Down
5 changes: 4 additions & 1 deletion src/components/structures/RoomStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import InlineSpinner from "../views/elements/InlineSpinner";
import MatrixClientContext from "../../contexts/MatrixClientContext";
import { RoomStatusBarUnsentMessages } from "./RoomStatusBarUnsentMessages";
import ExternalLink from "../views/elements/ExternalLink";
import Tchapi18nUtils from '../../../../../src/tchap/i18n/Tchapi18nUtils'; // :TCHAP:

const STATUS_BAR_HIDDEN = 0;
const STATUS_BAR_EXPANDED = 1;
Expand Down Expand Up @@ -270,7 +271,9 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
<WarningIcon width="24" height="24" />
<div>
<div className="mx_RoomStatusBar_connectionLostBar_title">
{_t("room|status_bar|server_connectivity_lost_title")}
{/* :TCHAP: _t("room|status_bar|server_connectivity_lost_title") */}
{Tchapi18nUtils.getServerDownMessage()}
{/* end :TCHAP: */}
</div>
<div className="mx_RoomStatusBar_connectionLostBar_desc">
{_t("room|status_bar|server_connectivity_lost_description")}
Expand Down
9 changes: 9 additions & 0 deletions src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ export default class UserMenu extends React.Component<IProps, IState> {
this.setState({ contextMenuPosition: null }); // also close the menu
};

private onOpenFAQPage = () => {
window.open("https://www.tchap.gouv.fr/faq", '_blank');
};

private onProvideFeedback = (ev: ButtonEvent): void => {
ev.preventDefault();
ev.stopPropagation();
Expand Down Expand Up @@ -382,6 +386,11 @@ export default class UserMenu extends React.Component<IProps, IState> {
onClick={(e) => this.onSettingsOpen(e)}
/>
{feedbackButton}
<IconizedContextMenuOption
iconClassName="mx_UserMenu_iconInfo"
label={_t("common|help")}
onClick={this.onOpenFAQPage}
/>
<IconizedContextMenuOption
className="mx_IconizedContextMenu_option_red"
iconClassName="mx_UserMenu_iconSignOut"
Expand Down
11 changes: 10 additions & 1 deletion src/components/structures/auth/CompleteSecurity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export default class CompleteSecurity extends React.Component<IProps, IState> {
return null;
} else if (phase === Phase.Intro) {
if (lostKeys) {
/* :tchap: hide anxious icon of warning
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />;
end :tchap: */
title = _t("encryption|verification|after_new_login|unable_to_verify");
} else {
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />;
Expand All @@ -92,9 +94,16 @@ export default class CompleteSecurity extends React.Component<IProps, IState> {

let skipButton;
if (phase === Phase.Intro || phase === Phase.ConfirmReset) {
// :Tchap: Condition to skip Phase.ConfirmSkip and its "Are you sure" modal after login for csss
const tchapOnSkipClick = phase === Phase.Intro ? this.props.onFinished : this.onSkipClick;
// end :Tchap:

skipButton = (
<AccessibleButton
onClick={this.onSkipClick}
// :tchap: remove onClick={this.onSkipClick}
// add instead
onClick={tchapOnSkipClick}
// end :tchap:
className="mx_CompleteSecurity_skip"
aria-label={_t("encryption|verification|after_new_login|skip_verification")}
/>
Expand Down
Loading

0 comments on commit 04d353f

Please sign in to comment.