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

Skip to content

chore(site): Remove template editor out of experimental #7165

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 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions coderd/apidoc/docs.go

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

4 changes: 2 additions & 2 deletions coderd/apidoc/swagger.json

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

6 changes: 1 addition & 5 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1605,10 +1605,6 @@ func (c *Client) BuildInfo(ctx context.Context) (BuildInfoResponse, error) {
type Experiment string

const (
// ExperimentTemplateEditor is an internal experiment that enables the template editor
// for all users.
ExperimentTemplateEditor Experiment = "template_editor"

// ExperimentMoons enabled the workspace proxy endpoints and CRUD. This
// feature is not yet complete in functionality.
ExperimentMoons Experiment = "moons"
Expand All @@ -1621,7 +1617,7 @@ const (
// users to opt-in to via --experimental='*'.
// Experiments that are not ready for consumption by all users should
// not be included here and will be essentially hidden.
var ExperimentsAll = Experiments{ExperimentTemplateEditor}
var ExperimentsAll = Experiments{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above comment is confusing to me - "should not be included here"? I assume any experiment included in this struct will be hidden.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It kinda is 🤔


// Experiments is a list of experiments that are enabled for the deployment.
// Multiple experiments may be enabled at the same time.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ curl -X GET http://coder-server:8080/api/v2/experiments \
> 200 Response
```json
["template_editor"]
["moons"]
```

### Responses
Expand Down
9 changes: 4 additions & 5 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2447,17 +2447,16 @@ CreateParameterRequest is a structure used to create a new parameter value for a
## codersdk.Experiment

```json
"template_editor"
"moons"
```

### Properties

#### Enumerated Values

| Value |
| ----------------- |
| `template_editor` |
| `moons` |
| Value |
| ------- |
| `moons` |

## codersdk.Feature

Expand Down
4 changes: 2 additions & 2 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1309,8 +1309,8 @@ export const Entitlements: Entitlement[] = [
]

// From codersdk/deployment.go
export type Experiment = "moons" | "template_editor"
export const Experiments: Experiment[] = ["moons", "template_editor"]
export type Experiment = "moons"
export const Experiments: Experiment[] = ["moons"]

// From codersdk/deployment.go
export type FeatureName =
Expand Down
3 changes: 0 additions & 3 deletions site/src/components/TemplateLayout/TemplateLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
getTemplateVersion,
} from "api/api"
import { useQuery } from "@tanstack/react-query"
import { useDashboard } from "components/Dashboard/DashboardProvider"
import { AuthorizationRequest } from "api/typesGenerated"

const templatePermissions = (
Expand Down Expand Up @@ -72,7 +71,6 @@ export const TemplateLayout: FC<{ children?: JSX.Element }> = ({
queryKey: ["template", templateName],
queryFn: () => fetchTemplate(orgId, templateName),
})
const dashboard = useDashboard()

if (error) {
return (
Expand All @@ -92,7 +90,6 @@ export const TemplateLayout: FC<{ children?: JSX.Element }> = ({
template={data.template}
activeVersion={data.activeVersion}
permissions={data.permissions}
canEditFiles={dashboard.experiments.includes("template_editor")}
onDeleteTemplate={() => {
navigate("/templates")
}}
Expand Down
46 changes: 19 additions & 27 deletions site/src/components/TemplateLayout/TemplatePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import FileCopyOutlined from "@material-ui/icons/FileCopyOutlined"
const TemplateMenu: FC<{
templateName: string
templateVersion: string
canEditFiles: boolean
onDelete: () => void
}> = ({ templateName, templateVersion, canEditFiles, onDelete }) => {
}> = ({ templateName, templateVersion, onDelete }) => {
const menuTriggerRef = useRef<HTMLButtonElement>(null)
const [isMenuOpen, setIsMenuOpen] = useState(false)
const navigate = useNavigate()
Expand Down Expand Up @@ -69,28 +68,24 @@ const TemplateMenu: FC<{
<SettingsOutlined />
Settings
</MenuItem>
{canEditFiles && (
<MenuItem
onClick={onMenuItemClick(() =>
navigate(`/templates/new?fromTemplate=${templateName}`),
)}
>
<FileCopyOutlined />
Duplicate
</MenuItem>
)}
{canEditFiles && (
<MenuItem
onClick={onMenuItemClick(() =>
navigate(
`/templates/${templateName}/versions/${templateVersion}/edit`,
),
)}
>
<EditOutlined />
Edit files
</MenuItem>
)}
<MenuItem
onClick={onMenuItemClick(() =>
navigate(`/templates/new?fromTemplate=${templateName}`),
)}
>
<FileCopyOutlined />
Duplicate
</MenuItem>
<MenuItem
onClick={onMenuItemClick(() =>
navigate(
`/templates/${templateName}/versions/${templateVersion}/edit`,
),
)}
>
<EditOutlined />
Edit files
</MenuItem>
<MenuItem onClick={onMenuItemClick(onDelete)}>
<DeleteOutlined />
Delete
Expand All @@ -117,15 +112,13 @@ export type TemplatePageHeaderProps = {
template: Template
activeVersion: TemplateVersion
permissions: AuthorizationResponse
canEditFiles: boolean
onDeleteTemplate: () => void
}

export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
template,
activeVersion,
permissions,
canEditFiles,
onDeleteTemplate,
}) => {
const hasIcon = template.icon && template.icon !== ""
Expand All @@ -142,7 +135,6 @@ export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
templateVersion={activeVersion.name}
templateName={template.name}
onDelete={deleteTemplate.openDeleteConfirmation}
canEditFiles={canEditFiles}
/>
</Maybe>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import { VersionsTable } from "components/VersionsTable/VersionsTable"
import { useState } from "react"
import { Helmet } from "react-helmet-async"
import { getTemplatePageTitle } from "../utils"
import { useDashboard } from "components/Dashboard/DashboardProvider"

const TemplateVersionsPage = () => {
const dashboard = useDashboard()
const { template, permissions } = useTemplateLayoutContext()
const { data } = useQuery({
queryKey: ["template", "versions", template.id],
Expand Down Expand Up @@ -39,9 +37,6 @@ const TemplateVersionsPage = () => {
const [selectedVersionIdToPromote, setSelectedVersionIdToPromote] = useState<
string | undefined
>()
const canPromoteVersion =
dashboard.experiments.includes("template_editor") &&
permissions.canUpdateTemplate

return (
<>
Expand All @@ -51,7 +46,9 @@ const TemplateVersionsPage = () => {
<VersionsTable
versions={data}
onPromoteClick={
canPromoteVersion ? setSelectedVersionIdToPromote : undefined
permissions.canUpdateTemplate
? setSelectedVersionIdToPromote
: undefined
}
activeVersionId={latestActiveVersion}
/>
Expand Down
3 changes: 0 additions & 3 deletions site/src/pages/TemplateVersionPage/TemplateVersionPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMachine } from "@xstate/react"
import { useDashboard } from "components/Dashboard/DashboardProvider"
import { useOrganizationId } from "hooks/useOrganizationId"
import { useTab } from "hooks/useTab"
import { FC } from "react"
Expand All @@ -23,7 +22,6 @@ export const TemplateVersionPage: FC = () => {
})
const tab = useTab("file", "0")
const { t } = useTranslation("templateVersionPage")
const dashboard = useDashboard()

return (
<>
Expand All @@ -38,7 +36,6 @@ export const TemplateVersionPage: FC = () => {
versionName={versionName}
templateName={templateName}
tab={tab}
canEdit={dashboard.experiments.includes("template_editor")}
/>
</>
)
Expand Down
22 changes: 9 additions & 13 deletions site/src/pages/TemplateVersionPage/TemplateVersionPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface TemplateVersionPageViewProps {
*/
versionName: string
templateName: string
canEdit: boolean
tab: UseTabResult
context: TemplateVersionMachineContext
}
Expand All @@ -35,7 +34,6 @@ export const TemplateVersionPageView: FC<TemplateVersionPageViewProps> = ({
tab,
versionName,
templateName,
canEdit,
}) => {
const { currentFiles, error, currentVersion, previousFiles } = context
const { t } = useTranslation("templateVersionPage")
Expand All @@ -44,17 +42,15 @@ export const TemplateVersionPageView: FC<TemplateVersionPageViewProps> = ({
<Margins>
<PageHeader
actions={
canEdit ? (
<Link
underline="none"
component={RouterLink}
to={`/templates/${templateName}/versions/${versionName}/edit`}
>
<Button variant="outlined" startIcon={<EditIcon />}>
Edit
</Button>
</Link>
) : undefined
<Link
underline="none"
component={RouterLink}
to={`/templates/${templateName}/versions/${versionName}/edit`}
>
<Button variant="outlined" startIcon={<EditIcon />}>
Edit
</Button>
</Link>
}
>
<PageHeaderCaption>{t("header.caption")}</PageHeaderCaption>
Expand Down
5 changes: 1 addition & 4 deletions site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export const WorkspaceReadyPage = ({
queryFn: () => getTemplateVersions(workspace.template_id),
enabled: changeVersionDialogOpen,
})
const dashboard = useDashboard()

// keep banner machine in sync with workspace
useEffect(() => {
Expand Down Expand Up @@ -137,9 +136,7 @@ export const WorkspaceReadyPage = ({
builds={builds}
canUpdateWorkspace={canUpdateWorkspace}
canUpdateTemplate={canUpdateTemplate}
canChangeVersions={
canUpdateTemplate && dashboard.experiments.includes("template_editor")
}
canChangeVersions={canUpdateTemplate}
hideSSHButton={featureVisibility["browser_only"]}
hideVSCodeDesktopButton={featureVisibility["browser_only"]}
workspaceErrors={{
Expand Down