-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccfce8d
commit 279b863
Showing
11 changed files
with
424 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,96 @@ | ||
package workloads | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/google/uuid" | ||
htmx "github.com/zeiss/fiber-htmx" | ||
"github.com/zeiss/fiber-htmx/components/buttons" | ||
"github.com/zeiss/fiber-htmx/components/forms" | ||
"github.com/zeiss/fiber-htmx/components/modals" | ||
"github.com/zeiss/service-lens/internal/utils" | ||
) | ||
|
||
// AddTagModalProps ... | ||
type AddTagModalProps struct { | ||
// WorkloadID ... | ||
WorkloadID uuid.UUID | ||
} | ||
|
||
// AddTagModal ... | ||
func AddTagModal(props AddTagModalProps) htmx.Node { | ||
return modals.Modal( | ||
modals.ModalProps{ | ||
ID: "add_tag_modal", | ||
}, | ||
htmx.FormElement( | ||
htmx.HxPost(fmt.Sprintf(utils.AddWorkloadTagUrlFormat, props.WorkloadID)), | ||
htmx.HxTrigger("submit"), | ||
htmx.HxOn("htmx:after-settle", "event.target.closest('dialog').close(), event.target.reset()"), | ||
htmx.HxSwap("none"), | ||
forms.FormControl( | ||
forms.FormControlProps{ | ||
ClassNames: htmx.ClassNames{}, | ||
}, | ||
forms.TextInputBordered( | ||
forms.TextInputProps{ | ||
Name: "name", | ||
Placeholder: "Provide tag name ...", | ||
}, | ||
htmx.AutoComplete("off"), | ||
), | ||
forms.FormControlLabel( | ||
forms.FormControlLabelProps{}, | ||
forms.FormControlLabelText( | ||
forms.FormControlLabelTextProps{ | ||
ClassNames: htmx.ClassNames{ | ||
"text-neutral-500": true, | ||
}, | ||
}, | ||
htmx.Text("Use a unique name to identify the tag that has between 3 and 255 characters."), | ||
), | ||
), | ||
), | ||
forms.FormControl( | ||
forms.FormControlProps{ | ||
ClassNames: htmx.ClassNames{}, | ||
}, | ||
forms.TextInputBordered( | ||
forms.TextInputProps{ | ||
Name: "value", | ||
Placeholder: "Provide a tag value ...", | ||
}, | ||
htmx.AutoComplete("off"), | ||
), | ||
forms.FormControlLabel( | ||
forms.FormControlLabelProps{}, | ||
forms.FormControlLabelText( | ||
forms.FormControlLabelTextProps{ | ||
ClassNames: htmx.ClassNames{ | ||
"text-neutral-500": true, | ||
}, | ||
}, | ||
htmx.Text("Use a unique value of the tag that has between 3 and 255 characters."), | ||
), | ||
), | ||
), | ||
modals.ModalAction( | ||
modals.ModalActionProps{}, | ||
buttons.Ghost( | ||
buttons.ButtonProps{ | ||
Type: "button", | ||
}, | ||
htmx.Text("Cancel"), | ||
htmx.Attribute("formnovalidate", ""), | ||
htmx.OnClick("event.target.closest('dialog').close()"), | ||
), | ||
buttons.Button( | ||
buttons.ButtonProps{ | ||
Type: "submit", | ||
}, | ||
htmx.Text("Create"), | ||
), | ||
), | ||
), | ||
) | ||
} |
This file contains 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,87 @@ | ||
package workloads | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/google/uuid" | ||
htmx "github.com/zeiss/fiber-htmx" | ||
"github.com/zeiss/fiber-htmx/components/buttons" | ||
"github.com/zeiss/fiber-htmx/components/forms" | ||
"github.com/zeiss/fiber-htmx/components/icons" | ||
"github.com/zeiss/fiber-htmx/components/tailwind" | ||
"github.com/zeiss/service-lens/internal/models" | ||
"github.com/zeiss/service-lens/internal/utils" | ||
) | ||
|
||
// WorkloadTagProps ... | ||
type WorkloadTagProps struct { | ||
ClassNames htmx.ClassNames | ||
WorkloadID uuid.UUID | ||
Tag models.Tag | ||
} | ||
|
||
// WorkloadTag ... | ||
func WorkloadTag(props WorkloadTagProps) htmx.Node { | ||
return htmx.FormElement( | ||
htmx.ClassNames{ | ||
tailwind.Flex: true, | ||
tailwind.WFull: true, | ||
tailwind.SpaceX4: true, | ||
}, | ||
htmx.HxDelete(fmt.Sprintf(utils.RemoveWorkloadTagUrlFormat, props.WorkloadID, props.Tag.ID)), | ||
htmx.HxConfirm("Are you sure you want to remove this tag?"), | ||
htmx.HxDisabledElt("button"), | ||
forms.FormControl( | ||
forms.FormControlProps{ | ||
ClassNames: htmx.ClassNames{}, | ||
}, | ||
forms.TextInputBordered( | ||
forms.TextInputProps{ | ||
Value: props.Tag.Name, | ||
Disabled: true, | ||
}, | ||
), | ||
forms.FormControlLabel( | ||
forms.FormControlLabelProps{}, | ||
forms.FormControlLabelText( | ||
forms.FormControlLabelTextProps{ | ||
ClassNames: htmx.ClassNames{ | ||
"text-neutral-500": true, | ||
}, | ||
}, | ||
htmx.Text("Key in a tag."), | ||
), | ||
), | ||
), | ||
forms.FormControl( | ||
forms.FormControlProps{ | ||
ClassNames: htmx.ClassNames{}, | ||
}, | ||
forms.TextInputBordered( | ||
forms.TextInputProps{ | ||
Value: props.Tag.Value, | ||
Disabled: true, | ||
}, | ||
), | ||
forms.FormControlLabel( | ||
forms.FormControlLabelProps{}, | ||
forms.FormControlLabelText( | ||
forms.FormControlLabelTextProps{ | ||
ClassNames: htmx.ClassNames{ | ||
"text-neutral-500": true, | ||
}, | ||
}, | ||
htmx.Text("Value in a tag."), | ||
), | ||
), | ||
), | ||
buttons.Button( | ||
buttons.ButtonProps{ | ||
Type: "submit", | ||
}, | ||
icons.TrashOutline( | ||
icons.IconProps{}, | ||
), | ||
), | ||
) | ||
} |
This file contains 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,62 @@ | ||
package workloads | ||
|
||
import ( | ||
htmx "github.com/zeiss/fiber-htmx" | ||
"github.com/zeiss/fiber-htmx/components/buttons" | ||
"github.com/zeiss/fiber-htmx/components/cards" | ||
"github.com/zeiss/fiber-htmx/components/tailwind" | ||
"github.com/zeiss/service-lens/internal/models" | ||
) | ||
|
||
// WorkloadTagsCardProps ... | ||
type WorkloadTagsCardProps struct { | ||
ClassNames htmx.ClassNames | ||
Workload models.Workload | ||
} | ||
|
||
// WorkloadTagsCard ... | ||
func WorkloadTagsCard(props WorkloadTagsCardProps) htmx.Node { | ||
return cards.CardBordered( | ||
cards.CardProps{ | ||
ClassNames: htmx.ClassNames{ | ||
tailwind.M2: true, | ||
}, | ||
}, | ||
cards.Body( | ||
cards.BodyProps{}, | ||
cards.Title( | ||
cards.TitleProps{}, | ||
htmx.Text("Tags"), | ||
), | ||
htmx.Div( | ||
htmx.ID("tags"), | ||
htmx.Group( | ||
htmx.ForEach(props.Workload.Tags, func(tag models.Tag, idx int) htmx.Node { | ||
return WorkloadTag( | ||
WorkloadTagProps{ | ||
WorkloadID: props.Workload.ID, | ||
Tag: tag, | ||
}, | ||
) | ||
}, | ||
)..., | ||
), | ||
), | ||
AddTagModal( | ||
AddTagModalProps{ | ||
WorkloadID: props.Workload.ID, | ||
}, | ||
), | ||
cards.Actions( | ||
cards.ActionsProps{}, | ||
buttons.Button( | ||
buttons.ButtonProps{ | ||
Type: "button", | ||
}, | ||
htmx.OnClick("add_tag_modal.showModal()"), | ||
htmx.Text("Add Tag"), | ||
), | ||
), | ||
), | ||
) | ||
} |
This file contains 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
Oops, something went wrong.