add device code

git4refactor
filip mertens 7 months ago
parent be0be4c078
commit 777f635f75
  1. 30
      libs/remix-ui/git/src/components/github/devicecode.tsx
  2. 2
      libs/remix-ui/git/src/components/gitui.tsx
  3. 4
      libs/remix-ui/git/src/lib/gitactions.ts

@ -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 (
<div>
<button onClick={requestDeviceCode}>Get Device Code</button>
{userCode && <div>User Code: {userCode}</div>}
</div>
);
};
export default GetDeviceCode;

@ -29,6 +29,7 @@ import { GitHubCredentials } from './panels/githubcredentials'
import { loaderReducer } from '../state/loaderReducer' import { loaderReducer } from '../state/loaderReducer'
import { ApolloClient, ApolloProvider, NormalizedCacheObject } from '@apollo/client' import { ApolloClient, ApolloProvider, NormalizedCacheObject } from '@apollo/client'
import { client, getApolloLink } from '../state/apolloClient' import { client, getApolloLink } from '../state/apolloClient'
import GetDeviceCode from './github/devicecode'
export const gitPluginContext = React.createContext<gitState>(defaultGitState) export const gitPluginContext = React.createContext<gitState>(defaultGitState)
export const loaderContext = React.createContext<loaderState>(defaultLoaderState) export const loaderContext = React.createContext<loaderState>(defaultLoaderState)
@ -181,6 +182,7 @@ export const GitUI = (props: IGitUi) => {
<> <>
<GitHubAuth></GitHubAuth> <GitHubAuth></GitHubAuth>
<GitHubCredentials></GitHubCredentials> <GitHubCredentials></GitHubCredentials>
<GetDeviceCode></GetDeviceCode>
</> </>
</Accordion.Collapse> </Accordion.Collapse>

@ -186,15 +186,11 @@ export const currentBranch = async () => {
export const createBranch = async (name: string = "") => { export const createBranch = async (name: string = "") => {
dispatch(setLoading(true)) dispatch(setLoading(true))
await disableCallBacks()
if (name) { if (name) {
await plugin.call("dGitProvider", "branch", { ref: name }); await plugin.call("dGitProvider", "branch", { ref: name });
await plugin.call("dGitProvider", "checkout", { ref: name }); await plugin.call("dGitProvider", "checkout", { ref: name });
} }
dispatch(setLoading(false)) dispatch(setLoading(false))
await enableCallBacks()
} }
export const getCommitFromRef = async (ref: string) => { export const getCommitFromRef = async (ref: string) => {

Loading…
Cancel
Save