Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(site): display version message#8435

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 14 commits intomainfrombq/add-version-message
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
5bc48df
Add base
BrunoQuaresmaJul 11, 2023
42643b6
Add more info to outdated tooltip
BrunoQuaresmaJul 11, 2023
3936a13
Fix link
BrunoQuaresmaJul 12, 2023
3496e4d
Fix test
BrunoQuaresmaJul 12, 2023
e01ac01
feat(coderd): allow template version message to be set to empty
mafredriJul 12, 2023
273061a
fix(coderd): fix bug in template creation that resets the message
mafredriJul 12, 2023
ebd8e0d
make gen
mafredriJul 12, 2023
5904c6d
fix patch in template editor
mafredriJul 12, 2023
9cdce40
fix comment
mafredriJul 12, 2023
46ac0d6
Fix test
BrunoQuaresmaJul 12, 2023
434cf2b
Fix fmt
BrunoQuaresmaJul 12, 2023
4fff5e2
Fix storybook
BrunoQuaresmaJul 12, 2023
4d610e1
Merge branch 'main' into bq/add-version-message
BrunoQuaresmaJul 12, 2023
e4196c4
Merge branch 'main' into bq/add-version-message
BrunoQuaresmaJul 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionscoderd/apidoc/docs.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 3 additions & 0 deletionscoderd/apidoc/swagger.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

1 change: 1 addition & 0 deletionscoderd/database/dbfake/dbfake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4771,6 +4771,7 @@ func (q *FakeQuerier) UpdateTemplateVersionByID(_ context.Context, arg database.
templateVersion.TemplateID = arg.TemplateID
templateVersion.UpdatedAt = arg.UpdatedAt
templateVersion.Name = arg.Name
templateVersion.Message = arg.Message
q.templateVersions[index] = templateVersion
return templateVersion, nil
}
Expand Down
5 changes: 4 additions & 1 deletioncoderd/database/queries.sql.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 2 additions & 1 deletioncoderd/database/queries/templateversions.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,7 +91,8 @@ UPDATE
SET
template_id = $2,
updated_at = $3,
name = $4
name = $4,
message = $5
WHERE
id = $1 RETURNING *;

Expand Down
1 change: 1 addition & 0 deletionscoderd/templates.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -336,6 +336,7 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque
},
UpdatedAt: database.Now(),
Name: templateVersion.Name,
Message: templateVersion.Message,
})
if err != nil {
return xerrors.Errorf("insert template version: %s", err)
Expand Down
5 changes: 5 additions & 0 deletionscoderd/templateversions.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,12 +106,17 @@ func (api *API) patchTemplateVersion(rw http.ResponseWriter, r *http.Request) {
TemplateID: templateVersion.TemplateID,
UpdatedAt: database.Now(),
Name: templateVersion.Name,
Message: templateVersion.Message,
}

if params.Name != "" {
updateParams.Name = params.Name
}

if params.Message != nil {
updateParams.Message = *params.Message
}

errTemplateVersionNameConflict := xerrors.New("template version name must be unique for a template")

var updatedTemplateVersion database.TemplateVersion
Expand Down
65 changes: 65 additions & 0 deletionscoderd/templateversions_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1223,6 +1223,71 @@ func TestTemplateVersionPatch(t *testing.T) {
assert.NotEqual(t, updatedVersion.Name, version.Name)
})

t.Run("Update the message", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil, func(req *codersdk.CreateTemplateVersionRequest) {
req.Message = "Example message"
})
coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

wantMessage := "Updated message"
updatedVersion, err := client.UpdateTemplateVersion(ctx, version.ID, codersdk.PatchTemplateVersionRequest{
Message: &wantMessage,
})

require.NoError(t, err)
assert.Equal(t, wantMessage, updatedVersion.Message)
})

t.Run("Remove the message", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil, func(req *codersdk.CreateTemplateVersionRequest) {
req.Message = "Example message"
})
coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

