-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(github): add tag pattern filtering for deployments #3726
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
Open
Alm0stEthical
wants to merge
4
commits into
Dokploy:canary
Choose a base branch
from
Alm0stEthical:feat/tag-pattern-filtering
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7,634
−9
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9063840
feat(github): add tag pattern filtering for deployments
AHTOOOXA 58bd01d
refactor(github): extract TagPatternsField to shared component and ad…
AHTOOOXA aa1ee97
[autofix.ci] apply automated fixes
autofix-ci[bot] be9d90a
Trim tag input, track deploy counts, fix auth
Alm0stEthical 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
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
170 changes: 170 additions & 0 deletions
170
apps/dokploy/components/dashboard/shared/tag-patterns-field.tsx
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,170 @@ | ||
| import { HelpCircle, X } from "lucide-react"; | ||
| import { useState } from "react"; | ||
| import { Badge } from "@/components/ui/badge"; | ||
| import { | ||
| Command, | ||
| CommandEmpty, | ||
| CommandGroup, | ||
| CommandInput, | ||
| CommandItem, | ||
| } from "@/components/ui/command"; | ||
| import { | ||
| FormControl, | ||
| FormItem, | ||
| FormLabel, | ||
| FormMessage, | ||
| } from "@/components/ui/form"; | ||
| import { | ||
| Popover, | ||
| PopoverContent, | ||
| PopoverTrigger, | ||
| } from "@/components/ui/popover"; | ||
| import { ScrollArea } from "@/components/ui/scroll-area"; | ||
| import { | ||
| Tooltip, | ||
| TooltipContent, | ||
| TooltipProvider, | ||
| TooltipTrigger, | ||
| } from "@/components/ui/tooltip"; | ||
|
|
||
| interface TagPatternsFieldProps { | ||
| value: string[] | undefined; | ||
| onChange: (value: string[]) => void; | ||
| tags: { name: string }[] | undefined; | ||
| isLoadingTags: boolean; | ||
| } | ||
|
|
||
| export const TagPatternsField = ({ | ||
| value, | ||
| onChange, | ||
| tags, | ||
| isLoadingTags, | ||
| }: TagPatternsFieldProps) => { | ||
| const [open, setOpen] = useState(false); | ||
| const [inputValue, setInputValue] = useState(""); | ||
|
|
||
| const selectedValues = value || []; | ||
| const availableTags = tags?.map((t) => t.name) || []; | ||
|
|
||
| const handleSelect = (tagValue: string) => { | ||
| if (!selectedValues.includes(tagValue)) { | ||
| onChange([...selectedValues, tagValue]); | ||
| } | ||
| setInputValue(""); | ||
| }; | ||
|
|
||
| const handleRemove = (tagValue: string) => { | ||
| onChange(selectedValues.filter((v) => v !== tagValue)); | ||
| }; | ||
|
|
||
| const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => { | ||
| if (e.key === "Enter" && inputValue.trim()) { | ||
| e.preventDefault(); | ||
| handleSelect(inputValue.trim()); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <FormItem className="md:col-span-2"> | ||
| <div className="flex items-center gap-2"> | ||
| <FormLabel>Tag Patterns</FormLabel> | ||
| <TooltipProvider delayDuration={0}> | ||
| <Tooltip> | ||
| <TooltipTrigger type="button"> | ||
| <HelpCircle className="size-4 text-muted-foreground hover:text-foreground transition-colors cursor-pointer" /> | ||
| </TooltipTrigger> | ||
| <TooltipContent className="max-w-xs"> | ||
| <p> | ||
| Select existing tags or type glob patterns (e.g., v*, release-*, | ||
| v[0-9].*). Leave empty to deploy on any tag. | ||
| </p> | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| </TooltipProvider> | ||
| </div> | ||
|
|
||
| <Popover open={open} onOpenChange={setOpen}> | ||
| <PopoverTrigger asChild> | ||
| <FormControl> | ||
| <div className="flex min-h-10 w-full flex-wrap gap-1 rounded-md border border-input bg-input px-3 py-2 text-sm ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 cursor-pointer"> | ||
| {selectedValues.length > 0 ? ( | ||
| selectedValues.map((tagValue) => ( | ||
| <Badge | ||
| key={tagValue} | ||
| variant="secondary" | ||
| className="flex items-center gap-1" | ||
| > | ||
| {tagValue} | ||
| <X | ||
| className="size-3 cursor-pointer hover:text-destructive" | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| handleRemove(tagValue); | ||
| }} | ||
| /> | ||
| </Badge> | ||
| )) | ||
| ) : ( | ||
| <span className="text-muted-foreground"> | ||
| {isLoadingTags | ||
| ? "Loading tags..." | ||
| : "Select tags or type patterns (empty = any tag)"} | ||
| </span> | ||
| )} | ||
| </div> | ||
| </FormControl> | ||
| </PopoverTrigger> | ||
| <PopoverContent className="w-[400px] p-0" align="start"> | ||
| <Command> | ||
| <CommandInput | ||
| placeholder="Search tags or type a pattern..." | ||
| value={inputValue} | ||
| onValueChange={setInputValue} | ||
| onKeyDown={handleKeyDown} | ||
| /> | ||
| <CommandEmpty> | ||
| {inputValue ? ( | ||
| <button | ||
| type="button" | ||
| className="w-full px-2 py-1.5 text-left text-sm hover:bg-accent" | ||
| onClick={() => { | ||
| const trimmedInputValue = inputValue.trim(); | ||
| if (trimmedInputValue) { | ||
| handleSelect(trimmedInputValue); | ||
| } | ||
| }} | ||
| > | ||
| Add pattern: "{inputValue}" | ||
| </button> | ||
| ) : ( | ||
| "No tags found. Type a pattern and press Enter." | ||
| )} | ||
| </CommandEmpty> | ||
| <ScrollArea className="h-64"> | ||
| <CommandGroup> | ||
| {availableTags | ||
| .filter((tag) => !selectedValues.includes(tag)) | ||
| .map((tag) => ( | ||
| <CommandItem | ||
| key={tag} | ||
| value={tag} | ||
| onSelect={() => handleSelect(tag)} | ||
| > | ||
| {tag} | ||
| </CommandItem> | ||
| ))} | ||
| </CommandGroup> | ||
| </ScrollArea> | ||
| </Command> | ||
| </PopoverContent> | ||
| </Popover> | ||
|
|
||
| {selectedValues.length === 0 && ( | ||
| <p className="text-xs text-muted-foreground"> | ||
| No patterns configured - will deploy on any tag | ||
| </p> | ||
| )} | ||
| <FormMessage /> | ||
| </FormItem> | ||
| ); | ||
| }; | ||
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,2 @@ | ||||||||
| ALTER TABLE "application" ADD COLUMN "tagPatterns" text[] DEFAULT '{}';--> statement-breakpoint | ||||||||
| ALTER TABLE "compose" ADD COLUMN "tagPatterns" text[] DEFAULT '{}'; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing newline at end of file
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleKeyDownreferencesReact.KeyboardEvent, but this file doesn’t import theReactnamespace. With the automatic JSX runtime,Reactisn’t in scope, so this will fail type-checking. Import the needed type fromreact(e.g.,KeyboardEvent) or add aimport type React from "react"and use that consistently.