update props. update Token warning. update behaviour

pull/5000/head
Joseph Izang 7 months ago committed by Aniket
parent 9b0149de3b
commit dde07bfd4e
  1. 4
      apps/remix-ide/src/app/plugins/git.tsx
  2. 3
      libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx
  3. 4
      libs/remix-ui/git/src/components/gitui.tsx
  4. 34
      libs/remix-ui/git/src/components/panels/clone.tsx
  5. 20
      libs/remix-ui/git/src/components/panels/remotes.tsx
  6. 24
      libs/remix-ui/git/src/components/panels/remotesimport.tsx
  7. 18
      libs/remix-ui/git/src/components/panels/tokenWarning.tsx
  8. 10
      libs/remix-ui/git/src/style/index.css

@ -1,7 +1,7 @@
'use strict' 'use strict'
import { ViewPlugin } from '@remixproject/engine-web'; import { ViewPlugin } from '@remixproject/engine-web'
import React from 'react' // eslint-disable-line import React from 'react' // eslint-disable-line
import { gitState, GitUI } from '@remix-ui/git'; import { gitState, GitUI } from '@remix-ui/git'
import * as packageJson from '../../../../../package.json' import * as packageJson from '../../../../../package.json'
const profile = { const profile = {

@ -9,6 +9,7 @@ import { TokenWarning } from "../panels/tokenWarning";
interface RepositoriesProps { interface RepositoriesProps {
cloneDepth?: number cloneDepth?: number
cloneAllBranches?: boolean cloneAllBranches?: boolean
plugin: any
} }
export const SelectAndCloneRepositories = (props: RepositoriesProps) => { export const SelectAndCloneRepositories = (props: RepositoriesProps) => {
@ -43,7 +44,7 @@ export const SelectAndCloneRepositories = (props: RepositoriesProps) => {
return ( return (
<> <>
<TokenWarning /> <TokenWarning plugin={props.plugin} />
<RepositorySelect select={selectRepo} /> <RepositorySelect select={selectRepo} />
{repo &&<BranchSelect select={selectRemoteBranch} />} {repo &&<BranchSelect select={selectRemoteBranch} />}

@ -207,14 +207,14 @@ export const GitUI = (props: IGitUi) => {
<RemotesNavigation eventKey="5" activePanel={activePanel} callback={setActivePanel} /> <RemotesNavigation eventKey="5" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="5"> <Accordion.Collapse className='bg-light' eventKey="5">
<> <>
<Remotes></Remotes> <Remotes plugin={plugin}></Remotes>
</> </>
</Accordion.Collapse> </Accordion.Collapse>
<hr></hr> <hr></hr>
<CloneNavigation eventKey="4" activePanel={activePanel} callback={setActivePanel} /> <CloneNavigation eventKey="4" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="4"> <Accordion.Collapse className='bg-light' eventKey="4">
<> <>
<Clone /></> <Clone plugin={plugin} /></>
</Accordion.Collapse> </Accordion.Collapse>
<hr></hr> <hr></hr>
<GitHubNavigation eventKey="7" activePanel={activePanel} callback={setActivePanel} /> <GitHubNavigation eventKey="7" activePanel={activePanel} callback={setActivePanel} />

@ -1,14 +1,18 @@
import React, { useState } from "react"; import React, { useState } from "react"
import { Alert, Form, FormControl, InputGroup } from "react-bootstrap"; import { Alert, Form, FormControl, InputGroup } from "react-bootstrap"
import { useLocalStorage } from "../../hooks/useLocalStorage"; import { useLocalStorage } from "../../hooks/useLocalStorage"
import { gitActionsContext } from "../../state/context"; import { gitActionsContext } from "../../state/context"
import { gitPluginContext } from "../gitui"; import { gitPluginContext } from "../gitui"
import { SelectAndCloneRepositories } from "../github/selectandclonerepositories"; import { SelectAndCloneRepositories } from "../github/selectandclonerepositories"
import { RemixUiCheckbox } from "@remix-ui/checkbox"; import { RemixUiCheckbox } from "@remix-ui/checkbox"
import GitUIButton from "../buttons/gituibutton"; import GitUIButton from "../buttons/gituibutton"
export const Clone = () => { export interface CloneProps {
plugin: any
}
export const Clone = ({ plugin }: CloneProps) => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
const actions = React.useContext(gitActionsContext) const actions = React.useContext(gitActionsContext)
const [cloneUrl, setCloneUrl] = useLocalStorage( const [cloneUrl, setCloneUrl] = useLocalStorage(
@ -64,20 +68,20 @@ export const Clone = () => {
return ( return (
<> <>
<div data-id="clone-panel-content" className="px-3 py-2"> <div data-id="clone-panel-content" className="px-3 py-2">
<InputGroup className="mb-1"> <InputGroup className="mb-2 pb-1">
<FormControl data-id="clone-url" id="cloneulr" placeholder="url" name='cloneurl' value={cloneUrl} onChange={e => onGitHubCloneUrlChange(e.target.value)} aria-describedby="urlprepend" /> <FormControl data-id="clone-url" id="cloneulr" placeholder="url" name='cloneurl' value={cloneUrl} onChange={e => onGitHubCloneUrlChange(e.target.value)} aria-describedby="urlprepend" />
</InputGroup> </InputGroup>
<input name='clonebranch' onChange={e => onCloneBranchChange(e.target.value)} value={cloneBranch} className="form-control mb-1 mt-2" placeholder="branch" type="text" id="clonebranch" /> <input name='clonebranch' onChange={e => onCloneBranchChange(e.target.value)} value={cloneBranch} className="form-control mb-2 mt-2" placeholder="branch" type="text" id="clonebranch" />
<GitUIButton disabledCondition={!cloneUrl} data-id='clone-btn' className='btn btn-primary mt-1 w-100' onClick={async () => { <GitUIButton disabledCondition={!cloneUrl} data-id='clone-btn' className='btn btn-primary mt-1 w-100' onClick={async () => {
clone() clone()
}}>clone</GitUIButton> }}>clone</GitUIButton>
<hr /> <hr />
<SelectAndCloneRepositories cloneAllBranches={cloneAllBranches} cloneDepth={cloneDepth} /> <SelectAndCloneRepositories cloneAllBranches={cloneAllBranches} cloneDepth={cloneDepth} plugin={plugin} />
<hr /> <hr />
<label>options</label> <label>Options</label>
<InputGroup className="mt-1 mb-1"> <InputGroup className="mt-1 mb-1">
<InputGroup.Prepend> <InputGroup.Prepend className="bg-secondary">
<InputGroup.Text id="clonedepthprepend"> <InputGroup.Text id="clonedepthprepend">
--depth --depth
</InputGroup.Text> </InputGroup.Text>

@ -1,10 +1,14 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react"
import { gitActionsContext } from "../../state/context"; import { gitActionsContext } from "../../state/context"
import { gitPluginContext } from "../gitui"; import { gitPluginContext } from "../gitui"
import { Remoteselect } from "./remoteselect"; import { Remoteselect } from "./remoteselect"
import { RemotesImport } from "./remotesimport"; import { RemotesImport } from "./remotesimport"
export const Remotes = () => { export interface RemotesProps {
plugin: any
}
export const Remotes = (props: RemotesProps) => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
const actions = React.useContext(gitActionsContext) const actions = React.useContext(gitActionsContext)
const [remoteName, setRemoteName] = React.useState<string>('') const [remoteName, setRemoteName] = React.useState<string>('')
@ -46,8 +50,8 @@ export const Remotes = () => {
addRemote(); addRemote();
}}>add remote</button> }}>add remote</button>
<hr /> <hr />
<RemotesImport /> <RemotesImport plugin={props.plugin} />
<hr /> <hr />
</div> </div>
</>) </>)
} }

@ -1,14 +1,18 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react"
import { Alert, Button } from "react-bootstrap"; import { Alert, Button } from "react-bootstrap"
import { gitActionsContext } from "../../state/context"; import { gitActionsContext } from "../../state/context"
import { repository } from "../../types"; import { repository } from "../../types"
import { gitPluginContext } from "../gitui"; import { gitPluginContext } from "../gitui"
import Select from 'react-select' import Select from 'react-select'
import { selectStyles, selectTheme } from "../../types/styles"; import { selectStyles, selectTheme } from "../../types/styles"
import { TokenWarning } from "./tokenWarning"; import { TokenWarning } from "./tokenWarning"
import RepositorySelect from "../github/repositoryselect"; import RepositorySelect from "../github/repositoryselect"
export const RemotesImport = () => { export interface RemotesImportProps {
plugin: any
}
export const RemotesImport = (props: RemotesImportProps) => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
const actions = React.useContext(gitActionsContext) const actions = React.useContext(gitActionsContext)
const [repo, setRepo] = useState<repository>(null); const [repo, setRepo] = useState<repository>(null);
@ -64,7 +68,7 @@ export const RemotesImport = () => {
return ( return (
<> <>
<TokenWarning /> <TokenWarning plugin={props.plugin} />
<RepositorySelect select={selectRepo} /> <RepositorySelect select={selectRepo} />
{repo ? {repo ?

@ -1,12 +1,20 @@
import { gitPluginContext } from "../gitui" import { gitPluginContext } from "../gitui"
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react"
export const TokenWarning = () => {
export interface TokenWarningProps {
plugin: any
}
export const TokenWarning = (props: TokenWarningProps) => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
return (<> return (<>
{(context.gitHubUser && context.gitHubUser.login) ? null : {(context.gitHubUser && context.gitHubUser.login) ? null :
<li className="text-warning list-group-item d-flex justify-content-between align-items-center"> <li className="text-warning list-group-item text-left">
To use add a GitHub token to the settings.</li> <span>Generate and add a Git token to use this plugin. Tokens are found in </span><span className=" text-decoration-line-through messageTip" onClick={async () => {
await props.plugin.call('menuicons', 'select', 'settings')
}}>settings</span><span> of the IDE.</span>
</li>
} }
</> </>
) )
} }

@ -28,9 +28,17 @@
.gitfile:hover { .gitfile:hover {
background-color : var(--custom-select); background-color : var(--custom-select);
} }
hr { hr {
background-color: var(--custom-select); background-color: var(--custom-select);
} }
.messageTip {
}
.messageTip:hover {
cursor: pointer;
text-decoration: underline;
}

Loading…
Cancel
Save