commits paging

pull/5370/head
bunsenstraat 7 months ago
parent 651afc09a6
commit 6049eb4675
  1. 10
      apps/remixdesktop/src/plugins/isoGitPlugin.ts
  2. 4
      libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx
  3. 10
      libs/remix-ui/git/src/components/gitui.tsx
  4. 11
      libs/remix-ui/git/src/components/panels/commits.tsx
  5. 22
      libs/remix-ui/git/src/lib/gitactions.ts
  6. 14
      libs/remix-ui/git/src/lib/listeners.ts
  7. 2
      libs/remix-ui/git/src/state/actions.ts
  8. 3
      libs/remix-ui/git/src/state/context.tsx
  9. 14
      libs/remix-ui/git/src/state/gitpayload.ts
  10. 11
      libs/remix-ui/git/src/state/gitreducer.tsx
  11. 13
      libs/remix-ui/git/src/types/index.ts

@ -95,18 +95,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
return [] return []
} }
const logCount = await git.log({
...await this.getGitConfig(),
...cmd,
depth: 100
})
console.log('LOG-COUNT', logCount.length)
const log = await git.log({ const log = await git.log({
...await this.getGitConfig(), ...await this.getGitConfig(),
...cmd, ...cmd,
depth: 10 depth: cmd.depth || 10
}) })
console.log('LOG') console.log('LOG')
return log return log

