From 67ee33ec74c4e3e9f9e4932bf03c59149adcf339 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 10:36:52 +0100 Subject: [PATCH 01/21] remove semicolons. add padding. use native button --- .../git/src/components/github/repositoryselect.tsx | 4 ++-- libs/remix-ui/git/src/components/gitui.tsx | 8 ++++---- libs/remix-ui/git/src/components/panels/clone.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/remix-ui/git/src/components/github/repositoryselect.tsx b/libs/remix-ui/git/src/components/github/repositoryselect.tsx index c4f9da7864..dab826beb9 100644 --- a/libs/remix-ui/git/src/components/github/repositoryselect.tsx +++ b/libs/remix-ui/git/src/components/github/repositoryselect.tsx @@ -64,9 +64,9 @@ const RepositorySelect = (props: RepositorySelectProps) => { }; return ( - <> + { show ? onCloneBranchChange(e.target.value)} value={cloneBranch} className="form-control mb-1 mt-2" placeholder="branch" type="text" id="clonebranch" /> + onCloneBranchChange(e.target.value)} value={cloneBranch} className="form-control mb-2 mt-2" placeholder="branch" type="text" id="clonebranch" /> { clone() }}>clone
- +
- + - + --depth diff --git a/libs/remix-ui/git/src/components/panels/remotes.tsx b/libs/remix-ui/git/src/components/panels/remotes.tsx index cf8ea2fc58..4a0728f3e4 100644 --- a/libs/remix-ui/git/src/components/panels/remotes.tsx +++ b/libs/remix-ui/git/src/components/panels/remotes.tsx @@ -1,10 +1,14 @@ -import React, { useEffect } from "react"; -import { gitActionsContext } from "../../state/context"; -import { gitPluginContext } from "../gitui"; -import { Remoteselect } from "./remoteselect"; -import { RemotesImport } from "./remotesimport"; +import React, { useEffect } from "react" +import { gitActionsContext } from "../../state/context" +import { gitPluginContext } from "../gitui" +import { Remoteselect } from "./remoteselect" +import { RemotesImport } from "./remotesimport" -export const Remotes = () => { +export interface RemotesProps { + plugin: any +} + +export const Remotes = (props: RemotesProps) => { const context = React.useContext(gitPluginContext) const actions = React.useContext(gitActionsContext) const [remoteName, setRemoteName] = React.useState('') @@ -46,8 +50,8 @@ export const Remotes = () => { addRemote(); }}>add remote
- +
) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/panels/remotesimport.tsx b/libs/remix-ui/git/src/components/panels/remotesimport.tsx index 646546c1a4..9cbf4ec776 100644 --- a/libs/remix-ui/git/src/components/panels/remotesimport.tsx +++ b/libs/remix-ui/git/src/components/panels/remotesimport.tsx @@ -1,14 +1,18 @@ -import React, { useEffect, useState } from "react"; -import { Alert, Button } from "react-bootstrap"; -import { gitActionsContext } from "../../state/context"; -import { repository } from "../../types"; -import { gitPluginContext } from "../gitui"; +import React, { useEffect, useState } from "react" +import { Alert, Button } from "react-bootstrap" +import { gitActionsContext } from "../../state/context" +import { repository } from "../../types" +import { gitPluginContext } from "../gitui" import Select from 'react-select' -import { selectStyles, selectTheme } from "../../types/styles"; -import { TokenWarning } from "./tokenWarning"; -import RepositorySelect from "../github/repositoryselect"; +import { selectStyles, selectTheme } from "../../types/styles" +import { TokenWarning } from "./tokenWarning" +import RepositorySelect from "../github/repositoryselect" -export const RemotesImport = () => { +export interface RemotesImportProps { + plugin: any +} + +export const RemotesImport = (props: RemotesImportProps) => { const context = React.useContext(gitPluginContext) const actions = React.useContext(gitActionsContext) const [repo, setRepo] = useState(null); @@ -64,7 +68,7 @@ export const RemotesImport = () => { return ( <> - + {repo ? diff --git a/libs/remix-ui/git/src/components/panels/tokenWarning.tsx b/libs/remix-ui/git/src/components/panels/tokenWarning.tsx index 4188c07c93..7b713ea26a 100644 --- a/libs/remix-ui/git/src/components/panels/tokenWarning.tsx +++ b/libs/remix-ui/git/src/components/panels/tokenWarning.tsx @@ -1,12 +1,20 @@ import { gitPluginContext } from "../gitui" -import React, { useEffect, useState } from "react"; -export const TokenWarning = () => { +import React, { useEffect, useState } from "react" + +export interface TokenWarningProps { + plugin: any +} + +export const TokenWarning = (props: TokenWarningProps) => { const context = React.useContext(gitPluginContext) return (<> {(context.gitHubUser && context.gitHubUser.login) ? null : -
  • - To use add a GitHub token to the settings.
  • +
  • + Generate and add a Git token to use this plugin. Tokens are found in { + await props.plugin.call('menuicons', 'select', 'settings') + }}>settings of the IDE. +
  • } ) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/style/index.css b/libs/remix-ui/git/src/style/index.css index 973889c15c..57df5f68c9 100644 --- a/libs/remix-ui/git/src/style/index.css +++ b/libs/remix-ui/git/src/style/index.css @@ -28,9 +28,17 @@ .gitfile:hover { background-color : var(--custom-select); } - + hr { background-color: var(--custom-select); } +.messageTip { + +} + +.messageTip:hover { + cursor: pointer; + text-decoration: underline; +} From d016daf6ccd16a1cb55da17c8e943a9d23303c1b Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 12:08:51 +0100 Subject: [PATCH 03/21] relocate the git fetch button. format code. --- .../git/src/components/github/repositoryselect.tsx | 2 +- .../src/components/github/selectandclonerepositories.tsx | 8 ++++---- libs/remix-ui/git/src/components/panels/clone.tsx | 4 ++-- libs/remix-ui/git/src/components/panels/tokenWarning.tsx | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/git/src/components/github/repositoryselect.tsx b/libs/remix-ui/git/src/components/github/repositoryselect.tsx index dab826beb9..212ce295dd 100644 --- a/libs/remix-ui/git/src/components/github/repositoryselect.tsx +++ b/libs/remix-ui/git/src/components/github/repositoryselect.tsx @@ -64,7 +64,7 @@ const RepositorySelect = (props: RepositorySelectProps) => { }; return ( - <> { diff --git a/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx b/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx index 54054605a8..d62b761118 100644 --- a/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx +++ b/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx @@ -44,15 +44,15 @@ export const SelectAndCloneRepositories = (props: RepositoriesProps) => { return ( <> - + - {repo &&} + { repo && } - {repo && branch && branch.name && branch.name !== '0' ? + { repo && branch && branch.name && branch.name !== '0' ? : null} + }}>clone {repo.full_name}:{branch.name} : null } ) diff --git a/libs/remix-ui/git/src/components/panels/clone.tsx b/libs/remix-ui/git/src/components/panels/clone.tsx index 96d0388767..09e32e3e1d 100644 --- a/libs/remix-ui/git/src/components/panels/clone.tsx +++ b/libs/remix-ui/git/src/components/panels/clone.tsx @@ -68,6 +68,8 @@ export const Clone = ({ plugin }: CloneProps) => { return ( <>
    + +
    onGitHubCloneUrlChange(e.target.value)} aria-describedby="urlprepend" /> @@ -77,8 +79,6 @@ export const Clone = ({ plugin }: CloneProps) => { clone() }}>clone
    - -
    diff --git a/libs/remix-ui/git/src/components/panels/tokenWarning.tsx b/libs/remix-ui/git/src/components/panels/tokenWarning.tsx index 7b713ea26a..bce647758e 100644 --- a/libs/remix-ui/git/src/components/panels/tokenWarning.tsx +++ b/libs/remix-ui/git/src/components/panels/tokenWarning.tsx @@ -9,11 +9,11 @@ export const TokenWarning = (props: TokenWarningProps) => { const context = React.useContext(gitPluginContext) return (<> {(context.gitHubUser && context.gitHubUser.login) ? null : -
  • - Generate and add a Git token to use this plugin. Tokens are found in { + + Generate and add a Git token to use this plugin. Tokens are added in { await props.plugin.call('menuicons', 'select', 'settings') }}>settings of the IDE. -
  • + } ) From d7f27dee4215618f4ff1d622e9cd5d790cf2622e Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 12:37:56 +0100 Subject: [PATCH 04/21] add spacing. --- libs/remix-ui/git/src/components/panels/clone.tsx | 2 +- .../git/src/components/panels/commands.tsx | 6 +++--- .../git/src/components/panels/commands/fetch.tsx | 6 +++--- .../src/components/panels/commands/pushpull.tsx | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/remix-ui/git/src/components/panels/clone.tsx b/libs/remix-ui/git/src/components/panels/clone.tsx index 09e32e3e1d..4e562be544 100644 --- a/libs/remix-ui/git/src/components/panels/clone.tsx +++ b/libs/remix-ui/git/src/components/panels/clone.tsx @@ -82,7 +82,7 @@ export const Clone = ({ plugin }: CloneProps) => { - + --depth diff --git a/libs/remix-ui/git/src/components/panels/commands.tsx b/libs/remix-ui/git/src/components/panels/commands.tsx index f1b9cfc952..45f6f05aeb 100644 --- a/libs/remix-ui/git/src/components/panels/commands.tsx +++ b/libs/remix-ui/git/src/components/panels/commands.tsx @@ -6,9 +6,9 @@ import { Merge } from "./commands/merge"; export const Commands = () => { return ( - <> +

    - ) -} \ No newline at end of file +
    ) +} diff --git a/libs/remix-ui/git/src/components/panels/commands/fetch.tsx b/libs/remix-ui/git/src/components/panels/commands/fetch.tsx index d7b8ee0c30..8387cf5b14 100644 --- a/libs/remix-ui/git/src/components/panels/commands/fetch.tsx +++ b/libs/remix-ui/git/src/components/panels/commands/fetch.tsx @@ -15,11 +15,11 @@ export const Fetch = () => {
    actions.fetch({ remote: context.upstream, - })} className="btn btn-primary mr-1 w-50">
    Fetch {context.upstream && context.upstream.name}
    + })} className="btn btn-secondary mr-1 w-50">
    Fetch {context.upstream && context.upstream.name}
    actions.fetch({ remote: context.upstream, ref: context.currentBranch - })} className="btn btn-primary w-50 long-and-truncated">Fetch {context.currentBranch.name} + })} className="btn btn-secondary w-50 long-and-truncated">Fetch {context.currentBranch.name}
    ) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx index fa21eb7d4f..48088706a0 100644 --- a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx +++ b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx @@ -148,7 +148,7 @@ export const PushPull = () => { push()} className="btn btn-primary">Push
    - + { placeholder="Type to search for a branch..." /> - + onForceChange(e)} className="remixui_autocompile custom-control-input" type="checkbox" data-id="compilerContainerAutoCompile" id="forcepush" title="Force Push" /> - +
    + onForceChange(e)} className="remixui_autocompile form-check-input custom-control-input" type="checkbox" data-id="compilerContainerAutoCompile" id="forcepush" title="Force Push" /> +
    ) -} \ No newline at end of file +} From 96a9a71cc46f7b22fa0d66d40932e93b0ed32b87 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 13:29:50 +0100 Subject: [PATCH 05/21] replace svg carets with i tags and css classes. fix padding --- libs/remix-ui/git/src/components/gitui.tsx | 2 +- .../git/src/components/navigation/branches.tsx | 8 +++----- .../git/src/components/navigation/clone.tsx | 8 +++----- .../git/src/components/navigation/commands.tsx | 13 +++++-------- .../git/src/components/navigation/commits.tsx | 9 +++------ .../git/src/components/navigation/github.tsx | 18 ++++++++---------- .../git/src/components/navigation/log.tsx | 8 +++----- .../git/src/components/navigation/remotes.tsx | 8 +++----- .../git/src/components/navigation/settings.tsx | 8 +++----- .../components/navigation/sourcecontrol.tsx | 13 ++++++------- 10 files changed, 38 insertions(+), 57 deletions(-) diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 3511e15047..46f7733b02 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -185,7 +185,7 @@ export const GitUI = (props: IGitUi) => {
    - + <> diff --git a/libs/remix-ui/git/src/components/navigation/branches.tsx b/libs/remix-ui/git/src/components/navigation/branches.tsx index b9dd9b06f2..3dfb19cc66 100644 --- a/libs/remix-ui/git/src/components/navigation/branches.tsx +++ b/libs/remix-ui/git/src/components/navigation/branches.tsx @@ -20,13 +20,11 @@ export const BranchesNavigation = ({ eventKey, activePanel, callback }) => { <>
    handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - + +
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/clone.tsx b/libs/remix-ui/git/src/components/navigation/clone.tsx index ee9e1579bf..ac564290c4 100644 --- a/libs/remix-ui/git/src/components/navigation/clone.tsx +++ b/libs/remix-ui/git/src/components/navigation/clone.tsx @@ -17,13 +17,11 @@ export const CloneNavigation = ({ eventKey, activePanel, callback }) => { <>
    handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - + +
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/commands.tsx b/libs/remix-ui/git/src/components/navigation/commands.tsx index 9a3b3f03df..5a3ac86e15 100644 --- a/libs/remix-ui/git/src/components/navigation/commands.tsx +++ b/libs/remix-ui/git/src/components/navigation/commands.tsx @@ -21,15 +21,12 @@ export const CommandsNavigation = ({ eventKey, activePanel, callback }) => { return ( <>
    - handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - - - + handleClick()} role={'button'} className="nav d-flex justify-content-start align-items-center w-75"> + + +
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/commits.tsx b/libs/remix-ui/git/src/components/navigation/commits.tsx index a3cbcb1d2f..6e71f302d4 100644 --- a/libs/remix-ui/git/src/components/navigation/commits.tsx +++ b/libs/remix-ui/git/src/components/navigation/commits.tsx @@ -43,14 +43,11 @@ export const CommitsNavigation = ({ eventKey, activePanel, callback, title, bran <>
    handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-100'> - { - activePanel === eventKey ? : - } + {ahead? : null} {behind? : null} - + - {showButtons ? @@ -60,4 +57,4 @@ export const CommitsNavigation = ({ eventKey, activePanel, callback, title, bran
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/github.tsx b/libs/remix-ui/git/src/components/navigation/github.tsx index 2e45e3317a..4ad720a89f 100644 --- a/libs/remix-ui/git/src/components/navigation/github.tsx +++ b/libs/remix-ui/git/src/components/navigation/github.tsx @@ -1,7 +1,7 @@ -import { faCaretDown, faCaretRight } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import React, { } from "react"; -import { pluginActionsContext } from "../../state/context"; +import { faCaretDown, faCaretRight } from "@fortawesome/free-solid-svg-icons" +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" +import React, { } from "react" +import { pluginActionsContext } from "../../state/context" export const GitHubNavigation = ({ eventKey, activePanel, callback }) => { const pluginactions = React.useContext(pluginActionsContext) @@ -18,12 +18,10 @@ export const GitHubNavigation = ({ eventKey, activePanel, callback }) => { <>
    handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - + +
    - ); -} \ No newline at end of file + ) +} diff --git a/libs/remix-ui/git/src/components/navigation/log.tsx b/libs/remix-ui/git/src/components/navigation/log.tsx index 7b148b8de2..f9faaa7c42 100644 --- a/libs/remix-ui/git/src/components/navigation/log.tsx +++ b/libs/remix-ui/git/src/components/navigation/log.tsx @@ -47,10 +47,8 @@ export const LogNavigation = ({ eventKey, activePanel, callback }) => { <>
    handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - + + {logState.errorCount > 0 && (
    {logState.errorCount} @@ -84,4 +82,4 @@ export const LogNavigation = ({ eventKey, activePanel, callback }) => {
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/remotes.tsx b/libs/remix-ui/git/src/components/navigation/remotes.tsx index 8bb8c95494..551ea2cc0f 100644 --- a/libs/remix-ui/git/src/components/navigation/remotes.tsx +++ b/libs/remix-ui/git/src/components/navigation/remotes.tsx @@ -20,13 +20,11 @@ export const RemotesNavigation = ({ eventKey, activePanel, callback }) => { <>
    handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - + +
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/settings.tsx b/libs/remix-ui/git/src/components/navigation/settings.tsx index 9ea4d2c175..6dec9a514a 100644 --- a/libs/remix-ui/git/src/components/navigation/settings.tsx +++ b/libs/remix-ui/git/src/components/navigation/settings.tsx @@ -21,10 +21,8 @@ export const SettingsNavigation = ({ eventKey, activePanel, callback }) => { <>
    handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - + + @@ -38,4 +36,4 @@ export const SettingsNavigation = ({ eventKey, activePanel, callback }) => {
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx b/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx index e6eb60a36c..6ee074116f 100644 --- a/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx +++ b/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx @@ -24,12 +24,11 @@ export const SourceControlNavigation = ({ eventKey, activePanel, callback }) => return ( <> -
    - handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75'> - { - activePanel === eventKey ? : - } - +
    + handleClick()} role={'button'} className='nav d-flex justify-content-start align-items-center w-75' + > + + @@ -39,4 +38,4 @@ export const SourceControlNavigation = ({ eventKey, activePanel, callback }) =>
    ); -} \ No newline at end of file +} From 8a63f026d4124873f5553d2964ebd5db34e3397d Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 14:29:55 +0100 Subject: [PATCH 06/21] padding and spacing --- .../git/src/components/buttons/commitmessage.tsx | 4 ++-- libs/remix-ui/git/src/components/gitui.tsx | 4 ++-- .../src/components/navigation/sourcecontrolgroup.tsx | 10 ++++------ .../panels/sourcecontrol/sourcecontrolgroup.tsx | 2 +- .../panels/sourcecontrol/sourcecontrolitem.tsx | 12 ++++++------ .../git/src/components/panels/sourcontrol.tsx | 4 ++-- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/libs/remix-ui/git/src/components/buttons/commitmessage.tsx b/libs/remix-ui/git/src/components/buttons/commitmessage.tsx index 17fc807a79..e5726df46c 100644 --- a/libs/remix-ui/git/src/components/buttons/commitmessage.tsx +++ b/libs/remix-ui/git/src/components/buttons/commitmessage.tsx @@ -126,7 +126,7 @@ export const CommitMessage = () => { return ( <> -
    +
    + : null} : null @@ -49,4 +47,4 @@ export const SourceControlGroupNavigation = (props: SourceControlGroupNavigation
    ); -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolgroup.tsx b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolgroup.tsx index 1b17cb2b31..c6c77f3328 100644 --- a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolgroup.tsx +++ b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolgroup.tsx @@ -35,4 +35,4 @@ export const SourceControGroup = (props: SourceControGroupProps) => { : <>} ) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx index 64617b17e1..a28d2a6664 100644 --- a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx +++ b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx @@ -41,10 +41,10 @@ export const SourceControlItem = (props: SourceControlItemProps) => { return (<> - {status && status.indexOf("modified") === -1 ? <> :
    M
    } - {status && status.indexOf("deleted") === -1 ? <> : D} - {status && status.indexOf("added") === -1 ? <> : A} - {status && status.indexOf("untracked") === -1 ? <> : U} + {status && status.indexOf("modified") === -1 ? <> : M} + {status && status.indexOf("deleted") === -1 ? <> : D} + {status && status.indexOf("added") === -1 ? <> : A} + {status && status.indexOf("untracked") === -1 ? <> : U} ) } @@ -56,10 +56,10 @@ export const SourceControlItem = (props: SourceControlItemProps) => { {path.basename(file.filename)}
    {file.filename}
    -
    +
    ) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/panels/sourcontrol.tsx b/libs/remix-ui/git/src/components/panels/sourcontrol.tsx index ad54852073..64d1875791 100644 --- a/libs/remix-ui/git/src/components/panels/sourcontrol.tsx +++ b/libs/remix-ui/git/src/components/panels/sourcontrol.tsx @@ -37,7 +37,7 @@ export const SourceControl = () => { <> {show ? <> -
    +
    : <> @@ -46,4 +46,4 @@ export const SourceControl = () => { ); -} \ No newline at end of file +} From 072e6d570c312b6432873311c1a0b62767816aa2 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 14:53:32 +0100 Subject: [PATCH 07/21] spacing and cosmetics for source control --- libs/remix-ui/git/src/components/panels/sourcontrol.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/git/src/components/panels/sourcontrol.tsx b/libs/remix-ui/git/src/components/panels/sourcontrol.tsx index 64d1875791..beaf2638b7 100644 --- a/libs/remix-ui/git/src/components/panels/sourcontrol.tsx +++ b/libs/remix-ui/git/src/components/panels/sourcontrol.tsx @@ -37,7 +37,7 @@ export const SourceControl = () => { <> {show ? <> -
    +
    : <> From 51981ebf96ae430b0c8352555891099c66a17771 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 15:37:30 +0100 Subject: [PATCH 08/21] spacing and padding to branches --- libs/remix-ui/git/src/components/gitui.tsx | 5 +++-- libs/remix-ui/git/src/components/panels/branches.tsx | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 79be4d1c25..d723cc20ce 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -200,8 +200,9 @@ export const GitUI = (props: IGitUi) => {
    - <> - +
    + +

    diff --git a/libs/remix-ui/git/src/components/panels/branches.tsx b/libs/remix-ui/git/src/components/panels/branches.tsx index 503bea1202..0c70e1533f 100644 --- a/libs/remix-ui/git/src/components/panels/branches.tsx +++ b/libs/remix-ui/git/src/components/panels/branches.tsx @@ -18,7 +18,7 @@ export const Branches = () => { return ( <> -
    +
    {context.branches && context.branches.length ?
    {context.branches && context.branches.filter((branch, index) => !branch.remote).map((branch, index) => { @@ -32,9 +32,9 @@ export const Branches = () => { {context.currentBranch && context.currentBranch.name !== '' && (!context.branches || context.branches.length === 0) ? -
    Current branch is `{context.currentBranch.name}` but you have no commits.
    +
    Current branch is {`${context.currentBranch.name}`} but you have no commits.
    : null} - +
    { actions.createBranch(newBranch.value)} - className="btn w-md-25 w-100 btn-primary" + className="btn w-md-25 w-100 btn-primary mb-3" id="createbranch-btn" > create new branch @@ -57,4 +57,4 @@ export const Branches = () => {
    ); -} \ No newline at end of file +} From 65e49248f98a51aba6ebaaaf1963706c6b2274b6 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 15:59:24 +0100 Subject: [PATCH 09/21] add spacing and moved fetch repo button --- libs/remix-ui/git/src/components/gitui.tsx | 6 +++--- .../git/src/components/panels/remotes.tsx | 19 ++++++++++--------- .../src/components/panels/remotesimport.tsx | 3 +-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index d723cc20ce..fb9566895b 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -200,16 +200,16 @@ export const GitUI = (props: IGitUi) => {
    -
    +

    - <> +
    - +

    diff --git a/libs/remix-ui/git/src/components/panels/remotes.tsx b/libs/remix-ui/git/src/components/panels/remotes.tsx index 4a0728f3e4..5d0b561b8a 100644 --- a/libs/remix-ui/git/src/components/panels/remotes.tsx +++ b/libs/remix-ui/git/src/components/panels/remotes.tsx @@ -30,9 +30,11 @@ export const Remotes = (props: RemotesProps) => { return ( <> -
    +
    + +
    {context.remotes && context.remotes.length ? - <> +
    {context.remotes && context.remotes.map((remote, index) => { @@ -40,18 +42,17 @@ export const Remotes = (props: RemotesProps) => { ); })} - : <>No remotes} -
    +
    :
    + +
    } - onRemoteNameChange(e.target.value)} value={remoteName} className="form-control mb-2" type="text" id="remotename" /> - onUrlChange(e.target.value)} value={url} className="form-control" type="text" id="remoteurl" /> + onRemoteNameChange(e.target.value)} value={remoteName} className="form-control mb-3" type="text" id="remotename" /> + onUrlChange(e.target.value)} value={url} className="form-control mb-3" type="text" id="remoteurl" /> -
    - -
    +
    ) } diff --git a/libs/remix-ui/git/src/components/panels/remotesimport.tsx b/libs/remix-ui/git/src/components/panels/remotesimport.tsx index 9cbf4ec776..45c6013819 100644 --- a/libs/remix-ui/git/src/components/panels/remotesimport.tsx +++ b/libs/remix-ui/git/src/components/panels/remotesimport.tsx @@ -68,9 +68,8 @@ export const RemotesImport = (props: RemotesImportProps) => { return ( <> - - + {repo ? onRemoteNameChange(e.target.value)} value={remoteName} className="form-control mb-2" type="text" id="remotename" /> : null} From c9f3f069f3617463c5fe4dd873bfee23c5a69345 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 20:03:21 +0100 Subject: [PATCH 10/21] fix spacing in github setup --- .../git/src/components/github/devicecode.tsx | 4 ++-- libs/remix-ui/git/src/components/gitui.tsx | 16 ++++++++-------- .../remix-ui/git/src/components/panels/clone.tsx | 2 +- .../src/components/panels/githubcredentials.tsx | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libs/remix-ui/git/src/components/github/devicecode.tsx b/libs/remix-ui/git/src/components/github/devicecode.tsx index cd611efe4d..9e1a8ce2d9 100644 --- a/libs/remix-ui/git/src/components/github/devicecode.tsx +++ b/libs/remix-ui/git/src/components/github/devicecode.tsx @@ -72,7 +72,7 @@ export const GetDeviceCode = () => { return ( <> {(context.gitHubUser && context.gitHubUser.login) ? null : - } @@ -124,4 +124,4 @@ export const GetDeviceCode = () => { } ) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index fb9566895b..87d3b2145c 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -200,38 +200,38 @@ export const GitUI = (props: IGitUi) => {
    -
    +

    -
    +

    - <> - +
    +

    - <> +

    - +

    - <> +
    - +
    diff --git a/libs/remix-ui/git/src/components/panels/clone.tsx b/libs/remix-ui/git/src/components/panels/clone.tsx index 4e562be544..daddc53ad7 100644 --- a/libs/remix-ui/git/src/components/panels/clone.tsx +++ b/libs/remix-ui/git/src/components/panels/clone.tsx @@ -67,7 +67,7 @@ export const Clone = ({ plugin }: CloneProps) => { return ( <> -
    +

    diff --git a/libs/remix-ui/git/src/components/panels/githubcredentials.tsx b/libs/remix-ui/git/src/components/panels/githubcredentials.tsx index 300e6797f0..607e86f5dc 100644 --- a/libs/remix-ui/git/src/components/panels/githubcredentials.tsx +++ b/libs/remix-ui/git/src/components/panels/githubcredentials.tsx @@ -67,14 +67,14 @@ export const GitHubCredentials = () => { return ( <> -
    +
    handleChangeTokenState(e.target.value)} />
    - handleChangeUserNameState(e.target.value)} value={githubUsername} className="form-control mb-1" placeholder="Git username" type="text" id="githubUsername" /> - handleChangeEmailState(e.target.value)} value={githubEmail} className="form-control mb-1" placeholder="Git email" type="text" id="githubEmail" /> + handleChangeUserNameState(e.target.value)} value={githubUsername} className="form-control mb-3" placeholder="Git username" type="text" id="githubUsername" /> + handleChangeEmailState(e.target.value)} value={githubEmail} className="form-control mb-3" placeholder="Git email" type="text" id="githubEmail" />
    } {gitHubResponse && !authorized && From 45151d4f1dc6f1d12f271c7f6a8ee7f715e379b4 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 20:22:19 +0100 Subject: [PATCH 12/21] fix padding --- libs/remix-ui/git/src/components/gitui.tsx | 6 +++--- .../git/src/components/navigation/sourcecontrolgroup.tsx | 2 +- libs/remix-ui/git/src/components/panels/commands.tsx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 87d3b2145c..89dbbb434e 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -178,7 +178,7 @@ export const GitUI = (props: IGitUi) => { -
    +
    @@ -186,9 +186,9 @@ export const GitUI = (props: IGitUi) => {
    - <> +
    - +

    diff --git a/libs/remix-ui/git/src/components/navigation/sourcecontrolgroup.tsx b/libs/remix-ui/git/src/components/navigation/sourcecontrolgroup.tsx index cb392522c3..e80b43defd 100644 --- a/libs/remix-ui/git/src/components/navigation/sourcecontrolgroup.tsx +++ b/libs/remix-ui/git/src/components/navigation/sourcecontrolgroup.tsx @@ -39,7 +39,7 @@ export const SourceControlGroupNavigation = (props: SourceControlGroupNavigation {group.name === 'Changes' ? }> - + : null} : null diff --git a/libs/remix-ui/git/src/components/panels/commands.tsx b/libs/remix-ui/git/src/components/panels/commands.tsx index 45f6f05aeb..162603eb26 100644 --- a/libs/remix-ui/git/src/components/panels/commands.tsx +++ b/libs/remix-ui/git/src/components/panels/commands.tsx @@ -6,7 +6,7 @@ import { Merge } from "./commands/merge"; export const Commands = () => { return ( -
    +

    From 13a82e7cbc67577bdc51ab773990dddad2d4198e Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 2 Jul 2024 22:51:20 +0100 Subject: [PATCH 13/21] fix labels --- libs/remix-ui/git/src/components/panels/clone.tsx | 2 +- .../git/src/components/panels/commands/pushpull.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/git/src/components/panels/clone.tsx b/libs/remix-ui/git/src/components/panels/clone.tsx index daddc53ad7..5b6605879d 100644 --- a/libs/remix-ui/git/src/components/panels/clone.tsx +++ b/libs/remix-ui/git/src/components/panels/clone.tsx @@ -79,7 +79,7 @@ export const Clone = ({ plugin }: CloneProps) => { clone() }}>clone
    - + diff --git a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx index 48088706a0..22ac035e4d 100644 --- a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx +++ b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx @@ -148,7 +148,7 @@ export const PushPull = () => { push()} className="btn btn-primary">Push
    - + { placeholder="Type to search for a branch..." /> - + onRemoteNameChange(e.target.value)} value={remoteName} className="form-control mb-2" type="text" id="remotename" /> : null} diff --git a/libs/remix-ui/git/src/components/panels/tokenWarning.tsx b/libs/remix-ui/git/src/components/panels/tokenWarning.tsx index bce647758e..e13b3c912e 100644 --- a/libs/remix-ui/git/src/components/panels/tokenWarning.tsx +++ b/libs/remix-ui/git/src/components/panels/tokenWarning.tsx @@ -1,18 +1,13 @@ import { gitPluginContext } from "../gitui" import React, { useEffect, useState } from "react" -export interface TokenWarningProps { - plugin: any -} - -export const TokenWarning = (props: TokenWarningProps) => { +export const TokenWarning = () => { const context = React.useContext(gitPluginContext) return (<> {(context.gitHubUser && context.gitHubUser.login) ? null : Generate and add a Git token to use this plugin. Tokens are added in { - await props.plugin.call('menuicons', 'select', 'settings') - }}>settings of the IDE. + }}>settings. } From c4836a02b912e031d11b417ce3a6b4829802e165 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 3 Jul 2024 10:04:44 +0100 Subject: [PATCH 15/21] remove unnecessary plugin props --- .../src/components/github/selectandclonerepositories.tsx | 3 +-- libs/remix-ui/git/src/components/gitui.tsx | 2 +- libs/remix-ui/git/src/components/panels/clone.tsx | 8 ++------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx b/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx index d62b761118..c90c252eb2 100644 --- a/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx +++ b/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx @@ -9,7 +9,6 @@ import { TokenWarning } from "../panels/tokenWarning"; interface RepositoriesProps { cloneDepth?: number cloneAllBranches?: boolean - plugin: any } export const SelectAndCloneRepositories = (props: RepositoriesProps) => { @@ -45,7 +44,7 @@ export const SelectAndCloneRepositories = (props: RepositoriesProps) => { return ( <> - + { repo && } diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 2086e2349d..083a6da59b 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -215,7 +215,7 @@ export const GitUI = (props: IGitUi) => {
    -
    +

    diff --git a/libs/remix-ui/git/src/components/panels/clone.tsx b/libs/remix-ui/git/src/components/panels/clone.tsx index 5b6605879d..2454cecf84 100644 --- a/libs/remix-ui/git/src/components/panels/clone.tsx +++ b/libs/remix-ui/git/src/components/panels/clone.tsx @@ -8,11 +8,7 @@ import { SelectAndCloneRepositories } from "../github/selectandclonerepositories import { RemixUiCheckbox } from "@remix-ui/checkbox" import GitUIButton from "../buttons/gituibutton" -export interface CloneProps { - plugin: any -} - -export const Clone = ({ plugin }: CloneProps) => { +export const Clone = () => { const context = React.useContext(gitPluginContext) const actions = React.useContext(gitActionsContext) const [cloneUrl, setCloneUrl] = useLocalStorage( @@ -68,7 +64,7 @@ export const Clone = ({ plugin }: CloneProps) => { return ( <>
    - +
    onGitHubCloneUrlChange(e.target.value)} aria-describedby="urlprepend" /> From fe7fc98bd3faf07b382a2d077dc445de265e8d41 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 4 Jul 2024 14:47:41 +0100 Subject: [PATCH 16/21] finish dgit heading. cleanup --- .../git/src/components/branchHeader.tsx | 83 ++++++++++++++++--- libs/remix-ui/git/src/components/gitui.tsx | 4 +- libs/remix-ui/git/src/lib/pluginActions.ts | 9 ++ 3 files changed, 81 insertions(+), 15 deletions(-) diff --git a/libs/remix-ui/git/src/components/branchHeader.tsx b/libs/remix-ui/git/src/components/branchHeader.tsx index debb86bd5a..225eb12523 100644 --- a/libs/remix-ui/git/src/components/branchHeader.tsx +++ b/libs/remix-ui/git/src/components/branchHeader.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react' import { gitActionsContext, pluginActionsContext } from '../state/context' +import { storageStatus } from '../lib/pluginActions' import { ReadCommitResult } from "isomorphic-git" import { gitPluginContext } from './gitui' export const BranchHeader = () => { @@ -10,6 +11,7 @@ export const BranchHeader = () => { const [changed, setChanged] = useState(false) const [isDetached, setIsDetached] = useState(false) const [latestCommit, setLatestCommit] = useState(null) + const [storageStats, setStorageStats] = useState('') useEffect(() => { if (context.currentBranch) { @@ -43,6 +45,25 @@ export const BranchHeader = () => { } }, [context.fileStatusResult, context.modified, context.allchangesnotstaged, context.untracked, context.deleted]) + useEffect(() => { + const run = async () => { + const stats = await storageStatus() + setStorageStats(stats) + } + run() + + return () => { + run() + } + }, []) + + const getName = () => { + const url = context.currentBranch?.remote?.url + const regex = /https:\/\/github\.com\/[^/]+\/([^/]+)\.git/ + const match = url.match(regex) + return match ? match[1] : 'Couldn\'t get repo name!' + } + const showDetachedWarningText = async () => { await pluginActions.showAlert({ message: `You are in 'detached HEAD' state. This means you are not on a branch because you checkout a tag or a specific commit. If you want to commit changes, you will need to create a new branch.`, @@ -50,21 +71,57 @@ export const BranchHeader = () => { }) } + const Heading = () => { + return ( +
    +
    +
    +
    + Repository Name: + + + {getName()} + + +
    +
    + Branch Name: + + + + {context.currentBranch && context.currentBranch.name} + + +
    +
    + + Storage : + + {storageStats} MB + + +
    +
    + + Messages : + + {latestCommit ? + latestCommit.commit && latestCommit.commit.message ? latestCommit.commit.message : '' : null} + {isDetached ? + <>You are in a detached state: null} + + +
    +
    +
    +
    + ) + } + return (<>
    -
    - - {changed ? '*' : ''}{context.currentBranch && context.currentBranch.name} -
    - {latestCommit ? -
    - {latestCommit.commit && latestCommit.commit.message ? latestCommit.commit.message : ''} -
    : null} - {isDetached ? -
    - You are in a detached state -
    : null} +

    ) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 083a6da59b..b0f5337c58 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -193,9 +193,9 @@ export const GitUI = (props: IGitUi) => {
    - <> +
    - +

    diff --git a/libs/remix-ui/git/src/lib/pluginActions.ts b/libs/remix-ui/git/src/lib/pluginActions.ts index ece2b3953a..9b1f5f235b 100644 --- a/libs/remix-ui/git/src/lib/pluginActions.ts +++ b/libs/remix-ui/git/src/lib/pluginActions.ts @@ -23,6 +23,15 @@ export const statusChanged = (badges: number) => { }) } +export const storageStatus = async () => { + try { + const status = await plugin?.call('dgitApi' as any, 'localStorageUsed') + return status + } catch (error) { + console.log('An error occured while getting storage use summary', error) + } +} + export const openFile = async (path: string) => { if (!plugin) return await plugin.call('fileManager', 'open', path) From a3f041207668c29a248e6cbc85343e07f630f8d9 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 4 Jul 2024 15:36:02 +0100 Subject: [PATCH 17/21] handle error case --- libs/remix-ui/git/src/components/branchHeader.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/git/src/components/branchHeader.tsx b/libs/remix-ui/git/src/components/branchHeader.tsx index 225eb12523..c478f4bd39 100644 --- a/libs/remix-ui/git/src/components/branchHeader.tsx +++ b/libs/remix-ui/git/src/components/branchHeader.tsx @@ -59,6 +59,7 @@ export const BranchHeader = () => { const getName = () => { const url = context.currentBranch?.remote?.url + if (!url) return const regex = /https:\/\/github\.com\/[^/]+\/([^/]+)\.git/ const match = url.match(regex) return match ? match[1] : 'Couldn\'t get repo name!' @@ -80,7 +81,7 @@ export const BranchHeader = () => { Repository Name: - {getName()} + {getName() ?? ''}
    From 6777fdbbaad1dbf0882a55585bff8e73b6610cb6 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Fri, 5 Jul 2024 13:55:50 +0200 Subject: [PATCH 18/21] add storage state --- .../git/src/components/branchHeader.tsx | 36 +- libs/remix-ui/git/src/lib/gitactions.ts | 11 +- libs/remix-ui/git/src/lib/listeners.ts | 55 ++- libs/remix-ui/git/src/lib/pluginActions.ts | 9 - libs/remix-ui/git/src/state/actions.ts | 3 +- libs/remix-ui/git/src/state/gitpayload.ts | 9 +- libs/remix-ui/git/src/state/gitreducer.tsx | 398 +++++++++--------- libs/remix-ui/git/src/types/index.ts | 18 +- 8 files changed, 300 insertions(+), 239 deletions(-) diff --git a/libs/remix-ui/git/src/components/branchHeader.tsx b/libs/remix-ui/git/src/components/branchHeader.tsx index c478f4bd39..79b3e3d4db 100644 --- a/libs/remix-ui/git/src/components/branchHeader.tsx +++ b/libs/remix-ui/git/src/components/branchHeader.tsx @@ -1,6 +1,5 @@ import React, { useEffect, useState } from 'react' import { gitActionsContext, pluginActionsContext } from '../state/context' -import { storageStatus } from '../lib/pluginActions' import { ReadCommitResult } from "isomorphic-git" import { gitPluginContext } from './gitui' export const BranchHeader = () => { @@ -11,7 +10,6 @@ export const BranchHeader = () => { const [changed, setChanged] = useState(false) const [isDetached, setIsDetached] = useState(false) const [latestCommit, setLatestCommit] = useState(null) - const [storageStats, setStorageStats] = useState('') useEffect(() => { if (context.currentBranch) { @@ -45,18 +43,6 @@ export const BranchHeader = () => { } }, [context.fileStatusResult, context.modified, context.allchangesnotstaged, context.untracked, context.deleted]) - useEffect(() => { - const run = async () => { - const stats = await storageStatus() - setStorageStats(stats) - } - run() - - return () => { - run() - } - }, []) - const getName = () => { const url = context.currentBranch?.remote?.url if (!url) return @@ -80,7 +66,7 @@ export const BranchHeader = () => {
    Repository Name: - + {getName() ?? ''} @@ -88,20 +74,22 @@ export const BranchHeader = () => {
    Branch Name: - + {context.currentBranch && context.currentBranch.name}
    -
    - - Storage : - - {storageStats} MB + {context.storage.enabled ? +
    + + Storage : + + {context.storage.used} MB used + ({context.storage.percentUsed} %) + - -
    +
    : null}
    Messages : @@ -109,7 +97,7 @@ export const BranchHeader = () => { {latestCommit ? latestCommit.commit && latestCommit.commit.message ? latestCommit.commit.message : '' : null} {isDetached ? - <>You are in a detached state: null} + <>You are in a detached state : null}
    diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index 314d9143e5..b9e0817bd1 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -1,7 +1,7 @@ import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; 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 } from "../state/gitpayload"; -import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails } from '../types'; +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 } from "../state/gitpayload"; +import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails, storage } from '../types'; import { removeSlash } from "../utils"; import { disableCallBacks, enableCallBacks } from "./listeners"; import { ModalTypes } from "@remix-ui/app"; @@ -849,4 +849,9 @@ export const sendToGitLog = async (message: gitLog) => { export const clearGitLog = async () => { dispatch(clearLog()) -} \ No newline at end of file +} + +export const setStorage = async (storage: storage) => { + console.log(storage) + dispatch(setStoragePayload(storage)) +} diff --git a/libs/remix-ui/git/src/lib/listeners.ts b/libs/remix-ui/git/src/lib/listeners.ts index 66c94bdd8d..88fd8c2a85 100644 --- a/libs/remix-ui/git/src/lib/listeners.ts +++ b/libs/remix-ui/git/src/lib/listeners.ts @@ -1,9 +1,9 @@ import React from "react"; import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog, setGitHubUser, setUserEmails } from "../state/gitpayload"; -import { gitActionDispatch } from "../types"; +import { gitActionDispatch, storage } from "../types"; import { Plugin } from "@remixproject/engine"; -import { getBranches, getFileStatusMatrix, loadGitHubUserFromToken, getRemotes, gitlog, setPlugin } from "./gitactions"; +import { getBranches, getFileStatusMatrix, loadGitHubUserFromToken, getRemotes, gitlog, setPlugin, setStorage } from "./gitactions"; import { Profile } from "@remixproject/plugin-utils"; import { CustomRemixApi } from "@remix-api"; import { statusChanged } from "./pluginActions"; @@ -20,7 +20,7 @@ class AsyncDebouncedQueue { this.queues = new Map(); } - enqueue(callback: AsyncCallback, customDelay?:number): void { + enqueue(callback: AsyncCallback, customDelay?: number): void { if (this.queues.has(callback)) { clearTimeout(this.queues.get(callback)!.timer); } @@ -180,6 +180,7 @@ export const getGitConfig = async () => { export const loadFiles = async (filepaths: string[] = null) => { try { + await calculateLocalStorage() const branch = await plugin.call('dgitApi', "currentbranch") if (branch) { await getFileStatusMatrix(filepaths); @@ -199,3 +200,51 @@ export const enableCallBacks = async () => { callBackEnabled = true; } +const calculateLocalStorage = async () => { + function bytesToMB(bytes) { + return parseFloat((bytes / (1024 * 1024)).toFixed(2)); + } + + function calculatePercentage(used, quota) { + return parseFloat(((used / quota) * 100).toFixed(2)); + } + + let storage: storage = { + used: 0, + total: 0, + available: 0, + percentUsed: 0, + enabled: false + } + + if ('storage' in navigator && 'estimate' in navigator.storage) { + navigator.storage.estimate().then(estimate => { + const usedMB = bytesToMB(estimate.usage); + const quotaMB = bytesToMB(estimate.quota); + const availableMB = bytesToMB(estimate.quota - estimate.usage); + const percentageUsed = calculatePercentage(estimate.usage, estimate.quota); + + console.log(`Used storage: ${usedMB} MB`); + console.log(`Total quota: ${quotaMB} MB`); + console.log(`Available storage: ${availableMB} MB`); + console.log(`Percentage used: ${percentageUsed}%`); + + storage = { + used: usedMB, + total: quotaMB, + available: availableMB, + percentUsed: percentageUsed, + enabled: true + } + setStorage(storage); + + }); + } else { + console.log('Storage API not supported in this browser.'); + setStorage(storage); + } + + + +} + diff --git a/libs/remix-ui/git/src/lib/pluginActions.ts b/libs/remix-ui/git/src/lib/pluginActions.ts index 9b1f5f235b..ece2b3953a 100644 --- a/libs/remix-ui/git/src/lib/pluginActions.ts +++ b/libs/remix-ui/git/src/lib/pluginActions.ts @@ -23,15 +23,6 @@ export const statusChanged = (badges: number) => { }) } -export const storageStatus = async () => { - try { - const status = await plugin?.call('dgitApi' as any, 'localStorageUsed') - return status - } catch (error) { - console.log('An error occured while getting storage use summary', error) - } -} - export const openFile = async (path: string) => { if (!plugin) return await plugin.call('fileManager', 'open', path) diff --git a/libs/remix-ui/git/src/state/actions.ts b/libs/remix-ui/git/src/state/actions.ts index 4d35aa1b8c..61cdd628c5 100644 --- a/libs/remix-ui/git/src/state/actions.ts +++ b/libs/remix-ui/git/src/state/actions.ts @@ -1,5 +1,5 @@ import { ReadCommitResult } from "isomorphic-git" -import { branch, branchDifference, commitChange, fileStatusResult, GitHubUser, gitLog, pagedCommits, remote, remoteBranch, repository, userEmails } from "../types" +import { branch, branchDifference, commitChange, fileStatusResult, GitHubUser, gitLog, pagedCommits, remote, remoteBranch, repository, storage, userEmails } from "../types" export interface ActionPayloadTypes { FILE_STATUS: fileStatusResult[], @@ -42,6 +42,7 @@ export interface ActionPayloadTypes { SET_LOG: gitLog CLEAR_LOG: void SET_USER_EMAILS: userEmails + SET_STORAGE: storage } export interface Action { diff --git a/libs/remix-ui/git/src/state/gitpayload.ts b/libs/remix-ui/git/src/state/gitpayload.ts index c075331d6e..1211775280 100644 --- a/libs/remix-ui/git/src/state/gitpayload.ts +++ b/libs/remix-ui/git/src/state/gitpayload.ts @@ -1,5 +1,5 @@ import { ReadCommitResult } from "isomorphic-git" -import { GitHubUser, branch, commitChange, fileStatusResult, remote, pagedCommits, branchDifference, gitLog, repository, userEmails } from "../types" +import { GitHubUser, branch, commitChange, fileStatusResult, remote, pagedCommits, branchDifference, gitLog, repository, userEmails, storage } from "../types" import { Endpoints } from "@octokit/types" export const fileStatus = (files: fileStatusResult[]) => { @@ -218,3 +218,10 @@ export const clearLog = () => { type: 'CLEAR_LOG' } } + +export const setStoragePayload = (storage: storage) => { + return { + type: 'SET_STORAGE', + payload: storage + } +} diff --git a/libs/remix-ui/git/src/state/gitreducer.tsx b/libs/remix-ui/git/src/state/gitreducer.tsx index 674e1e69a5..4ea8a94d84 100644 --- a/libs/remix-ui/git/src/state/gitreducer.tsx +++ b/libs/remix-ui/git/src/state/gitreducer.tsx @@ -6,203 +6,209 @@ import { Actions } from "./actions" export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => { switch (action.type) { - case 'FILE_STATUS': - return { - ...state, - fileStatusResult: action.payload, - staged: getFilesByStatus("staged", action.payload), - modified: getFilesByStatus("modified", action.payload), - untracked: getFilesByStatus("untracked", action.payload), - deleted: getFilesByStatus("deleted", action.payload), - allchangesnotstaged: allChangedButNotStagedFiles(action.payload) - } - - case 'FILE_STATUS_MERGE': - action.payload.map((fileStatusResult: fileStatusResult) => { - const file = state.fileStatusResult.find(stateFile => { - return stateFile.filename === fileStatusResult.filename + case 'FILE_STATUS': + return { + ...state, + fileStatusResult: action.payload, + staged: getFilesByStatus("staged", action.payload), + modified: getFilesByStatus("modified", action.payload), + untracked: getFilesByStatus("untracked", action.payload), + deleted: getFilesByStatus("deleted", action.payload), + allchangesnotstaged: allChangedButNotStagedFiles(action.payload) + } + + case 'FILE_STATUS_MERGE': + action.payload.map((fileStatusResult: fileStatusResult) => { + const file = state.fileStatusResult.find(stateFile => { + return stateFile.filename === fileStatusResult.filename + }) + if (file) { + file.status = fileStatusResult.status + file.statusNames = fileStatusResult.statusNames + } + }) + + return { + ...state, + staged: getFilesByStatus("staged", state.fileStatusResult), + modified: getFilesByStatus("modified", state.fileStatusResult), + untracked: getFilesByStatus("untracked", state.fileStatusResult), + deleted: getFilesByStatus("deleted", state.fileStatusResult), + allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult) + } + + case 'SET_COMMITS': + return { + ...state, + commits: action.payload, + localCommitCount: action.payload.length + } + + case 'SET_BRANCHES': + return { + ...state, + branches: action.payload + } + + case 'SET_CURRENT_BRANCH': + return { + ...state, + currentBranch: action.payload + } + + case 'SET_CURRENT_HEAD': + return { + ...state, + currentHead: action.payload + } + + case 'SET_CAN_USE_APP': + return { + ...state, + canUseApp: action.payload + } + case 'SET_REPO_NAME': + return { + ...state, + reponame: action.payload + } + case 'SET_LOADING': + return { + ...state, + loading: action.payload + } + + case 'SET_REPOS': + return { + ...state, + repositories: action.payload + } + + case 'SET_REMOTE_BRANCHES': + return { + ...state, + remoteBranches: action.payload + } + + case 'SET_CAN_COMMIT': + return { + ...state, + canCommit: action.payload + } + + case 'SET_REMOTES': + return { + ...state, + remotes: action.payload + } + + case 'SET_UPSTREAM': + return { + ...state, + upstream: action.payload + } + + case 'SET_COMMIT_CHANGES': + + action.payload.forEach((change: commitChange) => { + state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change) }) - if (file) { - file.status = fileStatusResult.status - file.statusNames = fileStatusResult.statusNames - } - }) - - return { - ...state, - staged: getFilesByStatus("staged", state.fileStatusResult), - modified: getFilesByStatus("modified", state.fileStatusResult), - untracked: getFilesByStatus("untracked", state.fileStatusResult), - deleted: getFilesByStatus("deleted", state.fileStatusResult), - allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult) - } - - case 'SET_COMMITS': - return { - ...state, - commits: action.payload, - localCommitCount: action.payload.length - } - - case 'SET_BRANCHES': - return { - ...state, - branches: action.payload - } - - case 'SET_CURRENT_BRANCH': - return { - ...state, - currentBranch: action.payload - } - - case 'SET_CURRENT_HEAD': - return { - ...state, - currentHead: action.payload - } - - case 'SET_CAN_USE_APP': - return { - ...state, - canUseApp: action.payload - } - case 'SET_REPO_NAME': - return { - ...state, - reponame: action.payload - } - case 'SET_LOADING': - return { - ...state, - loading: action.payload - } - - case 'SET_REPOS': - return { - ...state, - repositories: action.payload - } - - case 'SET_REMOTE_BRANCHES': - return { - ...state, - remoteBranches: action.payload - } - - case 'SET_CAN_COMMIT': - return { - ...state, - canCommit: action.payload - } - - case 'SET_REMOTES': - return { - ...state, - remotes: action.payload - } - - case 'SET_UPSTREAM': - return { - ...state, - upstream: action.payload - } - - case 'SET_COMMIT_CHANGES': - - action.payload.forEach((change: commitChange) => { - state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change) - }) - - return { - ...state, - commitChanges: [...state.commitChanges] - } - - case 'RESET_REMOTE_BRANCH_COMMITS': - if (state.remoteBranchCommits[action.payload.branch.name]) { - delete state.remoteBranchCommits[action.payload.branch.name] - } - return { - ...state, - remoteBranchCommits: { ...state.remoteBranchCommits } - } - - case 'SET_REMOTE_BRANCH_COMMITS': - if (state.remoteBranchCommits[action.payload.branch.name]) { - state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits) - } else { - state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits - } - return { - ...state, - remoteBranchCommits: { ...state.remoteBranchCommits } - } - - case 'SET_LOCAL_BRANCH_COMMITS': - - state.localBranchCommits[action.payload.branch.name] = action.payload.commits - return { - ...state, - localBranchCommits: { ...state.localBranchCommits } - } - - case 'SET_BRANCH_DIFFERENCES': - - state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference - - return { - ...state, - branchDifferences: { ...state.branchDifferences } - } - - case 'SET_GITHUB_USER': - return { - ...state, - gitHubUser: action.payload - } - - case 'SET_GITHUB_ACCESS_TOKEN': - return { - ...state, - gitHubAccessToken: action.payload - } - - case 'SET_SCOPES': - return { - ...state, - gitHubScopes: action.payload - } - - case 'SET_USER_EMAILS': - return { - ...state, - userEmails: action.payload - } - - case 'SET_DEFAULT_REMOTE': - return { - ...state, - defaultRemote: action.payload - } - - case 'SET_LOG': - if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) { - return { - ...state, - log: [...state.log] - } - } - return { - ...state, - log: [...state.log, action.payload] - } - - case 'CLEAR_LOG': - return { - ...state, - log: [] - } + + return { + ...state, + commitChanges: [...state.commitChanges] + } + + case 'RESET_REMOTE_BRANCH_COMMITS': + if (state.remoteBranchCommits[action.payload.branch.name]) { + delete state.remoteBranchCommits[action.payload.branch.name] + } + return { + ...state, + remoteBranchCommits: { ...state.remoteBranchCommits } + } + + case 'SET_REMOTE_BRANCH_COMMITS': + if (state.remoteBranchCommits[action.payload.branch.name]) { + state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits) + } else { + state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits + } + return { + ...state, + remoteBranchCommits: { ...state.remoteBranchCommits } + } + + case 'SET_LOCAL_BRANCH_COMMITS': + + state.localBranchCommits[action.payload.branch.name] = action.payload.commits + return { + ...state, + localBranchCommits: { ...state.localBranchCommits } + } + + case 'SET_BRANCH_DIFFERENCES': + + state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference + + return { + ...state, + branchDifferences: { ...state.branchDifferences } + } + + case 'SET_GITHUB_USER': + return { + ...state, + gitHubUser: action.payload + } + + case 'SET_GITHUB_ACCESS_TOKEN': + return { + ...state, + gitHubAccessToken: action.payload + } + + case 'SET_SCOPES': + return { + ...state, + gitHubScopes: action.payload + } + + case 'SET_USER_EMAILS': + return { + ...state, + userEmails: action.payload + } + + case 'SET_DEFAULT_REMOTE': + return { + ...state, + defaultRemote: action.payload + } + + case 'SET_LOG': + if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) { + return { + ...state, + log: [...state.log] + } + } + return { + ...state, + log: [...state.log, action.payload] + } + + case 'CLEAR_LOG': + return { + ...state, + log: [] + } + + case 'SET_STORAGE': + return { + ...state, + storage: action.payload + } } } \ No newline at end of file diff --git a/libs/remix-ui/git/src/types/index.ts b/libs/remix-ui/git/src/types/index.ts index 9ed9a292ed..0041aaf357 100644 --- a/libs/remix-ui/git/src/types/index.ts +++ b/libs/remix-ui/git/src/types/index.ts @@ -163,7 +163,7 @@ export type gitState = { fileStatusResult: fileStatusResult[] canUseApp: boolean loading: boolean - storageUsed: any + storage: storage reponame: string staged: fileStatusResult[] untracked: fileStatusResult[] @@ -282,7 +282,13 @@ export const defaultGitState: gitState = { allchangesnotstaged: [], canUseApp: true, loading: false, - storageUsed: {}, + storage: { + used: 0, + total: 0, + available: 0, + percentUsed: 0, + enabled: false + }, reponame: "", repositories: [], remoteBranches: [], @@ -324,6 +330,14 @@ export type sourceControlGroup = { name: string } +export type storage = { + used: number, + total: number + available: number + percentUsed: number + enabled: boolean +} + export interface fileStatusAction { type: string, payload: fileStatusResult[] From a00c06234a9fccf9a9290827c2856bbb9ba20f02 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 5 Jul 2024 13:19:05 +0100 Subject: [PATCH 19/21] fix styles in header --- .../git/src/components/branchHeader.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libs/remix-ui/git/src/components/branchHeader.tsx b/libs/remix-ui/git/src/components/branchHeader.tsx index 79b3e3d4db..9c628d3677 100644 --- a/libs/remix-ui/git/src/components/branchHeader.tsx +++ b/libs/remix-ui/git/src/components/branchHeader.tsx @@ -64,9 +64,9 @@ export const BranchHeader = () => {
    - Repository Name: - - + Repository Name: + + {getName() ?? ''} @@ -81,23 +81,25 @@ export const BranchHeader = () => {
    {context.storage.enabled ? -
    - - Storage : +
    + + Storage : {context.storage.used} MB used - ({context.storage.percentUsed} %) + ({context.storage.percentUsed} %)
    : null}
    - Messages : - - {latestCommit ? - latestCommit.commit && latestCommit.commit.message ? latestCommit.commit.message : '' : null} - {isDetached ? - <>You are in a detached state : null} + Messages : + + + {latestCommit ? + latestCommit.commit && latestCommit.commit.message ? latestCommit.commit.message : '' : null} + {isDetached ? + <>You are in a detached state: null} +
    From b0571665779b3a3d46041e2ed7603cbe3203d54d Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 5 Jul 2024 14:32:37 +0100 Subject: [PATCH 20/21] fix spaces --- .../git/src/components/branchHeader.tsx | 31 +- libs/remix-ui/git/src/state/gitreducer.tsx | 406 +++++++++--------- 2 files changed, 220 insertions(+), 217 deletions(-) diff --git a/libs/remix-ui/git/src/components/branchHeader.tsx b/libs/remix-ui/git/src/components/branchHeader.tsx index 9c628d3677..2c6b635921 100644 --- a/libs/remix-ui/git/src/components/branchHeader.tsx +++ b/libs/remix-ui/git/src/components/branchHeader.tsx @@ -63,17 +63,20 @@ export const BranchHeader = () => {
    -
    - Repository Name: - - - {getName() ?? ''} + {getName() !== "Couldn't get repo name!" ? ( +
    + Repository Name: + + + {getName() ?? ''} + - -
    +
    + ) : null + }
    - Branch Name: - + Branch Name: + {context.currentBranch && context.currentBranch.name} @@ -83,7 +86,7 @@ export const BranchHeader = () => { {context.storage.enabled ?
    - Storage : + Storage : {context.storage.used} MB used ({context.storage.percentUsed} %) @@ -91,10 +94,10 @@ export const BranchHeader = () => {
    : null}
    - - Messages : - - + + Messages : + + {latestCommit ? latestCommit.commit && latestCommit.commit.message ? latestCommit.commit.message : '' : null} {isDetached ? diff --git a/libs/remix-ui/git/src/state/gitreducer.tsx b/libs/remix-ui/git/src/state/gitreducer.tsx index 4ea8a94d84..df3ed0a7a8 100644 --- a/libs/remix-ui/git/src/state/gitreducer.tsx +++ b/libs/remix-ui/git/src/state/gitreducer.tsx @@ -6,209 +6,209 @@ import { Actions } from "./actions" export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => { switch (action.type) { - case 'FILE_STATUS': - return { - ...state, - fileStatusResult: action.payload, - staged: getFilesByStatus("staged", action.payload), - modified: getFilesByStatus("modified", action.payload), - untracked: getFilesByStatus("untracked", action.payload), - deleted: getFilesByStatus("deleted", action.payload), - allchangesnotstaged: allChangedButNotStagedFiles(action.payload) - } - - case 'FILE_STATUS_MERGE': - action.payload.map((fileStatusResult: fileStatusResult) => { - const file = state.fileStatusResult.find(stateFile => { - return stateFile.filename === fileStatusResult.filename - }) - if (file) { - file.status = fileStatusResult.status - file.statusNames = fileStatusResult.statusNames - } - }) - - return { - ...state, - staged: getFilesByStatus("staged", state.fileStatusResult), - modified: getFilesByStatus("modified", state.fileStatusResult), - untracked: getFilesByStatus("untracked", state.fileStatusResult), - deleted: getFilesByStatus("deleted", state.fileStatusResult), - allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult) - } - - case 'SET_COMMITS': - return { - ...state, - commits: action.payload, - localCommitCount: action.payload.length - } - - case 'SET_BRANCHES': - return { - ...state, - branches: action.payload - } - - case 'SET_CURRENT_BRANCH': - return { - ...state, - currentBranch: action.payload - } - - case 'SET_CURRENT_HEAD': - return { - ...state, - currentHead: action.payload - } - - case 'SET_CAN_USE_APP': - return { - ...state, - canUseApp: action.payload - } - case 'SET_REPO_NAME': - return { - ...state, - reponame: action.payload - } - case 'SET_LOADING': - return { - ...state, - loading: action.payload - } - - case 'SET_REPOS': - return { - ...state, - repositories: action.payload - } - - case 'SET_REMOTE_BRANCHES': - return { - ...state, - remoteBranches: action.payload - } - - case 'SET_CAN_COMMIT': - return { - ...state, - canCommit: action.payload - } - - case 'SET_REMOTES': - return { - ...state, - remotes: action.payload - } - - case 'SET_UPSTREAM': - return { - ...state, - upstream: action.payload - } - - case 'SET_COMMIT_CHANGES': - - action.payload.forEach((change: commitChange) => { - state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change) + case 'FILE_STATUS': + return { + ...state, + fileStatusResult: action.payload, + staged: getFilesByStatus("staged", action.payload), + modified: getFilesByStatus("modified", action.payload), + untracked: getFilesByStatus("untracked", action.payload), + deleted: getFilesByStatus("deleted", action.payload), + allchangesnotstaged: allChangedButNotStagedFiles(action.payload) + } + + case 'FILE_STATUS_MERGE': + action.payload.map((fileStatusResult: fileStatusResult) => { + const file = state.fileStatusResult.find(stateFile => { + return stateFile.filename === fileStatusResult.filename }) - - return { - ...state, - commitChanges: [...state.commitChanges] - } - - case 'RESET_REMOTE_BRANCH_COMMITS': - if (state.remoteBranchCommits[action.payload.branch.name]) { - delete state.remoteBranchCommits[action.payload.branch.name] - } - return { - ...state, - remoteBranchCommits: { ...state.remoteBranchCommits } - } - - case 'SET_REMOTE_BRANCH_COMMITS': - if (state.remoteBranchCommits[action.payload.branch.name]) { - state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits) - } else { - state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits - } - return { - ...state, - remoteBranchCommits: { ...state.remoteBranchCommits } - } - - case 'SET_LOCAL_BRANCH_COMMITS': - - state.localBranchCommits[action.payload.branch.name] = action.payload.commits - return { - ...state, - localBranchCommits: { ...state.localBranchCommits } - } - - case 'SET_BRANCH_DIFFERENCES': - - state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference - - return { - ...state, - branchDifferences: { ...state.branchDifferences } - } - - case 'SET_GITHUB_USER': - return { - ...state, - gitHubUser: action.payload - } - - case 'SET_GITHUB_ACCESS_TOKEN': - return { - ...state, - gitHubAccessToken: action.payload - } - - case 'SET_SCOPES': - return { - ...state, - gitHubScopes: action.payload - } - - case 'SET_USER_EMAILS': - return { - ...state, - userEmails: action.payload - } - - case 'SET_DEFAULT_REMOTE': - return { - ...state, - defaultRemote: action.payload - } - - case 'SET_LOG': - if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) { - return { - ...state, - log: [...state.log] - } - } - return { - ...state, - log: [...state.log, action.payload] - } - - case 'CLEAR_LOG': - return { - ...state, - log: [] - } - - case 'SET_STORAGE': - return { - ...state, - storage: action.payload - } + if (file) { + file.status = fileStatusResult.status + file.statusNames = fileStatusResult.statusNames + } + }) + + return { + ...state, + staged: getFilesByStatus("staged", state.fileStatusResult), + modified: getFilesByStatus("modified", state.fileStatusResult), + untracked: getFilesByStatus("untracked", state.fileStatusResult), + deleted: getFilesByStatus("deleted", state.fileStatusResult), + allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult) + } + + case 'SET_COMMITS': + return { + ...state, + commits: action.payload, + localCommitCount: action.payload.length + } + + case 'SET_BRANCHES': + return { + ...state, + branches: action.payload + } + + case 'SET_CURRENT_BRANCH': + return { + ...state, + currentBranch: action.payload + } + + case 'SET_CURRENT_HEAD': + return { + ...state, + currentHead: action.payload + } + + case 'SET_CAN_USE_APP': + return { + ...state, + canUseApp: action.payload + } + case 'SET_REPO_NAME': + return { + ...state, + reponame: action.payload + } + case 'SET_LOADING': + return { + ...state, + loading: action.payload + } + + case 'SET_REPOS': + return { + ...state, + repositories: action.payload + } + + case 'SET_REMOTE_BRANCHES': + return { + ...state, + remoteBranches: action.payload + } + + case 'SET_CAN_COMMIT': + return { + ...state, + canCommit: action.payload + } + + case 'SET_REMOTES': + return { + ...state, + remotes: action.payload + } + + case 'SET_UPSTREAM': + return { + ...state, + upstream: action.payload + } + + case 'SET_COMMIT_CHANGES': + + action.payload.forEach((change: commitChange) => { + state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change) + }) + + return { + ...state, + commitChanges: [...state.commitChanges] + } + + case 'RESET_REMOTE_BRANCH_COMMITS': + if (state.remoteBranchCommits[action.payload.branch.name]) { + delete state.remoteBranchCommits[action.payload.branch.name] + } + return { + ...state, + remoteBranchCommits: { ...state.remoteBranchCommits } + } + + case 'SET_REMOTE_BRANCH_COMMITS': + if (state.remoteBranchCommits[action.payload.branch.name]) { + state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits) + } else { + state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits + } + return { + ...state, + remoteBranchCommits: { ...state.remoteBranchCommits } + } + + case 'SET_LOCAL_BRANCH_COMMITS': + + state.localBranchCommits[action.payload.branch.name] = action.payload.commits + return { + ...state, + localBranchCommits: { ...state.localBranchCommits } + } + + case 'SET_BRANCH_DIFFERENCES': + + state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference + + return { + ...state, + branchDifferences: { ...state.branchDifferences } + } + + case 'SET_GITHUB_USER': + return { + ...state, + gitHubUser: action.payload + } + + case 'SET_GITHUB_ACCESS_TOKEN': + return { + ...state, + gitHubAccessToken: action.payload + } + + case 'SET_SCOPES': + return { + ...state, + gitHubScopes: action.payload + } + + case 'SET_USER_EMAILS': + return { + ...state, + userEmails: action.payload + } + + case 'SET_DEFAULT_REMOTE': + return { + ...state, + defaultRemote: action.payload + } + + case 'SET_LOG': + if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) { + return { + ...state, + log: [...state.log] + } + } + return { + ...state, + log: [...state.log, action.payload] + } + + case 'CLEAR_LOG': + return { + ...state, + log: [] + } + + case 'SET_STORAGE': + return { + ...state, + storage: action.payload + } } -} \ No newline at end of file +} From d4566f5fbd2c36b49c738bba667b272820297920 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 5 Jul 2024 14:51:06 +0100 Subject: [PATCH 21/21] fix lint errors --- libs/remix-ui/git/src/lib/listeners.ts | 4 +--- .../plugin-manager/src/lib/reducers/pluginManagerReducer.ts | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/git/src/lib/listeners.ts b/libs/remix-ui/git/src/lib/listeners.ts index 88fd8c2a85..ddb436554d 100644 --- a/libs/remix-ui/git/src/lib/listeners.ts +++ b/libs/remix-ui/git/src/lib/listeners.ts @@ -237,14 +237,12 @@ const calculateLocalStorage = async () => { enabled: true } setStorage(storage); - + }); } else { console.log('Storage API not supported in this browser.'); setStorage(storage); } - - } diff --git a/libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts b/libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts index 6b701652ee..7b99b8f3db 100644 --- a/libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts +++ b/libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ export type localPluginReducerActionType = { type: 'show' | 'close',