-
-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ServerCompatNotice: Add, to nag users connected to servers <2.0.0.
As the jsdoc says, at some point we'll settle on a non-hard-coded threshold; see https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/compatibility.20documentation/near/1174966.
- Loading branch information
1 parent
4156248
commit 998fad6
Showing
4 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* @flow strict-local */ | ||
|
||
import React, { useContext } from 'react'; | ||
import { View, Pressable } from 'react-native'; | ||
import Color from 'color'; | ||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
|
||
import { createStyleSheet, HALF_COLOR, ThemeContext } from '../styles'; | ||
import { useSelector, useDispatch } from '../react-redux'; | ||
import Label from './Label'; | ||
import RawLabel from './RawLabel'; | ||
import { Icon } from './Icons'; | ||
import { getActiveAccount } from '../account/accountsSelectors'; | ||
import WebLink from './WebLink'; | ||
import { getSession } from '../directSelectors'; | ||
import { dismissCompatNotice } from '../session/sessionActions'; | ||
|
||
const styles = createStyleSheet({ | ||
wrapper: { | ||
flexDirection: 'row', | ||
justifyContent: 'flex-start', | ||
alignItems: 'center', | ||
backgroundColor: HALF_COLOR, | ||
}, | ||
}); | ||
|
||
type Props = $ReadOnly<{||}>; | ||
|
||
/** | ||
* A "nag banner" saying that the server version is unsupported. | ||
* | ||
* Currently just checks if it's less than 2.0.0. In the future, this | ||
* won't be so hard-coded; we'll use a timer or something. | ||
*/ | ||
export default function ServerCompatNotice(props: Props) { | ||
const dispatch = useDispatch(); | ||
const hasDismissedServerCompatNotice = useSelector( | ||
state => getSession(state).hasDismissedServerCompatNotice, | ||
); | ||
const zulipVersion = useSelector(state => getActiveAccount(state).zulipVersion); | ||
const realm = useSelector(state => getActiveAccount(state).realm); | ||
|
||
const { color } = useContext(ThemeContext); | ||
|
||
if (zulipVersion && !zulipVersion.isAtLeast('2.0.0') && !hasDismissedServerCompatNotice) { | ||
return ( | ||
<SafeAreaView mode="padding" edges={['right', 'left']} style={styles.wrapper}> | ||
<Pressable | ||
onPress={() => { | ||
dispatch(dismissCompatNotice()); | ||
}} | ||
hitSlop={12} | ||
style={{ margin: 12 }} | ||
> | ||
{({ pressed }) => ( | ||
<Icon | ||
size={24} | ||
color={Color(color) | ||
.fade(pressed ? 0.75 : 0) | ||
.toString()} | ||
name="x" | ||
/> | ||
)} | ||
</Pressable> | ||
<View style={{ flex: 1, paddingVertical: 4, paddingRight: 4 }}> | ||
<RawLabel> | ||
<Label | ||
text={{ | ||
text: | ||
'{realm} is running Zulip Server {serverVersionRaw}, which is unsupported. Please contact your administrator about upgrading.', | ||
values: { realm: realm.toString(), serverVersionRaw: zulipVersion.raw() }, | ||
}} | ||
/> | ||
{' '} | ||
<WebLink | ||
label="Learn more" | ||
url={ | ||
new URL('https://zulip.readthedocs.io/en/stable/overview/release-lifecycle.html') | ||
} | ||
/> | ||
</RawLabel> | ||
</View> | ||
</SafeAreaView> | ||
); | ||
} else { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters