Repository navigation
(size/L)feat:Added the option for bruno version edit in the collection overview #8424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bijin-bruno
merged 6 commits into
usebruno:main
from
sachin-bruno:sachin-bruno/feature-collection-version-edit
Jul 3, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
146 changes: 146 additions & 0 deletions
146
...pp/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/StyledWrapper.js
This file contains hidden or 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,146 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const ModalTitle = styled.div` | ||
| color: ${(props) => props.theme.colors.text.subtext2}; | ||
| font-weight: 600; | ||
| font-size: ${(props) => props.theme.font.size.base}; | ||
| line-height: 18px; | ||
| `; | ||
|
|
||
| const StyledWrapper = styled.div` | ||
| max-width: 100%; | ||
| .subheader { | ||
| margin-bottom: 0.5rem; | ||
| color: ${(props) => props.theme.colors.text.muted}; | ||
| font-weight: 400; | ||
| font-size: ${(props) => props.theme.font.size.base}; | ||
| line-height: 18px; | ||
|
|
||
| .collection-name { | ||
| color: ${(props) => props.theme.text}; | ||
| font-weight: 600; | ||
| } | ||
| } | ||
|
|
||
| .version-card { | ||
| width: 100%; | ||
| border: 1px solid ${(props) => props.theme.border.border1}; | ||
| border-radius: ${(props) => props.theme.border.radius.md}; | ||
| overflow: hidden; | ||
|
|
||
| .version-row { | ||
| display: flex; | ||
| align-items: flex-start; | ||
| gap: 1rem; | ||
| padding: 1rem; | ||
| } | ||
|
|
||
| .version-col { | ||
| flex: 1; | ||
| min-width: 0; | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 0.5rem; | ||
| } | ||
|
|
||
| .col-label { | ||
| color: ${(props) => props.theme.text}; | ||
| font-weight: 500; | ||
| font-size: ${(props) => props.theme.font.size.base}; | ||
| line-height: 20px; | ||
| } | ||
|
|
||
| .current-value { | ||
| color: ${(props) => props.theme.text}; | ||
| font-weight: 400; | ||
| font-size: ${(props) => props.theme.font.size.sm}; | ||
| line-height: 20px; | ||
| overflow-wrap: anywhere; | ||
|
|
||
| .unset { | ||
| font-family: inherit; | ||
| font-style: italic; | ||
| } | ||
| } | ||
|
|
||
| .arrow { | ||
| align-self: center; | ||
| color: ${(props) => props.theme.colors.text.muted}; | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .input-wrap { | ||
| position: relative; | ||
|
|
||
| .textbox { | ||
| padding-right: 2.25rem; | ||
| color: ${(props) => props.theme.text}; | ||
| font-weight: 400; | ||
| font-size: ${(props) => props.theme.font.size.sm}; | ||
| line-height: 20px; | ||
| } | ||
|
|
||
| .copy-btn { | ||
| position: absolute; | ||
| top: 50%; | ||
| right: 0.5rem; | ||
| transform: translateY(-50%); | ||
| display: inline-flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| padding: 0.25rem; | ||
| background: transparent; | ||
| border: none; | ||
| cursor: pointer; | ||
| color: ${(props) => props.theme.colors.text.muted}; | ||
|
|
||
| &:hover:not(:disabled) { | ||
| color: ${(props) => props.theme.text}; | ||
| } | ||
|
|
||
| &:disabled { | ||
| opacity: 0.5; | ||
| cursor: default; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .preview { | ||
| display: flex; | ||
| align-items: center; | ||
| flex-wrap: wrap; | ||
| gap: 0.25rem; | ||
| padding: 0.625rem 1rem; | ||
| border-top: 1px solid ${(props) => props.theme.border.border1}; | ||
| background-color: ${(props) => props.theme.background.mantle}; | ||
| color: ${(props) => props.theme.text}; | ||
| font-weight: 400; | ||
| font-size: ${(props) => props.theme.font.size.sm}; | ||
| line-height: 20px; | ||
|
|
||
| strong { | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| .old { | ||
| color: ${(props) => props.theme.colors.text.danger}; | ||
| font-weight: 700; | ||
| word-break: break-all; | ||
| } | ||
|
|
||
| .new { | ||
| font-family: monospace; | ||
| color: ${(props) => props.theme.colors.text.green}; | ||
| font-weight: 700; | ||
| word-break: break-all; | ||
| } | ||
|
|
||
| .preview-arrow { | ||
| color: ${(props) => props.theme.colors.text.muted}; | ||
| flex-shrink: 0; | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| export default StyledWrapper; |
143 changes: 143 additions & 0 deletions
143
.../bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/index.js
|
bijin-bruno marked this conversation as resolved.
Resolved
|
This file contains hidden or 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,143 @@ | ||
| import React, { useEffect, useMemo, useRef, useState } from 'react'; | ||
| import { useDispatch, useSelector } from 'react-redux'; | ||
| import { IconArrowRight, IconCopy, IconCheck, IconAlertTriangle } from '@tabler/icons'; | ||
|
|
||
| import Modal from 'components/Modal'; | ||
| import Portal from 'components/Portal'; | ||
| import { findCollectionByUid, getCollectionVersion, isOpenCollectionFormat } from 'utils/collections/index'; | ||
| import { saveCollectionVersion } from 'providers/ReduxStore/slices/collections/actions'; | ||
| import StyledWrapper, { ModalTitle } from './StyledWrapper'; | ||
|
|
||
| const CollectionNotFound = ({ onClose }) => ( | ||
| <Portal> | ||
| <Modal size="sm" title="Change Collection Version" confirmText="Close" handleConfirm={onClose} hideCancel> | ||
| <StyledWrapper className="w-[480px]"> | ||
| <div className="flex items-center gap-2 text-warning"> | ||
| <IconAlertTriangle size={16} className="shrink-0" /> | ||
| <span>Collection not found. It may have been deleted or is no longer available.</span> | ||
| </div> | ||
| </StyledWrapper> | ||
| </Modal> | ||
| </Portal> | ||
| ); | ||
|
|
||
| const ChangeCollectionVersion = ({ collectionUid, onClose }) => { | ||
| const dispatch = useDispatch(); | ||
| const inputRef = useRef(null); | ||
| const collection = useSelector((state) => findCollectionByUid(state.collections.collections, collectionUid)); | ||
|
|
||
| const currentVersion = getCollectionVersion(collection); | ||
| const isYml = isOpenCollectionFormat(collection); | ||
| const targetKey = isYml ? 'info.version' : 'collectionVersion'; | ||
| const targetFile = isYml ? 'opencollection.yml' : 'bruno.json'; | ||
| const [newVersion, setNewVersion] = useState(currentVersion); | ||
| const [isSaving, setIsSaving] = useState(false); | ||
| const [copied, setCopied] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (inputRef.current) { | ||
| inputRef.current.focus(); | ||
| inputRef.current.select(); | ||
| } | ||
| }, []); | ||
|
|
||
| const trimmedVersion = newVersion.trim(); | ||
| const canSubmit = useMemo( | ||
| () => trimmedVersion.length > 0 && trimmedVersion !== currentVersion, | ||
| [trimmedVersion, currentVersion] | ||
| ); | ||
|
|
||
| const handleConfirm = () => { | ||
| if (!canSubmit || isSaving) return; | ||
| setIsSaving(true); | ||
| dispatch(saveCollectionVersion(collectionUid, trimmedVersion)) | ||
| .then(() => onClose()) | ||
| .catch(() => setIsSaving(false)); | ||
|
sachin-bruno marked this conversation as resolved.
Resolved
|
||
| }; | ||
|
|
||
| const handleCopy = () => { | ||
| if (!trimmedVersion || !navigator.clipboard) return; | ||
| navigator.clipboard.writeText(trimmedVersion) | ||
| .then(() => { | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 1500); | ||
| }).catch(() => {}); | ||
| }; | ||
|
|
||
| if (!collection) { | ||
| return <CollectionNotFound onClose={onClose} />; | ||
| } | ||
|
|
||
| return ( | ||
| <Portal> | ||
| <Modal | ||
| size="md" | ||
| customHeader={<ModalTitle>Change Collection Version</ModalTitle>} | ||
| confirmText={isSaving ? 'Updating...' : 'Update Version'} | ||
| cancelText="Cancel" | ||
| handleConfirm={handleConfirm} | ||
| handleCancel={onClose} | ||
| confirmDisabled={!canSubmit || isSaving} | ||
| dataTestId="change-version" | ||
| > | ||
| <StyledWrapper className="w-[560px]"> | ||
| <div className="subheader" data-testid="change-version-collection"> | ||
| Collection: <span className="collection-name">{collection.name}</span> | ||
| </div> | ||
|
|
||
| <div className="version-card"> | ||
| <div className="version-row"> | ||
| <div className="version-col"> | ||
| <div className="col-label">Current Version</div> | ||
| <div className="current-value" data-testid="change-version-current"> | ||
| {currentVersion || <span className="unset">Not Set</span>} | ||
| </div> | ||
| </div> | ||
|
|
||
| <IconArrowRight size={18} className="arrow" stroke={1.5} /> | ||
|
|
||
| <div className="version-col"> | ||
| <div className="col-label">New Version</div> | ||
| <div className="input-wrap"> | ||
| <input | ||
| ref={inputRef} | ||
| type="text" | ||
| className="textbox w-full" | ||
| autoComplete="off" | ||
| autoCorrect="off" | ||
| autoCapitalize="off" | ||
| spellCheck="false" | ||
| placeholder="e.g. v1.0.0" | ||
| maxLength={50} | ||
| value={newVersion} | ||
| onChange={(e) => setNewVersion(e.target.value)} | ||
| data-testid="change-version-input" | ||
| /> | ||
| <button | ||
| type="button" | ||
| className="copy-btn" | ||
| aria-label={copied ? 'Copied' : 'Copy version'} | ||
| onClick={handleCopy} | ||
| disabled={!trimmedVersion} | ||
| data-testid="change-version-copy" | ||
| > | ||
| {copied ? <IconCheck size={15} stroke={1.5} /> : <IconCopy size={15} stroke={1.5} />} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <p className="preview m-0" data-testid="change-version-preview"> | ||
| Updates <strong>{targetKey}</strong> in {targetFile} from{' '} | ||
| <span className="old">{currentVersion || '(none)'}</span> | ||
| <IconArrowRight size={13} className="preview-arrow" stroke={1.5} /> | ||
| <span className="new">{trimmedVersion || '…'}</span> | ||
| </p> | ||
| </div> | ||
| </StyledWrapper> | ||
| </Modal> | ||
| </Portal> | ||
| ); | ||
| }; | ||
|
|
||
| export default ChangeCollectionVersion; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.