Merge branch 'main' into FEAT_BoltDYI_NEW_SETTINGS_UI_V2

This commit is contained in:
Stijnus
2025-01-28 10:38:06 +01:00
committed by GitHub
24 changed files with 436 additions and 161 deletions

View File

@@ -18,6 +18,7 @@ import { EditorPanel } from './EditorPanel';
import { Preview } from './Preview';
import useViewport from '~/lib/hooks';
import Cookies from 'js-cookie';
import { chatMetadata, useChatHistory } from '~/lib/persistence';
interface WorkspaceProps {
chatStarted?: boolean;
@@ -66,6 +67,8 @@ export const Workbench = memo(({ chatStarted, isStreaming }: WorkspaceProps) =>
const unsavedFiles = useStore(workbenchStore.unsavedFiles);
const files = useStore(workbenchStore.files);
const selectedView = useStore(workbenchStore.currentView);
const metadata = useStore(chatMetadata);
const { updateChatMestaData } = useChatHistory();
const isSmallViewport = useViewport(1024);
@@ -171,18 +174,28 @@ export const Workbench = memo(({ chatStarted, isStreaming }: WorkspaceProps) =>
<PanelHeaderButton
className="mr-1 text-sm"
onClick={() => {
const repoName = prompt(
'Please enter a name for your new GitHub repository:',
'bolt-generated-project',
);
let repoName = metadata?.gitUrl?.split('/').slice(-1)[0]?.replace('.git', '') || null;
let repoConfirmed: boolean = true;
if (repoName) {
repoConfirmed = confirm(`Do you want to push to the repository ${repoName}?`);
}
if (!repoName || !repoConfirmed) {
repoName = prompt(
'Please enter a name for your new GitHub repository:',
'bolt-generated-project',
);
} else {
}
if (!repoName) {
alert('Repository name is required. Push to GitHub cancelled.');
return;
}
const githubUsername = Cookies.get('githubUsername');
const githubToken = Cookies.get('githubToken');
let githubUsername = Cookies.get('githubUsername');
let githubToken = Cookies.get('githubToken');
if (!githubUsername || !githubToken) {
const usernameInput = prompt('Please enter your GitHub username:');
@@ -193,9 +206,26 @@ export const Workbench = memo(({ chatStarted, isStreaming }: WorkspaceProps) =>
return;
}
workbenchStore.pushToGitHub(repoName, usernameInput, tokenInput);
} else {
workbenchStore.pushToGitHub(repoName, githubUsername, githubToken);
githubUsername = usernameInput;
githubToken = tokenInput;
Cookies.set('githubUsername', usernameInput);
Cookies.set('githubToken', tokenInput);
Cookies.set(
'git:github.com',
JSON.stringify({ username: tokenInput, password: 'x-oauth-basic' }),
);
}
const commitMessage =
prompt('Please enter a commit message:', 'Initial commit') || 'Initial commit';
workbenchStore.pushToGitHub(repoName, commitMessage, githubUsername, githubToken);
if (!metadata?.gitUrl) {
updateChatMestaData({
...(metadata || {}),
gitUrl: `https://github.com/${githubUsername}/${repoName}.git`,
});
}
}}
>