|
|
|
@ -18,7 +18,6 @@ export function Workspace () { |
|
|
|
|
const [showIconsMenu, hideIconsMenu] = useState<boolean>(false) |
|
|
|
|
const [showBranches, setShowBranches] = useState<boolean>(false) |
|
|
|
|
const [branchFilter, setBranchFilter] = useState<string>('') |
|
|
|
|
const [selectedBranch, setSelectedBranch] = useState<string>('') |
|
|
|
|
const displayOzCustomRef = useRef<HTMLDivElement>() |
|
|
|
|
const mintableCheckboxRef = useRef() |
|
|
|
|
const burnableCheckboxRef = useRef() |
|
|
|
@ -32,6 +31,7 @@ export function Workspace () { |
|
|
|
|
const cloneUrlRef = useRef<HTMLInputElement>() |
|
|
|
|
const initGitRepoRef = useRef<HTMLInputElement>() |
|
|
|
|
const filteredBranches = selectedWorkspace ? (selectedWorkspace.branches || []).filter(branch => branch.name.includes(branchFilter) && branch.remote).slice(0, 20) : [] |
|
|
|
|
const currentBranch = selectedWorkspace ? selectedWorkspace.currentBranch : null |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
let workspaceName = localStorage.getItem('currentWorkspace') |
|
|
|
@ -67,7 +67,7 @@ export function Workspace () { |
|
|
|
|
const workspace = global.fs.browser.workspaces.find(workspace => workspace.name === currentWorkspace) |
|
|
|
|
|
|
|
|
|
setSelectedWorkspace(workspace) |
|
|
|
|
workspace && setSelectedBranch(workspace.currentBranch) |
|
|
|
|
// workspace && setSelectedBranch(workspace.currentBranch)
|
|
|
|
|
}, [currentWorkspace]) |
|
|
|
|
|
|
|
|
|
const renameCurrentWorkspace = () => { |
|
|
|
@ -221,7 +221,6 @@ export function Workspace () { |
|
|
|
|
const switchToBranch = async (branch: string) => { |
|
|
|
|
try { |
|
|
|
|
await global.dispatchSwitchToBranch(branch) |
|
|
|
|
setSelectedBranch(branch) |
|
|
|
|
} catch (e) { |
|
|
|
|
global.modal('Checkout Git Branch', e.message, 'OK', () => {}) |
|
|
|
|
} |
|
|
|
@ -230,7 +229,6 @@ export function Workspace () { |
|
|
|
|
const switchToNewBranch = async () => { |
|
|
|
|
try { |
|
|
|
|
await global.dispatchSwitchToNewBranch(branchFilter) |
|
|
|
|
setSelectedBranch(branchFilter) |
|
|
|
|
} catch (e) { |
|
|
|
|
global.modal('Checkout Git Branch', e.message, 'OK', () => {}) |
|
|
|
|
} |
|
|
|
@ -725,7 +723,7 @@ export function Workspace () { |
|
|
|
|
<div className="pt-1 mr-1"> |
|
|
|
|
<Dropdown style={{ height: 30, minWidth: 80 }} onToggle={toggleBranches} show={showBranches} drop={'up'}> |
|
|
|
|
<Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control h-100 p-0 pl-2 pr-2 text-dark" icon={null}> |
|
|
|
|
{ global.fs.browser.isRequestingCloning ? <i className="fad fa-spinner fa-spin"></i> : selectedBranch || '-none-' } |
|
|
|
|
{ global.fs.browser.isRequestingCloning ? <i className="fad fa-spinner fa-spin"></i> : currentBranch || '-none-' } |
|
|
|
|
</Dropdown.Toggle> |
|
|
|
|
|
|
|
|
|
<Dropdown.Menu as={CustomMenu} className='custom-dropdown-items branches-dropdown' data-id="custom-dropdown-items"> |
|
|
|
@ -748,7 +746,7 @@ export function Workspace () { |
|
|
|
|
return ( |
|
|
|
|
<Dropdown.Item key={index} onClick={() => { switchToBranch(branch.name) }}> |
|
|
|
|
{
|
|
|
|
|
selectedBranch === branch.name ? |
|
|
|
|
currentBranch === branch.name ? |
|
|
|
|
<span>✓ { branch.name } </span> : |
|
|
|
|
<span className="pl-3">{ branch.name }</span> |
|
|
|
|
} |
|
|
|
@ -757,7 +755,7 @@ export function Workspace () { |
|
|
|
|
}) :
|
|
|
|
|
<Dropdown.Item onClick={switchToNewBranch}> |
|
|
|
|
<div className="pl-1 pr-1"> |
|
|
|
|
<i className="fas fa-code-branch pr-2"></i><span>Create branch: { branchFilter } from '{selectedBranch}'</span> |
|
|
|
|
<i className="fas fa-code-branch pr-2"></i><span>Create branch: { branchFilter } from '{currentBranch}'</span> |
|
|
|
|
</div> |
|
|
|
|
</Dropdown.Item> |
|
|
|
|
} |
|
|
|
|