Skip to content

Commit

Permalink
Merge branch 'force-migration-page' into 'master'
Browse files Browse the repository at this point in the history
Fix: Force migration for mac desktop users

See merge request kchat/webapp!837
  • Loading branch information
antonbuks committed Sep 9, 2024
2 parents 31b979f + 37607ba commit facbe29
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 3 deletions.
18 changes: 18 additions & 0 deletions webapp/channels/src/actions/views/root.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import type {ServerError} from '@mattermost/types/errors';

import {getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general';
import {redirectToErrorPageIfNecessary} from 'mattermost-redux/actions/helpers';
import {loadMe} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';
import type {ActionFuncAsync, ThunkActionFunc} from 'mattermost-redux/types/actions';
Expand All @@ -12,6 +15,7 @@ import {checkIKTokenIsExpired, refreshIKToken} from 'components/login/utils';

import {ActionTypes} from 'utils/constants';
import {isDesktopApp} from 'utils/user_agent';
import * as UserAgent from 'utils/user_agent';

import en from 'i18n/en.json';

Expand Down Expand Up @@ -39,6 +43,19 @@ export function loadConfigAndMe(): ActionFuncAsync<boolean> {
dispatch(getLicenseConfig()),
]);

let redirect = true;
if (!UserAgent.isMacApp() || !UserAgent.isNotMacMas()) {
redirect = false;
}

if (redirect) {
const forceMigrationError: ServerError = {
message: 'Maintenance mode',
status_code: 1,
};
redirectToErrorPageIfNecessary(forceMigrationError);
}

let isMeLoaded = false;

// if (document.cookie.includes('MMUSERID=')) {
Expand Down Expand Up @@ -118,3 +135,4 @@ export function registerCustomPostRenderer(type: string, component: any, id: str
return {data: true};
};
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React from 'react';

