update free uses gui
This commit is contained in:
parent
9837670030
commit
0632154be8
5 changed files with 106 additions and 136 deletions
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.212",
|
||||
"version": "0.9.213",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.212",
|
||||
"version": "0.9.213",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
EllipsisHorizontalCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial";
|
||||
import ProgressBar from "./loaders/ProgressBar";
|
||||
import FreeTrialProgressBar from "./loaders/FreeTrialProgressBar";
|
||||
import ProfileSwitcher from "./ProfileSwitcher";
|
||||
import ButtonWithTooltip from "./ButtonWithTooltip";
|
||||
import { useSelector } from "react-redux";
|
||||
|
|
@ -42,9 +42,9 @@ function Footer() {
|
|||
|
||||
return (
|
||||
<footer className="flex justify-between items-center overflow-hidden p-2 h-7 border-0 border-t border-solid border-t-zinc-700">
|
||||
<div className="flex gap-2 max-w-[25vw]">
|
||||
<div className="flex gap-2 max-w-[40vw]">
|
||||
{defaultModel?.provider === "free-trial" ? (
|
||||
<ProgressBar
|
||||
<FreeTrialProgressBar
|
||||
completed={parseInt(localStorage.getItem("ftc") || "0")}
|
||||
total={FREE_TRIAL_LIMIT_REQUESTS}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const TooltipStyles = {
|
|||
backgroundColor: vscInputBackground,
|
||||
boxShadow: `0px 0px 2px 1px ${vscBadgeBackground}`,
|
||||
color: vscForeground,
|
||||
padding: "2px 6px",
|
||||
padding: "4px 8px",
|
||||
zIndex: 1000,
|
||||
maxWidth: "80vw",
|
||||
textAlign: "center",
|
||||
|
|
|
|||
100
gui/src/components/loaders/FreeTrialProgressBar.tsx
Normal file
100
gui/src/components/loaders/FreeTrialProgressBar.tsx
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
import { ExclamationCircleIcon } from "@heroicons/react/24/outline";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
|
||||
interface FreeTrialProgressBarProps {
|
||||
completed: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
function FreeTrialProgressBar({ completed, total }: FreeTrialProgressBarProps) {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const fillPercentage = Math.min(100, Math.max(0, (completed / total) * 100));
|
||||
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
function onClick() {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
navigate("/");
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (completed > total) {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="flex items-center gap-1 cursor-default"
|
||||
data-tooltip-id="usage_progress_bar"
|
||||
>
|
||||
<ExclamationCircleIcon width="18px" height="18px" color="red" />
|
||||
Trial limit reached
|
||||
</div>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<ToolTip id="usage_progress_bar" place="top">
|
||||
Configure a model above in order to continue
|
||||
</ToolTip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="flex flex-col cursor-pointer text-gray-400 text-[10px]"
|
||||
data-tooltip-id="usage_progress_bar"
|
||||
onClick={onClick}
|
||||
>
|
||||
<div className="hidden xs:flex justify-between mb-0">
|
||||
<span>
|
||||
Free trial <span className="hidden sm:inline">requests</span>
|
||||
</span>
|
||||
|
||||
<span>
|
||||
{completed} / {total}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="w-[40vw] h-1.5 rounded-md border border-gray-400 border-solid my-2 flex">
|
||||
<div
|
||||
className={`transition-all duration-200 ease-in-out h-full rounded-lg ${
|
||||
completed / total > 0.75 ? "bg-amber-500" : "bg-stone-500"
|
||||
}`}
|
||||
style={{
|
||||
width: `${fillPercentage}%`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<ToolTip id="usage_progress_bar" place="top">
|
||||
{`Click to use your own API key or local LLM (required after ${FREE_TRIAL_LIMIT_REQUESTS} inputs)`}
|
||||
</ToolTip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default FreeTrialProgressBar;
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
import { ExclamationCircleIcon } from "@heroicons/react/24/outline";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { lightGray, vscForeground } from "..";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { getFontSize } from "../../util";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
|
||||
const ProgressBarWrapper = styled.div`
|
||||
width: 100px;
|
||||
height: 6px;
|
||||
border-radius: 6px;
|
||||
border: 0.5px solid ${lightGray};
|
||||
margin-top: 6px;
|
||||
`;
|
||||
|
||||
const ProgressBarFill = styled.div<{ completed: number; color?: string }>`
|
||||
height: 100%;
|
||||
background-color: ${(props) => props.color || vscForeground};
|
||||
border-radius: inherit;
|
||||
transition: width 0.2s ease-in-out;
|
||||
width: ${(props) => props.completed}%;
|
||||
`;
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-rows: 1fr auto;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
const P = styled.p`
|
||||
margin: 0;
|
||||
margin-top: 2px;
|
||||
font-size: ${getFontSize() - 2.5}px;
|
||||
color: ${lightGray};
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
`;
|
||||
|
||||
interface ProgressBarProps {
|
||||
completed: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
const ProgressBar = ({ completed, total }: ProgressBarProps) => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const fillPercentage = Math.min(100, Math.max(0, (completed / total) * 100));
|
||||
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
if (completed > total) {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="flex items-center gap-1 cursor-default"
|
||||
data-tooltip-id="usage_progress_bar"
|
||||
>
|
||||
<ExclamationCircleIcon width="18px" height="18px" color="red" />
|
||||
Trial limit reached
|
||||
</div>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<ToolTip id="usage_progress_bar" place="top">
|
||||
Configure a model above in order to continue
|
||||
</ToolTip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<GridDiv
|
||||
data-tooltip-id="usage_progress_bar"
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
navigate("/");
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}}
|
||||
>
|
||||
<ProgressBarWrapper>
|
||||
<ProgressBarFill
|
||||
completed={fillPercentage}
|
||||
color={
|
||||
completed / total > 0.75
|
||||
? completed / total > 0.9
|
||||
? "#f00"
|
||||
: "#fc0"
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</ProgressBarWrapper>
|
||||
<P>
|
||||
Free Uses: {completed} / {total}
|
||||
</P>
|
||||
</GridDiv>
|
||||
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<ToolTip id="usage_progress_bar" place="top">
|
||||
{`Click to use your own API key or local LLM (required after ${FREE_TRIAL_LIMIT_REQUESTS} inputs)`}
|
||||
</ToolTip>,
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProgressBar;
|
||||
Loading…
Add table
Reference in a new issue