diff --git a/web/src/components/BranchProtection/BranchProtectionForm/ProtectionRulesForm/ProtectionRulesForm.tsx b/web/src/components/BranchProtection/BranchProtectionForm/ProtectionRulesForm/ProtectionRulesForm.tsx index 2d5f7b0d0..e9fe07b24 100644 --- a/web/src/components/BranchProtection/BranchProtectionForm/ProtectionRulesForm/ProtectionRulesForm.tsx +++ b/web/src/components/BranchProtection/BranchProtectionForm/ProtectionRulesForm/ProtectionRulesForm.tsx @@ -66,7 +66,7 @@ const ProtectionRulesForm = (props: { name={'blockBranchDeletion'} /> - {getString('branchProtection.blockBranchCreationText')} + {getString('branchProtection.blockBranchDeletionText')}
{ enableReplyPlaceHolder?: boolean repoMetadata: TypesRepository | undefined standalone: boolean + routingId: string } export const CommentBox = ({ @@ -130,7 +131,8 @@ export const CommentBox = ({ autoFocusAndPosition, enableReplyPlaceHolder, repoMetadata, - standalone + standalone, + routingId }: CommentBoxProps) => { const { getString } = useStrings() const [comments, setComments] = useState[]>(commentItems) @@ -246,6 +248,7 @@ export const CommentBox = ({ ({ repoMetadata }: CommentsThreadProps) => { const { getString } = useStrings() - const { standalone } = useAppContext() + const { standalone, routingId } = useAppContext() const [editIndexes, setEditIndexes] = useState>({}) const resetStateAtIndex = useCallback( (index: number) => { @@ -429,6 +432,7 @@ const CommentsThread = ({ = ({ commitRange, scrollElement }) => { - const { routes } = useAppContext() + const { routes, routingId } = useAppContext() const { getString } = useStrings() const viewedPath = useMemo( () => `/api/v1/repos/${repoMetadata.path}/+/pullreq/${pullRequestMetadata?.number}/file-views`, @@ -228,6 +228,7 @@ export const DiffViewer: React.FC = ({ ReactDOM.render( { setUploading(true) - if (view.current && markdownContent) { + if (view.current && markdownContent && !inGitBlame) { const currentContent = view.current.state.doc.toString() const markdownInsert = `![image](${markdownContent})` // Create a transaction to update the document content @@ -200,7 +202,9 @@ export const Editor = React.memo(function CodeMirrorReactEditor({ } }, [filename, forMarkdown, view, languageConfig, markdownLanguageSupport]) const handleUploadCallback = (file: File) => { - handleUpload(file, setMarkdownContent, repoMetadata, showError, standalone) + if (!inGitBlame) { + handleUpload(file, setMarkdownContent, repoMetadata, showError, standalone, routingId) + } } // eslint-disable-next-line @typescript-eslint/no-explicit-any const handleDropForUpload = async (event: any) => { diff --git a/web/src/components/MarkdownEditorWithPreview/MarkdownEditorWithPreview.tsx b/web/src/components/MarkdownEditorWithPreview/MarkdownEditorWithPreview.tsx index c027f0191..5fe338116 100644 --- a/web/src/components/MarkdownEditorWithPreview/MarkdownEditorWithPreview.tsx +++ b/web/src/components/MarkdownEditorWithPreview/MarkdownEditorWithPreview.tsx @@ -96,6 +96,7 @@ interface MarkdownEditorWithPreviewProps { autoFocusAndPosition?: boolean repoMetadata: TypesRepository | undefined standalone: boolean + routingId: string } export function MarkdownEditorWithPreview({ @@ -114,11 +115,11 @@ export function MarkdownEditorWithPreview({ autoFocusAndPosition, secondarySaveButton: SecondarySaveButton, repoMetadata, - standalone + standalone, + routingId }: MarkdownEditorWithPreviewProps) { const { getString } = useStrings() const fileInputRef = useRef(null) - const [selectedTab, setSelectedTab] = useState(MarkdownEditorTab.WRITE) const viewRef = useRef() const containerRef = useRef(null) @@ -366,7 +367,7 @@ export function MarkdownEditorWithPreview({ variation={ButtonVariation.PRIMARY} disabled={false} onClick={() => { - handleUpload(file as File, setMarkdownContent, repoMetadata, showError, standalone) + handleUpload(file as File, setMarkdownContent, repoMetadata, showError, standalone, routingId) setOpen(false) setFile(undefined) }} @@ -420,6 +421,7 @@ export function MarkdownEditorWithPreview({ {getString('description')} { prChecksDecisionResult: PRChecksDecisionResult codeOwners?: TypesCodeOwnerEvaluation + standalone: boolean } enum CodeOwnerReqDecision { @@ -56,7 +57,8 @@ export function CodeOwnersOverview({ codeOwners, repoMetadata, pullRequestMetadata, - prChecksDecisionResult + prChecksDecisionResult, + standalone }: ChecksOverviewProps) { const { getString } = useStrings() const [isExpanded, toggleExpanded] = useToggle(false) @@ -100,7 +102,7 @@ export function CodeOwnersOverview({ const { borderColor, message, overallStatus } = checkEntries(changeReqEntries, waitingEntries, approvalEntries) return codeOwners?.evaluation_entries?.length ? ( diff --git a/web/src/pages/PullRequest/Conversation/Conversation.tsx b/web/src/pages/PullRequest/Conversation/Conversation.tsx index f813cda01..e60222c6c 100644 --- a/web/src/pages/PullRequest/Conversation/Conversation.tsx +++ b/web/src/pages/PullRequest/Conversation/Conversation.tsx @@ -51,6 +51,7 @@ export interface ConversationProps extends Pick void prChecksDecisionResult?: PRChecksDecisionResult standalone: boolean + routingId: string } export const Conversation: React.FC = ({ @@ -61,7 +62,8 @@ export const Conversation: React.FC = ({ showEditDescription, onCancelEditDescription, prChecksDecisionResult, - standalone + standalone, + routingId }) => { const { getString } = useStrings() const { currentUser } = useAppContext() @@ -187,6 +189,7 @@ export const Conversation: React.FC = ({ const newCommentBox = useMemo(() => { return ( = ({ } title={ = ({ )} {codeOwners && prChecksDecisionResult && ( = ({ {(hasDescription || showEditDescription) && ( = ({ pullRequestMetadata, onCommentUpdate: refreshPullRequestMetadata, onCancelEditDescription, - standalone + standalone, + routingId }) => { const [edit, setEdit] = useState(false) const [dirty, setDirty] = useState(false) @@ -64,6 +65,7 @@ export const DescriptionBox: React.FC = ({ {(edit && ( void, repoMetadata: TypesRepository | undefined, showError: (message: React.ReactNode, timeout?: number | undefined, key?: string | undefined) => void, - standalone: boolean + standalone: boolean, + routingId?: string ) => { const reader = new FileReader() // Set up a function to be called when the load event is triggered reader.onload = async function () { - const markdown = await uploadImage(reader.result, showError, repoMetadata, standalone) + const markdown = await uploadImage(reader.result, showError, repoMetadata, standalone, routingId) setMarkdownContent(markdown) // Set the markdown content } reader.readAsArrayBuffer(blob) // This will trigger the onload function when the reading is complete @@ -267,11 +269,14 @@ export const uploadImage = async ( fileBlob: any, showError: (message: React.ReactNode, timeout?: number | undefined, key?: string | undefined) => void, repoMetadata: TypesRepository | undefined, - standalone: boolean + standalone: boolean, + routingId?: string ) => { try { const response = await fetch( - `${window.location.origin}/${standalone ? '' : 'code/'}api/v1/repos/${repoMetadata?.path}/+/uploads/`, + `${window.location.origin}${getConfig( + `code/api/v1/repos/${repoMetadata?.path}/+/uploads${standalone || !routingId ? `` : `?routingId=${routingId}`}` + )}`, { method: 'POST', headers: {