-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Added Description Field for Secrets and Variables #33526
base: main
Are you sure you want to change the base?
Conversation
@@ -77,6 +81,15 @@ | |||
placeholder="{{ctx.Locale.Tr "secrets.creation.name_placeholder"}}" | |||
> | |||
</div> | |||
<div class="field"> | |||
<label for="dialog-variable-description">{{ctx.Locale.Tr "secrets.creation.description"}}</label> | |||
<input |
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.
Should probably also add max length to this field
Is there a standardized length limit for these texts in the project? Maybe we should define constants for these. For now, I've capped them all at 4096 characters |
LGTM except #33526 (comment) Screenshots are necessary. |
I noticed that the data field also doesn't have a length restriction. I'll add a length constraint to it as well. For this field, I think a limit of 65536 would be appropriate, although we can truncate the display when showing it. const (
VariableDataMaxLength = 65536
VariableDescriptionMaxLength = 4096
)
if utf8.RuneCountInString(data) > VariableDataMaxLength {
data = string([]rune(data)[:VariableDataMaxLength])
}
if utf8.RuneCountInString(description) > VariableDescriptionMaxLength {
description = string([]rune(description)[:VariableDescriptionMaxLength])
} Any other suggestions? |
I think the description should be moved under value because it's optional. And it's better to have 2 rows at least. |
Does it refer only to the form, or does it also include the list? Perhaps it would be better to place the description in the list above. |
if ownerID != 0 && repoID != 0 { | ||
// It's trying to create a variable that belongs to a repository, but OwnerID has been set accidentally. | ||
// Remove OwnerID to avoid confusion; it's not worth returning an error here. | ||
ownerID = 0 | ||
} | ||
|
||
if utf8.RuneCountInString(data) > VariableDataMaxLength { |
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.
I think we should return failure here because data should not be truncated.
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.
yes, you are right
data = string([]rune(data)[:VariableDataMaxLength]) | ||
} | ||
|
||
if utf8.RuneCountInString(description) > VariableDescriptionMaxLength { |
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.
Use util.SplitStringAtByteN
directly.
@@ -67,15 +74,25 @@ func InsertEncryptedSecret(ctx context.Context, ownerID, repoID int64, name, dat | |||
return nil, fmt.Errorf("%w: ownerID and repoID cannot be both zero, global secrets are not supported", util.ErrInvalidArgument) | |||
} | |||
|
|||
if len(data) > SecretDataMaxLength { |
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.
I think we should return failure here because data should not be truncated.
data = data[:SecretDataMaxLength] | ||
} | ||
|
||
if utf8.RuneCountInString(description) > SecretDescriptionMaxLength { |
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.
Use util.SplitStringAtByteN
directly.
@@ -62,7 +65,6 @@ | |||
<input autofocus required | |||
id="secret-name" | |||
name="name" | |||
value="{{.name}}" |
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.
Why remove this?
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.
Is this property actually needed? I don't see it used anywhere, and the template isn't setting its value.
@@ -72,7 +77,6 @@ | |||
<input autofocus required | |||
name="name" | |||
id="dialog-variable-name" | |||
value="{{.name}}" |
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.
As above
@@ -24,6 +25,9 @@ | |||
<div class="flex-item-title"> | |||
{{.Name}} | |||
</div> | |||
<div class="flex-item-body"> | |||
{{if .Description}} {{.Description}} {{else}} - {{end}} |
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.
{{if .Description}} {{.Description}} {{else}} - {{end}} | |
{{if .Description}}{{.Description}}{{else}}-{{end}} |
Whitespace inside HTML tags is irrelevant in flexbox. If you really need it for spacing, use
or add margin classes.
@@ -22,6 +22,9 @@ | |||
<div class="flex-item-title"> | |||
{{.Name}} | |||
</div> | |||
<div class="flex-item-body"> | |||
{{if .Description}} {{.Description}} {{else}} - {{end}} |
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.
{{if .Description}} {{.Description}} {{else}} - {{end}} | |
{{if .Description}}{{.Description}}{{else}}-{{end}} |
Fixes #33484