Skip to content

Commit

Permalink
feat: add PR raise
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Ellison committed Jan 3, 2024
1 parent d3eb35f commit 4d51339
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
1 change: 1 addition & 0 deletions components/appbar/ControlBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export function ControlBar({
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
params.set("branch", newBranch.name);
params.set("edit", "true");
url.search = params.toString();
window.location.href = url.toString();
}
Expand Down
32 changes: 25 additions & 7 deletions components/appbar/ControlBarComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import {
Stack,
Autocomplete,
Button,
Snackbar
Snackbar,
} from "@mui/material";
import PrintIcon from "@mui/icons-material/Print";
import SlideshowIcon from "@mui/icons-material/Slideshow";
import AddCircleIcon from "@mui/icons-material/AddCircle";
// import { useSelector, useDispatch } from 'react-redux'
// import { setBranch } from '@/lib/redux/reducers/branchSlice'
import ApprovalIcon from "@mui/icons-material/Approval";
import MuiAlert from '@mui/material/Alert';
import CircularProgress from '@mui/material/CircularProgress';
import MuiAlert from "@mui/material/Alert";
import CircularProgress from "@mui/material/CircularProgress";

export function ControlBarComponent({
open,
Expand Down Expand Up @@ -48,7 +48,8 @@ export function ControlBarComponent({
console.log("ControlBarComponent:collection: ", collection);
console.log("ControlBarComponent:editMode: ", editMode);
const [isLoading, setIsLoading] = useState(false);
const [showError, setShowError] = useState('');
const [showError, setShowError] = useState("");
const [showPRSuccess, setShowPRSuccess] = useState(false);

useEffect(() => {
if (context.branch != collection.branch) {
Expand Down Expand Up @@ -135,6 +136,7 @@ export function ControlBarComponent({
try {
// Replace this with your actual function
await handlePR();
setShowPRSuccess(true);
} catch (error) {
setShowError(error.message);
} finally {
Expand Down Expand Up @@ -228,7 +230,9 @@ export function ControlBarComponent({
</IconButton>
}
label=""
/>
/></>)}
{editMode && changeBranch && collection && (
<>
<Button
variant="outlined"
onClick={handlePRClick}
Expand All @@ -241,17 +245,31 @@ export function ControlBarComponent({
<Snackbar
open={showError}
autoHideDuration={6000}
onClose={() => setShowError('')}
onClose={() => setShowError("")}
>
<MuiAlert
onClose={() => setShowError('')}
onClose={() => setShowError("")}
severity="error"
elevation={6}
variant="filled"
>
An error occurred while processing your request: {showError}
</MuiAlert>
</Snackbar>
<Snackbar
open={showPRSuccess}
autoHideDuration={6000}
onClose={() => setShowPRSuccess(false)}
>
<MuiAlert
onClose={() => setShowPRSuccess(false)}
severity="success"
elevation={6}
variant="filled"
>
PR successfully created
</MuiAlert>
</Snackbar>
</>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions components/layouts/ContentPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export function ContentPage({
console.error("ContentPage:onSave:error: ", error);
throw new Error(`Error saving file: ${error.message}`);
}
handleContentChange(context.file);
// const currentState = store.getState();
// const reduxCollection = currentState.branch[collection];
// console.log("Editor:context: ", context);
Expand Down
2 changes: 1 addition & 1 deletion stories/AppBar.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TopBar } from '@/components/appbar';
import { TopBar } from '@/components/appbar/TopBar';

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
export default {
Expand Down
2 changes: 1 addition & 1 deletion stories/NewBranchDialog.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import Button from "@mui/material/Button";
import { NewBranchDialog } from "@/components/appbar";
import { NewBranchDialog } from "@/components/appbar/NewBranchDialog";
import { ControlBarComponent as ControlBar } from "@/components/appbar/ControlBarComponent";
import { toSnakeCase } from '@/lib/utils/stringUtils';
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
Expand Down
2 changes: 1 addition & 1 deletion stories/NewContentDialog.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import Button from "@mui/material/Button";
import { NewContentDialog } from "@/components/appbar";
import { NewContentDialog } from "@/components/appbar/NewContentDialog";
import { ControlBarComponent as ControlBar } from "@/components/appbar/ControlBarComponent";
import { toSnakeCase } from '@/lib/utils/stringUtils';
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
Expand Down

0 comments on commit 4d51339

Please sign in to comment.