@ -5,7 +5,7 @@ import React, { useEffect, useState } from "react"
import { FormattedMessage } from "react-intl" import { FormattedMessage } from "react-intl"
import { gitActionsContext } from "../../state/context" import { gitActionsContext } from "../../state/context"
import { branch, remote } from "@remix-api" import { branch, remote } from "@remix-api"
import { gitMatomoEventTypes } from "../../types" import { defaultGitState, gitMatomoEventTypes } from "../../types"
import { gitPluginContext } from "../gitui" import { gitPluginContext } from "../gitui"
import GitUIButton from "./gituibutton" import GitUIButton from "./gituibutton"
import { syncStateContext } from "./sourceControlBase" import { syncStateContext } from "./sourceControlBase"
@ -55,7 +55,7 @@ export const SourceControlButtons = () => {
const refresh = async() => { const refresh = async() => {
await sendToMatomo(gitMatomoEventTypes.REFRESH) await sendToMatomo(gitMatomoEventTypes.REFRESH)
await actions.getFileStatusMatrix(null) await actions.getFileStatusMatrix(null)
await actions.gitlog() actions.setStateGitLogCount(defaultGitState.gitLogCount)
} }
const buttonsDisabled = () => { const buttonsDisabled = () => {

@ -1,5 +1,5 @@
import React, { useEffect, useReducer, useState, useContext } from 'react' import React, { useEffect, useReducer, useState, useContext } from 'react'
import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, loadGitHubUserFromToken, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentialsFromLocalStorage, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix, init, showAlert, gitlog } from '../lib/gitactions' import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, loadGitHubUserFromToken, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentialsFromLocalStorage, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix, init, showAlert, gitlog, setStateGitLogCount } from '../lib/gitactions'
import { loadFiles, setCallBacks } from '../lib/listeners' import { loadFiles, setCallBacks } from '../lib/listeners'
import { openDiff, openFile, openFolderInSameWindow, sendToMatomo, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions' import { openDiff, openFile, openFolderInSameWindow, sendToMatomo, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions'
import { gitActionsContext, pluginActionsContext } from '../state/context' import { gitActionsContext, pluginActionsContext } from '../state/context'
@ -74,6 +74,11 @@ export const GitUI = (props: IGitUi) => {
}, [appLoaded]) }, [appLoaded])
useEffect(() => {
if (!appLoaded) return
gitlog(gitState.gitLogCount)
}, [gitState.timestamp, gitState.gitLogCount])
useEffect(() => { useEffect(() => {
if (!appLoaded) return if (!appLoaded) return
async function checkconfig() { async function checkconfig() {
@ -159,7 +164,8 @@ export const GitUI = (props: IGitUi) => {
clearGitLog, clearGitLog,
getFileStatusMatrix, getFileStatusMatrix,
gitlog, gitlog,
init init,
setStateGitLogCount
} }
const pluginActionsProviderValue = { const pluginActionsProviderValue = {

@ -1,12 +1,10 @@
import { checkout, ReadCommitResult } from "isomorphic-git"; import { ReadCommitResult } from "isomorphic-git";
import React from "react"; import React from "react";
import { gitActionsContext } from "../../state/context"; import { gitActionsContext } from "../../state/context";
import GitUIButton from "../buttons/gituibutton"; import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui"; import { gitPluginContext } from "../gitui";
import LoaderIndicator from "../navigation/loaderindicator";
import { BranchDifferences } from "./branches/branchdifferences"; import { BranchDifferences } from "./branches/branchdifferences";
import { CommitDetails } from "./commits/commitdetails"; import { CommitDetails } from "./commits/commitdetails";
import { CommitSummary } from "./commits/commitsummary";
export const Commits = () => { export const Commits = () => {
const [hasNextPage, setHasNextPage] = React.useState(true) const [hasNextPage, setHasNextPage] = React.useState(true)
@ -22,14 +20,15 @@ export const Commits = () => {
}; };
const loadNextPage = () => { const loadNextPage = () => {
actions.setStateGitLogCount(context.gitLogCount + 5)
actions.fetch({ actions.fetch({
remote: null, remote: null,
ref: context.currentBranch, ref: context.currentBranch,
relative: true, relative: true,
depth: 5, depth: 5,
singleBranch: true singleBranch: true,
quiet: true
}) })
} }
const getRemote = () => { const getRemote = () => {
@ -49,7 +48,7 @@ export const Commits = () => {
{context.commits && context.commits.length ? {context.commits && context.commits.length ?
<><BranchDifferences branch={context.currentBranch}></BranchDifferences><div> <><BranchDifferences branch={context.currentBranch}></BranchDifferences><div>
<div data-id={`commits-current-branch-${context.currentBranch && context.currentBranch.name}`} className="pt-1"> <div data-id={`commits-current-branch-${context.currentBranch && context.currentBranch.name}`} className="pt-1">
{context.commits && context.commits.slice(0,5).map((commit, index) => { {context.commits && context.commits.map((commit, index) => {
return ( return (
<CommitDetails branch={context.currentBranch} getCommitChanges={getCommitChanges} key={index} checkout={checkout} commit={commit}></CommitDetails> <CommitDetails branch={context.currentBranch} getCommitChanges={getCommitChanges} key={index} checkout={checkout} commit={commit}></CommitDetails>
); );

@ -1,6 +1,6 @@
import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; import { ReadBlobResult, ReadCommitResult } from "isomorphic-git";
import React from "react"; import React from "react";
import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails, setCurrenHead, setStoragePayload, resetBranchDifferences } from "../state/gitpayload"; import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails, setCurrenHead, setStoragePayload, resetBranchDifferences, setTimestamp, setGitLogCount } from "../state/gitpayload";
import { gitActionDispatch, statusMatrixType, gitState, gitLog, fileStatusResult, storage, gitMatomoEventTypes } from '../types'; import { gitActionDispatch, statusMatrixType, gitState, gitLog, fileStatusResult, storage, gitMatomoEventTypes } from '../types';
import { removeSlash } from "../utils"; import { removeSlash } from "../utils";
import { disableCallBacks, enableCallBacks } from "./listeners"; import { disableCallBacks, enableCallBacks } from "./listeners";
@ -41,7 +41,7 @@ export const setPlugin = (p: Plugin, dispatcher: React.Dispatch<gitActionDispatc
export const init = async () => { export const init = async () => {
await sendToMatomo(gitMatomoEventTypes.INIT) await sendToMatomo(gitMatomoEventTypes.INIT)
await plugin.call('dgitApi', "init"); await plugin.call('dgitApi', "init");
await gitlog(); dispatch(setTimestamp(Date.now()))
await getBranches(); await getBranches();
} }
@ -83,13 +83,13 @@ export const getFileStatusMatrix = async (filepaths: string[]) => {
dispatch(setLoading(false)) dispatch(setLoading(false))
} }
export const getCommits = async () => { export const getCommits = async (depth: number) => {
try { try {
const commits: ReadCommitResult[] = await plugin.call( const commits: ReadCommitResult[] = await plugin.call(
'dgitApi', 'dgitApi',
"log", "log",
{ ref: "HEAD" } { ref: "HEAD", depth: depth }
); );
console.log('commits', commits) console.log('commits', commits)
return commits; return commits;
@ -98,12 +98,12 @@ export const getCommits = async () => {
} }
} }
export const gitlog = async () => { export const gitlog = async (depth: number) => {
console.log('gitlog start') console.log('gitlog start')
dispatch(setLoading(true)) dispatch(setLoading(true))
let commits = [] let commits = []
try { try {
commits = await getCommits() commits = await getCommits(depth)
} catch (e) { } catch (e) {
} }
dispatch(setCommits(commits)) dispatch(setCommits(commits))
@ -112,6 +112,10 @@ export const gitlog = async () => {
console.log('gitlog end') console.log('gitlog end')
} }
export const setStateGitLogCount = async (count: number) => {
dispatch(setGitLogCount(count))
}
export const showCurrentBranch = async () => { export const showCurrentBranch = async () => {
try { try {
const branch = await currentBranch(); const branch = await currentBranch();
@ -346,7 +350,7 @@ export const fetch = async (input: fetchInputType) => {
try { try {
await plugin.call('dgitApi', 'fetch', input); await plugin.call('dgitApi', 'fetch', input);
if (!input.quiet) { if (!input.quiet) {
await gitlog() dispatch(setTimestamp(Date.now()))
await getBranches() await getBranches()
} }
} catch (e: any) { } catch (e: any) {
@ -363,7 +367,7 @@ export const pull = async (input: pullInputType) => {
await disableCallBacks() await disableCallBacks()
try { try {
await plugin.call('dgitApi', 'pull', input) await plugin.call('dgitApi', 'pull', input)
await gitlog() dispatch(setTimestamp(Date.now()))
} catch (e: any) { } catch (e: any) {
console.log(e) console.log(e)
await parseError(e) await parseError(e)
@ -397,6 +401,8 @@ const tokenWarning = async () => {
const parseError = async (e: any) => { const parseError = async (e: any) => {
console.trace(e) console.trace(e)
if(!e.message) return
// if message conttains 401 Unauthorized, show token warning // if message conttains 401 Unauthorized, show token warning
if (e.message.includes('401')) { if (e.message.includes('401')) {
await sendToMatomo(gitMatomoEventTypes.ERROR, ['401']) await sendToMatomo(gitMatomoEventTypes.ERROR, ['401'])

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog, setGitHubUser, setUserEmails, setDesktopWorkingDir, setVersion } from "../state/gitpayload"; import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog, setGitHubUser, setUserEmails, setDesktopWorkingDir, setVersion, setTimestamp } from "../state/gitpayload";
import { gitActionDispatch, gitUIPanels, storage } from "../types"; import { gitActionDispatch, gitUIPanels, storage } from "../types";
import { Plugin } from "@remixproject/engine"; import { Plugin } from "@remixproject/engine";
import { getBranches, getFileStatusMatrix, loadGitHubUserFromToken, getRemotes, gitlog, setPlugin, setStorage } from "./gitactions"; import { getBranches, getFileStatusMatrix, loadGitHubUserFromToken, getRemotes, gitlog, setPlugin, setStorage } from "./gitactions";
@ -78,7 +78,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
loadFiles() loadFiles()
}) })
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
gitlog() gitDispatch(setTimestamp(Date.now()))
}) })
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
getBranches() getBranches()
@ -105,7 +105,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
loadFiles() loadFiles()
}) })
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
gitlog() gitDispatch(setTimestamp(Date.now()))
}) })
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
getBranches() getBranches()
@ -117,7 +117,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
plugin.on('dgitApi', 'checkout', async () => { plugin.on('dgitApi', 'checkout', async () => {
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
gitlog() gitDispatch(setTimestamp(Date.now()))
}) })
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
getBranches() getBranches()
@ -148,7 +148,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
loadFiles() loadFiles()
}, 10) }, 10)
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
gitlog() gitDispatch(setTimestamp(Date.now()))
}, 10) }, 10)
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
getBranches() getBranches()
@ -160,7 +160,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
}) })
plugin.on('dgitApi', 'branch', async () => { plugin.on('dgitApi', 'branch', async () => {
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
gitlog() gitDispatch(setTimestamp(Date.now()))
}) })
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
getBranches() getBranches()
@ -182,7 +182,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
getBranches() getBranches()
}) })
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
gitlog() gitDispatch(setTimestamp(Date.now()))
}) })
}) })
plugin.on('manager', 'pluginActivated', async (p: Profile<any>) => { plugin.on('manager', 'pluginActivated', async (p: Profile<any>) => {

@ -48,6 +48,8 @@ export interface ActionPayloadTypes {
DESKTOP_SET_WORKING_DIR: string DESKTOP_SET_WORKING_DIR: string
SET_VERSION: string SET_VERSION: string
SET_STORAGE: storage SET_STORAGE: storage
SET_TIMESTAMP: number
SET_GIT_LOG_COUNT: number
} }
export interface Action<T extends keyof ActionPayloadTypes> { export interface Action<T extends keyof ActionPayloadTypes> {

@ -32,8 +32,9 @@ export interface gitActions {
sendToGitLog: (message: gitLog) => Promise<void> sendToGitLog: (message: gitLog) => Promise<void>
clearGitLog: () => Promise<void> clearGitLog: () => Promise<void>
getFileStatusMatrix(filespaths:[]): Promise<void> getFileStatusMatrix(filespaths:[]): Promise<void>
gitlog(): Promise<void> gitlog(depth: number): Promise<void>
init(): Promise<void> init(): Promise<void>
setStateGitLogCount(count: number): Promise<void>
} }
export const gitActionsContext = React.createContext<gitActions>(null) export const gitActionsContext = React.createContext<gitActions>(null)

@ -246,3 +246,17 @@ export const setStoragePayload = (storage: storage) => {
payload: storage payload: storage
} }
} }
export const setTimestamp = (timestamp: number) => {
return {
type: 'SET_TIMESTAMP',
payload: timestamp
}
}
export const setGitLogCount = (count: number) => {
return {
type: 'SET_GIT_LOG_COUNT',
payload: count
}
}

@ -226,6 +226,17 @@ export const gitReducer = (state: gitState = defaultGitState, action: Actions):
...state, ...state,
storage: action.payload storage: action.payload
} }
case 'SET_TIMESTAMP':
return {
...state,
timestamp: action.payload
}
case 'SET_GIT_LOG_COUNT':
return {
...state,
gitLogCount: action.payload
}
} }
} }

@ -38,6 +38,8 @@ export type gitState = {
log: gitLog[] log: gitLog[]
desktopWorkingDir?: string desktopWorkingDir?: string
version: string version: string
timestamp: number
gitLogCount: number
} }
export type gitLog = { export type gitLog = {
type: 'error' | 'warning' | 'info' | 'success', type: 'error' | 'warning' | 'info' | 'success',
@ -95,7 +97,9 @@ export const defaultGitState: gitState = {
gitHubAccessToken: "", gitHubAccessToken: "",
log: [], log: [],
desktopWorkingDir: null, desktopWorkingDir: null,
version: "" version: "",
timestamp: 0,
gitLogCount: 22
} }
export const defaultLoaderState: loaderState = { export const defaultLoaderState: loaderState = {
@ -290,4 +294,9 @@ export interface setDesktopWorkingDirAction {
payload: string payload: string
} }
export type gitActionDispatch = setDesktopWorkingDirAction | setCurrentHeadAction | clearLogAction | setLogAction | setDefaultRemoteAction | setTokenAction | setUpstreamAction | setRemoteBranchCommitsAction | setLocalBranchCommitsAction | setBranchDifferencesAction | setRemotesAction | setCurrentBranchAction | fileStatusAction | setLoadingAction | setCanUseAppAction | setRepoNameAction | setCommitsAction | setBranchesAction | setReposAction | setRemoteBranchesAction export interface setTimeStampAction {
type: string,
payload: number
}
export type gitActionDispatch = setTimeStampAction |setDesktopWorkingDirAction | setCurrentHeadAction | clearLogAction | setLogAction | setDefaultRemoteAction | setTokenAction | setUpstreamAction | setRemoteBranchCommitsAction | setLocalBranchCommitsAction | setBranchDifferencesAction | setRemotesAction | setCurrentBranchAction | fileStatusAction | setLoadingAction | setCanUseAppAction | setRepoNameAction | setCommitsAction | setBranchesAction | setReposAction | setRemoteBranchesAction
Loading…
Cancel
Save