Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
Add base
  • Loading branch information
BrunoQuaresma committed Jul 11, 2023
commit 5bc48df3dced414f7511ecd1f108d289dbe0db75
3 changes: 3 additions & 0 deletions coderd/apidoc/docs.go

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

3 changes: 3 additions & 0 deletions coderd/apidoc/swagger.json

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

5 changes: 4 additions & 1 deletion coderd/database/queries.sql.go

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

3 changes: 2 additions & 1 deletion coderd/database/queries/templateversions.sql
Original file line number Diff line number Diff 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
5 changes: 5 additions & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff 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 != "" {
updateParams.Message = params.Message
}

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

var updatedTemplateVersion database.TemplateVersion
Expand Down
3 changes: 2 additions & 1 deletion codersdk/templateversions.go
Original file line number Diff line number Diff 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" validate:"omitempty"`
}

// TemplateVersion returns a template version by ID.
Expand Down
8 changes: 5 additions & 3 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -3222,15 +3222,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 deletions docs/api/templates.md
Original file line number Diff line number Diff 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
1 change: 1 addition & 0 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 Down Expand 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ interface TooltipProps {
ariaLabel?: string
}

export const OutdatedHelpTooltip: FC<React.PropsWithChildren<TooltipProps>> = ({
onUpdateVersion,
ariaLabel,
}) => {
export const WorkspaceOutdatedTooltip: FC<
React.PropsWithChildren<TooltipProps>
> = ({ onUpdateVersion, ariaLabel }) => {
const styles = useStyles()

return (
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Tooltips/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { AuditHelpTooltip } from "./AuditHelpTooltip"
export { OutdatedHelpTooltip } from "./OutdatedHelpTooltip"
export { WorkspaceOutdatedTooltip } from "./WorkspaceOutdatedTooltip"
export { UserRoleHelpTooltip } from "./UserRoleHelpTooltip"
export { WorkspaceHelpTooltip } from "./WorkspaceHelpTooltip"
4 changes: 2 additions & 2 deletions site/src/components/WorkspaceStats/WorkspaceStats.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "@mui/material/Link"
import { OutdatedHelpTooltip } from "components/Tooltips"
import { WorkspaceOutdatedTooltip } from "components/Tooltips"
import { FC, useRef, useState } from "react"
import { Link as RouterLink } from "react-router-dom"
import { createDayString } from "utils/createDayString"
Expand Down Expand Up @@ -101,7 +101,7 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
</Link>

{workspace.outdated && (
<OutdatedHelpTooltip
<WorkspaceOutdatedTooltip
onUpdateVersion={handleUpdate}
ariaLabel="update version"
/>
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/WorkspacesTable/WorkspacesRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useNavigate } from "react-router-dom"
import { getDisplayWorkspaceTemplateName } from "utils/workspace"
import { LastUsed } from "../LastUsed/LastUsed"
import { Workspace } from "api/typesGenerated"
import { OutdatedHelpTooltip } from "components/Tooltips/OutdatedHelpTooltip"
import { WorkspaceOutdatedTooltip } from "components/Tooltips/WorkspaceOutdatedTooltip"
import { Avatar } from "components/Avatar/Avatar"
import { Stack } from "components/Stack/Stack"
import { useClickableTableRow } from "hooks/useClickableTableRow"
Expand All @@ -34,7 +34,7 @@ export const WorkspacesRow: FC<{
<Stack direction="row" spacing={0} alignItems="center">
{workspace.name}
{workspace.outdated && (
<OutdatedHelpTooltip
<WorkspaceOutdatedTooltip
onUpdateVersion={() => {
onUpdateWorkspace(workspace)
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type PublishVersionData = {
name: string
message: string
isActiveVersion: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Margins } from "components/Margins/Margins"
import {
PageHeader,
PageHeaderCaption,
PageHeaderSubtitle,
PageHeaderTitle,
} from "components/PageHeader/PageHeader"
import { Stack } from "components/Stack/Stack"
Expand Down Expand Up @@ -52,6 +53,11 @@ export const TemplateVersionPageView: FC<TemplateVersionPageViewProps> = ({
>
<PageHeaderCaption>{t("header.caption")}</PageHeaderCaption>
<PageHeaderTitle>{versionName}</PageHeaderTitle>
{currentVersion &&
currentVersion.message &&
currentVersion.message !== "" && (
<PageHeaderSubtitle>{currentVersion.message}</PageHeaderSubtitle>
)}
</PageHeader>

{!currentFiles && !error && <Loader />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export const templateVersionEditorMachine = createMachine(
},
publishingVersion: async (
{ version, templateId },
{ name, isActiveVersion },
{ name, message, isActiveVersion },
) => {
if (!version) {
throw new Error("Version is not set")
Expand All @@ -398,7 +398,7 @@ export const templateVersionEditorMachine = createMachine(
await Promise.all([
// Only do a patch if the name is different
name !== version.name
? API.patchTemplateVersion(version.id, { name })
? API.patchTemplateVersion(version.id, { name, message })
: Promise.resolve(),
isActiveVersion
? API.updateActiveTemplateVersion(templateId, {
Expand Down