Paste oauth token using deeplink
Reviewed By: passy Differential Revision: D28790868 fbshipit-source-id: 6a22809444462af15915fa4f06e76e64ebb7f590
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cf14f0808f
commit
fff489091e
@@ -51,7 +51,6 @@
|
|||||||
"promise-retry": "^2.0.1",
|
"promise-retry": "^2.0.1",
|
||||||
"promisify-child-process": "^4.1.0",
|
"promisify-child-process": "^4.1.0",
|
||||||
"prop-types": "^15.6.0",
|
"prop-types": "^15.6.0",
|
||||||
"query-string": "^7.0.0",
|
|
||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
"react-async": "^10.0.0",
|
"react-async": "^10.0.0",
|
||||||
"react-debounce-render": "^7.0.0",
|
"react-debounce-render": "^7.0.0",
|
||||||
|
|||||||
@@ -8,7 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {remote, ipcRenderer, IpcRendererEvent} from 'electron';
|
import {remote, ipcRenderer, IpcRendererEvent} from 'electron';
|
||||||
import {toggleAction} from '../reducers/application';
|
import {
|
||||||
|
ACTIVE_SHEET_SIGN_IN,
|
||||||
|
setActiveSheet,
|
||||||
|
setPastedToken,
|
||||||
|
toggleAction,
|
||||||
|
} from '../reducers/application';
|
||||||
import {Group, SUPPORTED_GROUPS} from '../reducers/supportForm';
|
import {Group, SUPPORTED_GROUPS} from '../reducers/supportForm';
|
||||||
import {Store} from '../reducers/index';
|
import {Store} from '../reducers/index';
|
||||||
import {Logger} from '../fb-interfaces/Logger';
|
import {Logger} from '../fb-interfaces/Logger';
|
||||||
@@ -20,7 +25,6 @@ import {
|
|||||||
} from '../utils/exportData';
|
} from '../utils/exportData';
|
||||||
import {tryCatchReportPlatformFailures} from '../utils/metrics';
|
import {tryCatchReportPlatformFailures} from '../utils/metrics';
|
||||||
import {selectPlugin} from '../reducers/connections';
|
import {selectPlugin} from '../reducers/connections';
|
||||||
import qs from 'query-string';
|
|
||||||
|
|
||||||
export const uriComponents = (url: string): Array<string> => {
|
export const uriComponents = (url: string): Array<string> => {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
@@ -74,9 +78,11 @@ export default (store: Store, _logger: Logger) => {
|
|||||||
'flipper-protocol-handler',
|
'flipper-protocol-handler',
|
||||||
(_event: IpcRendererEvent, query: string) => {
|
(_event: IpcRendererEvent, query: string) => {
|
||||||
const uri = new URL(query);
|
const uri = new URL(query);
|
||||||
if (query.startsWith('flipper://import')) {
|
if (uri.protocol !== 'flipper:') {
|
||||||
const {search} = new URL(query);
|
return;
|
||||||
const {url} = qs.parse(search);
|
}
|
||||||
|
if (uri.pathname.match(/^\/*import\/*$/)) {
|
||||||
|
const url = uri.searchParams.get('url');
|
||||||
store.dispatch(toggleAction('downloadingImportData', true));
|
store.dispatch(toggleAction('downloadingImportData', true));
|
||||||
return (
|
return (
|
||||||
typeof url === 'string' &&
|
typeof url === 'string' &&
|
||||||
@@ -91,16 +97,20 @@ export default (store: Store, _logger: Logger) => {
|
|||||||
store.dispatch(toggleAction('downloadingImportData', false));
|
store.dispatch(toggleAction('downloadingImportData', false));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (uri.pathname.match(/^\/*support-form\/*$/)) {
|
||||||
uri.protocol === 'flipper:' &&
|
|
||||||
uri.pathname.includes('support-form')
|
|
||||||
) {
|
|
||||||
const formParam = uri.searchParams.get('form');
|
const formParam = uri.searchParams.get('form');
|
||||||
const grp = deeplinkFormParamToGroups(formParam);
|
const grp = deeplinkFormParamToGroups(formParam);
|
||||||
if (grp) {
|
if (grp) {
|
||||||
grp.handleSupportFormDeeplinks(store);
|
grp.handleSupportFormDeeplinks(store);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else if (uri.pathname.match(/^\/*login\/*$/)) {
|
||||||
|
const token = uri.searchParams.get('token');
|
||||||
|
store.dispatch(setPastedToken(token ?? undefined));
|
||||||
|
if (store.getState().application.activeSheet !== ACTIVE_SHEET_SIGN_IN) {
|
||||||
|
store.dispatch(setActiveSheet(ACTIVE_SHEET_SIGN_IN));
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const match = uriComponents(query);
|
const match = uriComponents(query);
|
||||||
if (match.length > 1) {
|
if (match.length > 1) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {v1 as uuidv1} from 'uuid';
|
|||||||
import {ReactElement} from 'react';
|
import {ReactElement} from 'react';
|
||||||
import CancellableExportStatus from '../chrome/CancellableExportStatus';
|
import CancellableExportStatus from '../chrome/CancellableExportStatus';
|
||||||
import {Actions} from './';
|
import {Actions} from './';
|
||||||
|
import produce from 'immer';
|
||||||
export const ACTIVE_SHEET_PLUGIN_SHEET: 'PLUGIN_SHEET' = 'PLUGIN_SHEET';
|
export const ACTIVE_SHEET_PLUGIN_SHEET: 'PLUGIN_SHEET' = 'PLUGIN_SHEET';
|
||||||
export const ACTIVE_SHEET_PLUGINS: 'PLUGINS' = 'PLUGINS';
|
export const ACTIVE_SHEET_PLUGINS: 'PLUGINS' = 'PLUGINS';
|
||||||
export const ACTIVE_SHEET_SELECT_PLUGINS_TO_EXPORT: 'SELECT_PLUGINS_TO_EXPORT' =
|
export const ACTIVE_SHEET_SELECT_PLUGINS_TO_EXPORT: 'SELECT_PLUGINS_TO_EXPORT' =
|
||||||
@@ -87,6 +88,7 @@ export type State = {
|
|||||||
launcherMsg: LauncherMsg;
|
launcherMsg: LauncherMsg;
|
||||||
statusMessages: Array<string>;
|
statusMessages: Array<string>;
|
||||||
xcodeCommandLineToolsDetected: boolean;
|
xcodeCommandLineToolsDetected: boolean;
|
||||||
|
pastedToken?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type BooleanActionType =
|
type BooleanActionType =
|
||||||
@@ -154,6 +156,10 @@ export type Action =
|
|||||||
payload: {
|
payload: {
|
||||||
isDetected: boolean;
|
isDetected: boolean;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'SET_PASTED_TOKEN';
|
||||||
|
payload?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initialState: () => State = () => ({
|
export const initialState: () => State = () => ({
|
||||||
@@ -288,6 +294,10 @@ export default function reducer(
|
|||||||
return state;
|
return state;
|
||||||
} else if (action.type === 'SET_XCODE_DETECTED') {
|
} else if (action.type === 'SET_XCODE_DETECTED') {
|
||||||
return {...state, xcodeCommandLineToolsDetected: action.payload.isDetected};
|
return {...state, xcodeCommandLineToolsDetected: action.payload.isDetected};
|
||||||
|
} else if (action.type === 'SET_PASTED_TOKEN') {
|
||||||
|
return produce(state, (draft) => {
|
||||||
|
draft.pastedToken = action.payload;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -366,3 +376,8 @@ export const setXcodeDetected = (isDetected: boolean): Action => ({
|
|||||||
type: 'SET_XCODE_DETECTED',
|
type: 'SET_XCODE_DETECTED',
|
||||||
payload: {isDetected},
|
payload: {isDetected},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const setPastedToken = (pastedToken?: string): Action => ({
|
||||||
|
type: 'SET_PASTED_TOKEN',
|
||||||
|
payload: pastedToken,
|
||||||
|
});
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import {SidebarLeft, SidebarRight} from './SandyIcons';
|
|||||||
import {useDispatch, useStore} from '../utils/useStore';
|
import {useDispatch, useStore} from '../utils/useStore';
|
||||||
import {
|
import {
|
||||||
ACTIVE_SHEET_PLUGINS,
|
ACTIVE_SHEET_PLUGINS,
|
||||||
|
ACTIVE_SHEET_SIGN_IN,
|
||||||
setActiveSheet,
|
setActiveSheet,
|
||||||
toggleLeftSidebarVisible,
|
toggleLeftSidebarVisible,
|
||||||
toggleRightSidebarVisible,
|
toggleRightSidebarVisible,
|
||||||
@@ -39,7 +40,6 @@ import {theme, Layout, withTrackingScope} from 'flipper-plugin';
|
|||||||
import SetupDoctorScreen, {checkHasNewProblem} from './SetupDoctorScreen';
|
import SetupDoctorScreen, {checkHasNewProblem} from './SetupDoctorScreen';
|
||||||
import SettingsSheet from '../chrome/SettingsSheet';
|
import SettingsSheet from '../chrome/SettingsSheet';
|
||||||
import WelcomeScreen from './WelcomeScreen';
|
import WelcomeScreen from './WelcomeScreen';
|
||||||
import SignInSheet from '../chrome/fb-stubs/SignInSheet';
|
|
||||||
import {errorCounterAtom} from '../chrome/ConsoleLogs';
|
import {errorCounterAtom} from '../chrome/ConsoleLogs';
|
||||||
import {ToplevelProps} from './SandyApp';
|
import {ToplevelProps} from './SandyApp';
|
||||||
import {useValue} from 'flipper-plugin';
|
import {useValue} from 'flipper-plugin';
|
||||||
@@ -370,9 +370,10 @@ function LoginButton() {
|
|||||||
const user = useStore((state) => state.user);
|
const user = useStore((state) => state.user);
|
||||||
const login = (user?.id ?? null) !== null;
|
const login = (user?.id ?? null) !== null;
|
||||||
const profileUrl = user?.profile_picture?.uri;
|
const profileUrl = user?.profile_picture?.uri;
|
||||||
const [showLogin, setShowLogin] = useState(false);
|
const showLogin = useCallback(() => {
|
||||||
|
dispatch(setActiveSheet(ACTIVE_SHEET_SIGN_IN));
|
||||||
|
}, [dispatch]);
|
||||||
const [showLogout, setShowLogout] = useState(false);
|
const [showLogout, setShowLogout] = useState(false);
|
||||||
const onClose = useCallback(() => setShowLogin(false), []);
|
|
||||||
const onHandleVisibleChange = useCallback(
|
const onHandleVisibleChange = useCallback(
|
||||||
(visible) => setShowLogout(visible),
|
(visible) => setShowLogout(visible),
|
||||||
[],
|
[],
|
||||||
@@ -385,10 +386,11 @@ function LoginButton() {
|
|||||||
error instanceof UserUnauthorizedError ||
|
error instanceof UserUnauthorizedError ||
|
||||||
error instanceof UserNotSignedInError
|
error instanceof UserNotSignedInError
|
||||||
) {
|
) {
|
||||||
setShowLogin(true);
|
showLogin();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return login ? (
|
return login ? (
|
||||||
@@ -418,9 +420,8 @@ function LoginButton() {
|
|||||||
<LeftRailButton
|
<LeftRailButton
|
||||||
icon={<LoginOutlined />}
|
icon={<LoginOutlined />}
|
||||||
title="Log In"
|
title="Log In"
|
||||||
onClick={() => setShowLogin(true)}
|
onClick={showLogin}
|
||||||
/>
|
/>
|
||||||
{showLogin && <SignInSheet onHide={onClose} />}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6691,11 +6691,6 @@ fill-range@^7.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
to-regex-range "^5.0.1"
|
to-regex-range "^5.0.1"
|
||||||
|
|
||||||
filter-obj@^1.1.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-1.1.0.tgz#9b311112bc6c6127a16e016c6c5d7f19e0805c5b"
|
|
||||||
integrity sha1-mzERErxsYSehbgFsbF1/GeCAXFs=
|
|
||||||
|
|
||||||
finalhandler@1.1.2, finalhandler@~1.1.2:
|
finalhandler@1.1.2, finalhandler@~1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d"
|
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d"
|
||||||
@@ -10887,16 +10882,6 @@ qs@~6.5.2:
|
|||||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||||
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
|
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
|
||||||
|
|
||||||
query-string@^7.0.0:
|
|
||||||
version "7.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-7.0.0.tgz#aaad2c8d5c6a6d0c6afada877fecbd56af79e609"
|
|
||||||
integrity sha512-Iy7moLybliR5ZgrK/1R3vjrXq03S13Vz4Rbm5Jg3EFq1LUmQppto0qtXz4vqZ386MSRjZgnTSZ9QC+NZOSd/XA==
|
|
||||||
dependencies:
|
|
||||||
decode-uri-component "^0.2.0"
|
|
||||||
filter-obj "^1.1.0"
|
|
||||||
split-on-first "^1.0.0"
|
|
||||||
strict-uri-encode "^2.0.0"
|
|
||||||
|
|
||||||
querystring@0.2.1:
|
querystring@0.2.1:
|
||||||
version "0.2.1"
|
version "0.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd"
|
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd"
|
||||||
@@ -12530,11 +12515,6 @@ spectron@^14.0.0:
|
|||||||
split "^1.0.1"
|
split "^1.0.1"
|
||||||
webdriverio "^6.9.1"
|
webdriverio "^6.9.1"
|
||||||
|
|
||||||
split-on-first@^1.0.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
|
|
||||||
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==
|
|
||||||
|
|
||||||
split-string@^3.0.1, split-string@^3.0.2:
|
split-string@^3.0.1, split-string@^3.0.2:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
|
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
|
||||||
@@ -12628,11 +12608,6 @@ stealthy-require@^1.1.1:
|
|||||||
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
|
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
|
||||||
integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=
|
integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=
|
||||||
|
|
||||||
strict-uri-encode@^2.0.0:
|
|
||||||
version "2.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
|
|
||||||
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=
|
|
||||||
|
|
||||||
string-convert@^0.2.0:
|
string-convert@^0.2.0:
|
||||||
version "0.2.1"
|
version "0.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
|
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
|
||||||
|
|||||||
Reference in New Issue
Block a user