wantMessage := ""
updatedVersion, err := client.UpdateTemplateVersion(ctx, version.ID, codersdk.PatchTemplateVersionRequest{
Message: &wantMessage,
})

require.NoError(t, err)
assert.Equal(t, wantMessage, updatedVersion.Message)
})

t.Run("Keep the message", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
wantMessage := "Example message"
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil, func(req *codersdk.CreateTemplateVersionRequest) {
req.Message = wantMessage
})
coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)

t.Log(version.Message)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

updatedVersion, err := client.UpdateTemplateVersion(ctx, version.ID, codersdk.PatchTemplateVersionRequest{
Message: nil,
})

require.NoError(t, err)
assert.Equal(t, wantMessage, updatedVersion.Message)
})

t.Run("Use the same name if a new name is not passed", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
Expand Down
3 changes: 2 additions & 1 deletioncodersdk/templateversions.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,7 +87,8 @@ type TemplateVersionVariable struct {
}

type PatchTemplateVersionRequest struct {
Name string `json:"name" validate:"omitempty,template_version_name"`
Name string `json:"name" validate:"omitempty,template_version_name"`
Message *string `json:"message,omitempty" validate:"omitempty,lt=1048577"`
}

// TemplateVersion returns a template version by ID.
Expand Down
8 changes: 5 additions & 3 deletionsdocs/api/schemas.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3226,15 +3226,17 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in

```json
{
"message": "string",
"name": "string"
}
```

### Properties

| Name | Type | Required | Restrictions | Description |
| ------ | ------ | -------- | ------------ | ----------- |
| `name` | string | false | | |
| Name | Type | Required | Restrictions | Description |
| --------- | ------ | -------- | ------------ | ----------- |
| `message` | string | false | | |
| `name` | string | false | | |

## codersdk.PatchWorkspaceProxy

Expand Down
1 change: 1 addition & 0 deletionsdocs/api/templates.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1249,6 +1249,7 @@ curl -X PATCH http://coder-server:8080/api/v2/templateversions/{templateversion}

```json
{
"message": "string",
"name": "string"
}
```
Expand Down
8 changes: 8 additions & 0 deletionssite/.storybook/preview.jsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import { HelmetProvider } from "react-helmet-async"
import { dark } from "../src/theme"
import "../src/theme/globalFonts"
import "../src/i18n"
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"

export const decorators = [
(Story) => (
Expand All@@ -23,6 +24,13 @@ export const decorators = [
</HelmetProvider>
)
},
(Story) => {
return (
<QueryClientProvider client={new QueryClient()}>
<Story />
</QueryClientProvider>
)
},
]

export const parameters = {
Expand Down
1 change: 1 addition & 0 deletionssite/src/api/typesGenerated.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -644,6 +644,7 @@ export interface PatchGroupRequest {
// From codersdk/templateversions.go
export interface PatchTemplateVersionRequest {
readonly name: string
readonly message?: string
}

// From codersdk/workspaceproxy.go
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,10 +32,12 @@ export const PublishTemplateVersionDialog: FC<
const form = useFormik({
initialValues: {
name: defaultName,
message: "",
isActiveVersion: false,
},
validationSchema: Yup.object({
name: Yup.string().required(),
message: Yup.string(),
isActiveVersion: Yup.boolean(),
}),
onSubmit: onConfirm,
Expand DownExpand Up@@ -70,6 +72,16 @@ export const PublishTemplateVersionDialog: FC<
disabled={isPublishing}
/>

<TextField
{...getFieldHelpers("message")}
label="Message"
placeholder="Write a short message about the changes you made..."
autoFocus
disabled={isPublishing}
multiline
rows={5}
/>

<FormControlLabel
label="Promote to default version"
control={
Expand Down
66 changes: 0 additions & 66 deletionssite/src/components/Tooltips/OutdatedHelpTooltip.tsx
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp