-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from alirezamirian/2023-12
2023-12
- Loading branch information
Showing
42 changed files
with
1,873 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
|
||
// Redeclare forwardRef to fix the generic type removal problem. | ||
// See more: https://fettblog.eu/typescript-react-generic-forward-refs/#option-3%3A-augment-forwardref | ||
declare module "react" { | ||
function forwardRef<T, P = {}>( | ||
render: (props: P, ref: React.Ref<T>) => React.ReactElement | null | ||
): (props: P & React.RefAttributes<T>) => React.ReactElement | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
ActionTooltip, | ||
PlatformIcon, | ||
StatusBarWidget, | ||
TooltipTrigger, | ||
} from "@intellij-platform/core"; | ||
import React from "react"; | ||
|
||
import { activeFileRepoHeadState } from "../VersionControl/active-file.state"; | ||
import { useLatestRecoilValue } from "../recoil-utils"; | ||
|
||
export function BranchPopupTrigger() { | ||
const gitRepoHead = useLatestRecoilValue(activeFileRepoHeadState); | ||
|
||
return ( | ||
gitRepoHead && ( | ||
<TooltipTrigger | ||
tooltip={ | ||
<ActionTooltip | ||
actionName={ | ||
gitRepoHead.detached | ||
? "Git: Detached HEAD doesn't point to any branch" | ||
: `Git Branch: ${gitRepoHead.head}` | ||
} | ||
/> | ||
} | ||
> | ||
<StatusBarWidget | ||
icon={ | ||
<PlatformIcon | ||
icon={ | ||
gitRepoHead.detached ? "general/warning.svg" : "vcs/branch.svg" | ||
} | ||
/> | ||
} | ||
label={gitRepoHead.head.slice( | ||
0, | ||
gitRepoHead.detached ? 8 : undefined | ||
)} | ||
/> | ||
</TooltipTrigger> | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { atom } from "recoil"; | ||
import { Bounds } from "@intellij-platform/core"; | ||
|
||
export const showProgressPanelState = atom({ | ||
key: "ide.statusbar.showProgressPanel", | ||
default: false, | ||
}); | ||
export const tasksPopupBoundsState = atom<Bounds | null>({ | ||
key: "ide.statusbar.tasksPopup", | ||
default: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
packages/example-app/src/StatusBar/StatusBarTaskProgressBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import styled from "styled-components"; | ||
import { | ||
BareButton, | ||
Link, | ||
ProgressBar, | ||
ProgressBarProps, | ||
ProgressBarStopButton, | ||
Tooltip, | ||
TooltipTrigger, | ||
} from "@intellij-platform/core"; | ||
import { useRecoilState, useRecoilValue } from "recoil"; | ||
import { firstTaskState, taskCountState, useCancelTask } from "../tasks"; | ||
import { showProgressPanelState } from "./IdeStatusBar.state"; | ||
import React, { useEffect } from "react"; | ||
import { TasksPopup } from "./TasksPopup"; | ||
|
||
function StatusBarProgress( | ||
props: Omit<ProgressBarProps, "dense" | "namePosition" | "width"> | ||
) { | ||
return <ProgressBar dense namePosition="side" width={146} {...props} />; | ||
} | ||
|
||
const Spacer = styled.span` | ||
width: 0.5rem; | ||
`; | ||
const StyledProgressBarButton = styled.span` | ||
cursor: pointer; | ||
${ProgressBar.Container} { | ||
cursor: unset; | ||
} | ||
`; | ||
/** | ||
* Intentionally, "processes" haven't been abstracted as an extension point for different features, since the focus | ||
* here is not to create an IDE, but to demo UI components. | ||
*/ | ||
export const StatusBarTaskProgressBar = () => { | ||
const firstTask = useRecoilValue(firstTaskState); | ||
const tasksCount = useRecoilValue(taskCountState); | ||
const cancel = useCancelTask(); | ||
const [showProgressPanel, setShowProgressPanel] = useRecoilState( | ||
showProgressPanelState | ||
); | ||
|
||
// When there is no tasks, switch back to not showing the panel. | ||
useEffect(() => { | ||
if (tasksCount === 0) { | ||
setShowProgressPanel(false); | ||
} | ||
}, [tasksCount]); | ||
|
||
return ( | ||
<> | ||
{firstTask && !showProgressPanel && ( | ||
<TooltipTrigger | ||
tooltip={ | ||
<Tooltip>{`${firstTask.title}. Click to see all running background tasks.`}</Tooltip> | ||
} | ||
> | ||
<BareButton | ||
preventFocusOnPress | ||
onPress={() => { | ||
setShowProgressPanel(true); | ||
}} | ||
> | ||
<StyledProgressBarButton> | ||
<StatusBarProgress | ||
name={firstTask.progress.text || firstTask.title} | ||
isIndeterminate={firstTask.progress.isIndeterminate} | ||
value={firstTask.progress.fraction} | ||
maxValue={1} | ||
button={ | ||
<> | ||
{/* {task.canPause && ( | ||
<ProgressBarPauseButton | ||
small | ||
paused={false} | ||
onPausedChange={() => {}} | ||
/> | ||
)}*/} | ||
{firstTask.isCancelable && ( | ||
<TooltipTrigger tooltip={<Tooltip>Cancel</Tooltip>}> | ||
<ProgressBarStopButton | ||
small | ||
onPress={() => cancel(firstTask.id)} | ||
/> | ||
</TooltipTrigger> | ||
)} | ||
</> | ||
} | ||
/> | ||
</StyledProgressBarButton> | ||
</BareButton> | ||
</TooltipTrigger> | ||
)} | ||
{(tasksCount > 1 || showProgressPanel) && ( | ||
<> | ||
<Spacer /> | ||
<Link | ||
onPress={() => | ||
setShowProgressPanel((currentValue) => !currentValue) | ||
} | ||
> | ||
{showProgressPanel ? "Hide processes" : "Show all"} ({tasksCount}) | ||
</Link> | ||
</> | ||
)} | ||
{showProgressPanel && tasksCount > 0 && <TasksPopup />} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.