* feat: add shared server password to server setup
* feat: allow editing the sever
* refactor: changed password -> secret, styling and tests
* e2e: draft e2e tests
* chore: lint fix
* feat: also send preauth secret header when using native share
* fix: removed unused server database migration
credentials are being stored in the keychain
* i18n: added missing english translations
* test(e2e): simplified connection tests
* test(e2e): rework
* refactor: remove setBearerToken
* chore: restore migrations the way it was
* chore: reverted file to original state
* chore: removed unneeded test and renamed password to secret
* chore: function version
* chore: updated forms i18n keys
* chore: remove if from test
* chore: unneeded variable
* fix: add missing key on object list
* refactor: swift keychain access to retrieve all credentials in one call
* revert: edit server screen
* refactor: credentials use getGenericCredential
* fix: objc code calling old method
* fix: added scroll to login screen
* chore: variable names
* fix: avoid inline styles
* fix: Improved appVersion positioning
* Update app/screens/server/form.tsx
* feat: show error message on 403
* Revert "feat: show error message on 403"
This reverts commit f41630c767e10211adf1885321ceefd8a0931e32.
---------
(cherry picked from commit f50056f57b)
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {useCallback} from 'react';
|
|
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
|
|
import CompassIcon from '@components/compass_icon';
|
|
import {getServerCredentials} from '@init/credentials';
|
|
import {useShareExtensionState} from '@share/state';
|
|
import {changeOpacity} from '@utils/theme';
|
|
|
|
type Props = {
|
|
theme: Theme;
|
|
}
|
|
|
|
const hitSlop = {top: 10, left: 10, right: 10, bottom: 10};
|
|
|
|
const styles = StyleSheet.create({
|
|
right: {
|
|
marginRight: 10,
|
|
},
|
|
});
|
|
|
|
const PostButton = ({theme}: Props) => {
|
|
const {
|
|
closeExtension, channelId, files, globalError,
|
|
linkPreviewUrl, message, serverUrl, userId,
|
|
} = useShareExtensionState();
|
|
|
|
const disabled = !serverUrl || !channelId || (!message && !files.length && !linkPreviewUrl) || globalError;
|
|
|
|
const onPress = useCallback(async () => {
|
|
if (!serverUrl || !channelId || !userId) {
|
|
return;
|
|
}
|
|
|
|
let text = message || '';
|
|
if (linkPreviewUrl) {
|
|
if (text) {
|
|
text = `${text}\n\n${linkPreviewUrl}`;
|
|
} else {
|
|
text = linkPreviewUrl;
|
|
}
|
|
}
|
|
|
|
const credentials = await getServerCredentials(serverUrl);
|
|
|
|
if (credentials?.token) {
|
|
closeExtension({
|
|
serverUrl,
|
|
token: credentials.token,
|
|
channelId,
|
|
files,
|
|
message: text,
|
|
userId,
|
|
preauthSecret: credentials.preauthSecret,
|
|
});
|
|
}
|
|
}, [serverUrl, channelId, message, files, linkPreviewUrl, userId]);
|
|
|
|
return (
|
|
<TouchableOpacity
|
|
disabled={disabled}
|
|
onPress={onPress}
|
|
hitSlop={hitSlop}
|
|
>
|
|
<View style={[styles.right]}>
|
|
<CompassIcon
|
|
name='send'
|
|
color={changeOpacity(theme.sidebarHeaderTextColor, disabled ? 0.16 : 1)}
|
|
size={24}
|
|
/>
|
|
</View>
|
|
</TouchableOpacity>
|
|
);
|
|
};
|
|
|
|
export default PostButton;
|