const SvgIlluMigration = (props) => {
return (
<svg
width='232'
height='232'
viewBox='0 0 232 232'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<g clipPath='url(#clip0_7665_53874)'>
<rect
y='130.135'
width='58.4874'
height='58.4874'
rx='29.2437'
fill='#106C89'
/>
<path
d='M17.9592 183.288C20.6669 180.489 20.6384 175.321 20.5054 171.733L30.2528 163.015L35.9056 183.488L43.0119 190.988L30.4808 203.465L10.2354 189.522L17.9592 183.288Z'
fill='#EECEB7'
/>
<path
d='M22.3003 176.14L35.8955 198.078L42.2038 188.76L35.8955 183.497L30.2427 163.015L22.3003 176.14Z'
fill='#E0A883'
/>
<path
d='M36.4584 150.974L40.5531 168.211L39.7075 178.69L32.1452 181.917L21.6376 175.759L19.12 166.86L15.5479 152.174L36.4584 150.974Z'
fill='#EECEB7'
/>
<path
d='M20.5916 167.497C20.5916 167.497 18.3875 165.289 16.7059 165.394C15.0243 165.498 14.8153 167.564 16.3924 169.477C17.9695 171.39 18.1785 172.76 21.1236 171.494C24.0688 170.229 20.5916 167.497 20.5916 167.497Z'
fill='#EECEB7'
/>
<path
d='M39.0126 168.487L37.9486 170.333L35.8965 169.543L39.0126 168.487Z'
fill='#E0A883'
/>
<path
d='M40.9421 140.37C35.8245 141.101 30.3411 140.736 17.9127 146.585C5.48436 152.433 15.7197 165.958 15.7197 165.958C16.8165 165.227 19.0096 165.958 19.7404 166.69L22.2993 166.324C20.5447 164.277 18.6438 157.673 17.9127 154.627C17.9127 154.627 20.8373 156.454 29.2449 156.089C38.0146 155.707 41.7951 148.656 43.1354 144.757C41.3808 145.634 37.5304 145.366 35.8245 145.122C39.6262 142.783 40.8203 140.979 40.9421 140.37Z'
fill='#D57290'
/>
</g>
<g clipPath='url(#clip1_7665_53874)'>
<rect
x='154.017'
y='95.0421'
width='77.9832'
height='77.9832'
rx='38.9916'
fill='#7BB4D1'
/>
<path
d='M187.715 170.63C183.816 149.185 173.093 136.025 165.782 129.689L168.707 125.79L177.967 122.866L199.9 121.403C200.55 130.989 201.265 151.622 198.925 157.471C196.586 163.319 190.477 168.681 187.715 170.63Z'
fill='#751648'
/>
<path
d='M201.814 139.158L209.921 156.557L221.764 163.277L230.049 180.009H193.568L193.125 159.577L187.462 142.179L201.814 139.158Z'
fill='#DAA28B'
/>
<path
d='M204.196 144.26L201.814 139.158L187.462 142.179L193.125 159.577L193.175 161.912C197.698 159.577 205.957 151.201 204.196 144.26Z'
fill='black'
fillOpacity='0.15'
/>
<path
d='M205.464 122.572C206.363 127.344 203.513 132.166 203.513 132.166C204.222 132.166 206.072 131.824 206.325 134.552C206.781 139.628 202.626 140.859 202.626 140.859C204.134 145.529 200.333 150.986 197.787 152.585C195.14 154.235 191.226 156.57 189.592 157.141C187.958 157.712 187.464 157.687 185.006 157.75C182.549 157.813 181.865 157.179 181.295 156.176C180.725 155.174 176.595 148.334 176.202 146.722C175.81 145.11 174.505 121.506 174.505 121.506C174.505 108.143 201.436 104.425 205.464 122.572Z'
fill='#DAA28B'
/>
<path
d='M180.243 146.037L182.422 148.372L184.411 146.037H180.243Z'
fill='#AD4D2D'
/>
<path
d='M182.841 128.226C176.992 125.789 171.143 125.302 165.782 129.688C161.493 115.651 171.468 109.868 176.992 108.731C184.79 100.445 202.337 100.445 214.034 111.655C223.392 120.623 223.782 130.014 222.807 133.588C220.357 134.741 216.974 139.227 215.009 141.874L209.16 127.739L213.415 143.823C211.434 147.269 209.956 150.769 209.16 153.084C206.629 150.85 204.301 147.076 202.291 142.848C200.643 139.38 199.208 135.606 198.05 132.126C196.923 128.739 196.058 125.631 195.513 123.352C193.239 125.789 187.52 130.176 182.841 128.226Z'
fill='#8C3665'
/>
</g>
<path
d='M56.8495 146.052L56.9243 145.983H57.0263H133.912C135.922 145.983 137.551 144.354 137.551 142.344V72.6218C137.551 70.6121 135.922 68.9829 133.912 68.9829H26.3205C24.3108 68.9829 22.6816 70.6121 22.6816 72.6218V142.344C22.6816 144.354 24.3108 145.983 26.3205 145.983H46.5727H46.833V146.243V155.319L56.8495 146.052Z'
fill='#F5F5F5'
stroke='#9F9F9F'
strokeWidth='0.520587'
/>
<path
d='M145.982 123.953L145.907 123.886H145.807H58.4875C56.4778 123.886 54.8487 122.257 54.8487 120.247V47.2773C54.8487 45.2676 56.4778 43.6385 58.4875 43.6385H177.412C179.422 43.6385 181.051 45.2676 181.051 47.2773V120.247C181.051 122.257 179.422 123.886 177.412 123.886H158.653H158.393V124.146V135.169L145.982 123.953Z'
fill='white'
stroke='#9F9F9F'
strokeWidth='0.520587'
/>
<circle
cx='102.353'
cy='84.3193'
r='3.89916'
fill='#7BB4D1'
/>
<circle
cx='117.95'
cy='84.3193'
r='3.89916'
fill='#7BB4D1'
/>
<circle
cx='133.547'
cy='84.3193'
r='3.89916'
fill='#7BB4D1'
/>
<defs>
<clipPath id='clip0_7665_53874'>
<rect
y='130.135'
width='58.4874'
height='58.4874'
rx='29.2437'
fill='white'
/>
</clipPath>
<clipPath id='clip1_7665_53874'>
<rect
x='154.017'
y='95.0421'
width='77.9832'
height='77.9832'
rx='38.9916'
fill='white'
/>
</clipPath>
</defs>
</svg>

);
};

export default SvgIlluMigration;
10 changes: 10 additions & 0 deletions webapp/channels/src/components/error_page/error_message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ const ErrorMessage: React.FC<Props> = ({type, message, service, isGuest}: Props)
</p>
);
break;
case ErrorPageTypes.FORCE_MIGRATION:
errorMessage = (
<p>
<FormattedMessage
id='error.force_migration.message'
defaultMessage='Your version of the application is no longer supported. Please download and install the new version to benefit from the latest improvements.'
/>
</p>
);
break;
case ErrorPageTypes.PAGE_NOT_FOUND:
default:
errorMessage = (
Expand Down
24 changes: 22 additions & 2 deletions webapp/channels/src/components/error_page/error_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import {Link} from 'react-router-dom';

import * as GlobalActions from 'actions/global_actions';

import {ErrorPageTypes} from 'utils/constants';

import kSuite from 'images/ik/kSuite.svg';
import MattermostLogoSvg from 'images/logo.svg';
import loaderkChat from 'images/logo_compact.png';
import NoTeamIcon from 'images/no_team_icon.png';
import {ErrorPageTypes, Constants} from 'utils/constants';
import {isDesktopApp} from 'utils/user_agent';

import SvgIlluErrorBlocked from './assets/SvgIlluErrorBlocked';
import SvgIlluErrorMaintenance from './assets/SvgIlluErrorMaintenance';
import SvgIlluMigration from './assets/SvgIlluErrorMigration';
import SvgIlluErrorQuestion from './assets/SvgIlluErrorQuestion';
import ErrorMessage from './error_message';
import ErrorTitle from './error_title';
Expand Down Expand Up @@ -77,6 +78,10 @@ export default class ErrorPage extends React.PureComponent<Props> {
}
};

const goToAppStore = () => {
window.open('https://apps.apple.com/app/infomaniak-kchat/id6443845553', '_blank');
};

