diff --git a/libs/remix-ui/git/src/components/github/devicecode.tsx b/libs/remix-ui/git/src/components/github/devicecode.tsx new file mode 100644 index 0000000000..59f574afcb --- /dev/null +++ b/libs/remix-ui/git/src/components/github/devicecode.tsx @@ -0,0 +1,30 @@ +import React, { useState } from 'react'; + +const GetDeviceCode = () => { + const [userCode, setUserCode] = useState(null); + + const requestDeviceCode = async () => { + const response = await fetch('http://localhost:3000/github.com/login/device/code', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + client_id: 'dccbc48453f7afa34fad', + scope: 'repo', // or another appropriate scope + }), + }); + + const data = await response.json(); + setUserCode(data.user_code); // Store user code to show to the user + }; + + return ( +
+ + {userCode &&
User Code: {userCode}
} +
+ ); +}; + +export default GetDeviceCode; diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 876fe9d1f3..40ec615d75 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -29,6 +29,7 @@ import { GitHubCredentials } from './panels/githubcredentials' import { loaderReducer } from '../state/loaderReducer' import { ApolloClient, ApolloProvider, NormalizedCacheObject } from '@apollo/client' import { client, getApolloLink } from '../state/apolloClient' +import GetDeviceCode from './github/devicecode' export const gitPluginContext = React.createContext(defaultGitState) export const loaderContext = React.createContext(defaultLoaderState) @@ -181,6 +182,7 @@ export const GitUI = (props: IGitUi) => { <> + diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index 4197d80032..f19c0075bf 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -186,15 +186,11 @@ export const currentBranch = async () => { export const createBranch = async (name: string = "") => { dispatch(setLoading(true)) - await disableCallBacks() - if (name) { await plugin.call("dGitProvider", "branch", { ref: name }); await plugin.call("dGitProvider", "checkout", { ref: name }); } - dispatch(setLoading(false)) - await enableCallBacks() } export const getCommitFromRef = async (ref: string) => {