Skip to content

Commit

Permalink
fix(ui): use path param as main reference for selected pipeline (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
erka and kodiakhq[bot] authored Nov 24, 2024
1 parent 33252a0 commit 7d9a380
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ui/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export function Sidebar() {
const navigate = useNavigate();
const { pipelineId } = useParams();
const [open, setOpen] = useState(false);
const [value, setValue] = useState(pipelineId);
const { data: pipelinesData, isLoading } = useListPipelinesQuery();

return (
Expand Down Expand Up @@ -58,9 +57,9 @@ export function Sidebar() {
>
{isLoading
? 'Loading pipelines...'
: value
: pipelineId
? pipelinesData?.pipelines?.find(
(pipeline: Pipeline) => pipeline.name === value
(pipeline: Pipeline) => pipeline.name === pipelineId
)?.name
: 'Select pipeline...'}
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
Expand All @@ -79,7 +78,6 @@ export function Sidebar() {
key={pipeline.name}
value={pipeline.name}
onSelect={(currentValue: string) => {
setValue(currentValue === value ? '' : currentValue);
setOpen(false);
navigate(`/pipelines/${currentValue}`);
}}
Expand All @@ -88,7 +86,7 @@ export function Sidebar() {
<Check
className={cn(
'mr-2 h-4 w-4',
value === pipeline.name ? 'opacity-100' : 'opacity-0'
pipelineId === pipeline.name ? 'opacity-100' : 'opacity-0'
)}
/>
{pipeline.name}
Expand Down

0 comments on commit 7d9a380

Please sign in to comment.