const goToKsuite = () => {
if (window) {
window.open('https://infomaniak.com/ksuite', '_blank');
Expand Down Expand Up @@ -104,6 +109,7 @@ export default class ErrorPage extends React.PureComponent<Props> {
let backButton;
let secondaryButton;
let illustration: JSX.Element | null = <SvgIlluErrorQuestion/>;
const illustrationMigration: JSX.Element | null = <SvgIlluMigration/>;
let fullscreenIllustration;
if (type === ErrorPageTypes.PERMALINK_NOT_FOUND && returnTo) {
backButton = (
Expand Down Expand Up @@ -285,6 +291,20 @@ export default class ErrorPage extends React.PureComponent<Props> {
/>
</a>
);
} else if (type === ErrorPageTypes.FORCE_MIGRATION) {
illustration = illustrationMigration;
backButton = (
<a
className='btn btn-primary'
onClick={goToAppStore}
>
<FormattedMessage
id='error.generic.dl_link'
defaultMessage='Download the new version'

/>
</a>
);
} else {
backButton = (
<a
Expand Down
8 changes: 8 additions & 0 deletions webapp/channels/src/components/error_page/error_title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ const ErrorTitle: React.FC<Props> = ({type, title, groupName}: Props) => {
/>
);
break;
case ErrorPageTypes.FORCE_MIGRATION:
errorTitle = (
<FormattedMessage
id='error.force_migration.title'
defaultMessage='Download the new version of the kChat application'
/>
);
break;
case ErrorPageTypes.PAGE_NOT_FOUND:
default:
errorTitle = (
Expand Down
3 changes: 3 additions & 0 deletions webapp/channels/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3536,6 +3536,9 @@
"error.channel_not_found.message": "Der Kanal, den du anforderst ist privat oder existiert nicht. Bitte kontaktiere einen Administrator, um dem Kanal hinzugefügt zu werden.",
"error.channel_not_found.message_guest": "Dein Gastkonto ist keinem Kanal zugeordnet. Bitte kontaktiere einen Administrator.",
"error.channel_not_found.title": "Kanal nicht gefunden",
"error.force_migration.message": "Ihre Version der Anwendung wird nicht mehr unterstützt. Bitte laden Sie die neue Version herunter und installieren Sie sie, um von den neuesten Verbesserungen zu profitieren.",
"error.force_migration.title": "Laden Sie die neue Version der kChat-Anwendung herunter",
"error.generic.dl_link": "Laden Sie die neue Version herunter",
"error.generic.link": "Zurück zu {siteName}",
"error.generic.link_ksuite": "Entdecke kSuite",
"error.generic.link_login": "Zurück zur Anmeldeseite",
Expand Down
3 changes: 3 additions & 0 deletions webapp/channels/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3617,6 +3617,9 @@
"error.channel_not_found.title": "Channel Not Found",
"error.channelNotFound.guest_link": "Back",
"error.channelNotFound.link": "Back to {defaultChannelName}",
"error.force_migration.message": "Your version of the application is no longer supported. Please download and install the new version to benefit from the latest improvements.",
"error.force_migration.title": "Download the new version of the kChat application",
"error.generic.dl_link": "Download the new version",
"error.generic.link": "Back to {siteName}",
"error.generic.link_ksuite": "Discover kSuite",
"error.generic.link_login": "Back to Login Page",
Expand Down
3 changes: 3 additions & 0 deletions webapp/channels/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3193,6 +3193,9 @@
"error.channel_not_found.message": "El canal que estás solicitando es privado o no existe. Por favor contacta a un Administrador para ser agregado al canal.",
"error.channel_not_found.message_guest": "Tu cuenta de huésped no tiene canales asignados. Por favor contacta a un administrador.",
"error.channel_not_found.title": "Canal no encontrado",
"error.force_migration.message": "Su versión de la aplicación ya no es compatible. Por favor, descargue e instale la nueva versión para beneficiarse de las últimas mejoras.",
"error.force_migration.title": "Descargar la nueva versión de la aplicación kChat",
"error.generic.dl_link": "Descargar la nueva versión",
"error.generic.link": "Volver a {siteName}",
"error.generic.link_ksuite": "Descubra kSuite",
"error.generic.link_login": "Volver a la página de inicio de sesión",
Expand Down
3 changes: 3 additions & 0 deletions webapp/channels/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3162,6 +3162,9 @@
"error.channel_not_found.message": "Le canal que vous avez demandé est privé ou n'existe pas. Veuillez contacter un administrateur pour être rajouté à ce canal le cas échéant.",
"error.channel_not_found.message_guest": "Votre compte utilisateur invité n'a pas de canal assigné. Veuillez contacter un administrateur.",
"error.channel_not_found.title": "Canal introuvable",
"error.force_migration.message": "Votre version de l’application n’est plus supportée. Veuillez télécharger la nouvelle version et l’installer pour bénéficier des dernières améliorations.",
"error.force_migration.title": "Télécharger la nouvelle version de l’application kChat",
"error.generic.dl_link": "Télécharger la nouvelle version",
"error.generic.link": "Retour à {siteName}",
"error.generic.link_ksuite": "Découvrir kSuite",
"error.generic.link_login": "Retourner à la page de connexion",
Expand Down
3 changes: 3 additions & 0 deletions webapp/channels/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,9 @@
"error.channel_not_found.message": "Il canale richiesto è privato o non esiste. Contattare un Amministratore per essere aggiunto al canale.",
"error.channel_not_found.message_guest": "Il tuo account ospite non ha un canale assegnato. Contatta un amministratore.",
"error.channel_not_found.title": "Canale Non Trovato",
"error.force_migration.message": "La tua versione dell'applicazione non è più supportata. Si prega di scaricare e installare la nuova versione per beneficiare degli ultimi miglioramenti.",
"error.force_migration.title": "Scarica la nuova versione dell'applicazione kChat",
"error.generic.dl_link": "Scarica la nuova versione",
"error.generic.link": "Torna a {siteName}",
"error.generic.link_ksuite": "Scoprire kSuite",
"error.generic.link_login": "Torna alla pagina di accesso",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export function forceLogoutIfNecessary(err: ServerError, dispatch: DispatchFunc,
const statusCodes = {
HTTP_MAINTENANCE: 503,
HTTP_BLOCKED: 401,
FORCE_MIGRATION: 1,
};

function redirectToErrorPageIfNecessary(err: ServerError) {
export function redirectToErrorPageIfNecessary(err: ServerError) {
switch (err.status_code) {
case statusCodes.HTTP_MAINTENANCE:
getHistory().replace('/error?type=maintenance');
Expand All @@ -38,6 +39,9 @@ function redirectToErrorPageIfNecessary(err: ServerError) {
getHistory().replace('/error?type=blocked');
}
break;
case statusCodes.FORCE_MIGRATION:
getHistory().replace('/error?type=force_migration');
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ export const ErrorPageTypes = {
NO_KSUITE: 'no_ksuite',
MAINTENANCE: 'maintenance',
BLOCKED: 'blocked',
FORCE_MIGRATION: 'force_migration',
};

export const JobTypes = {
Expand Down

0 comments on commit facbe29

Please sign in to comment.