feat(site): improve template publishing flow (#9346)

This commit is contained in:
Kayla Washburn
2023-08-28 11:27:51 -06:00
committed by GitHub
parent 80425c32bf
commit ce9b048f06
8 changed files with 399 additions and 327 deletions
@@ -17,6 +17,14 @@ const ExampleAction = (
</Button>
)
export const Success: Story = {
args: {
children: "You're doing great!",
severity: "success",
onRetry: undefined,
},
}
export const Warning: Story = {
args: {
children: "This is a warning",
@@ -11,6 +11,12 @@ import Checkbox from "@mui/material/Checkbox"
import FormControlLabel from "@mui/material/FormControlLabel"
import { Stack } from "components/Stack/Stack"
export const Language = {
versionNameLabel: "Version name",
messagePlaceholder: "Write a short message about the changes you made...",
defaultCheckboxLabel: "Promote to default version",
}
export type PublishTemplateVersionDialogProps = DialogProps & {
defaultName: string
isPublishing: boolean
@@ -33,7 +39,7 @@ export const PublishTemplateVersionDialog: FC<
initialValues: {
name: defaultName,
message: "",
isActiveVersion: false,
isActiveVersion: true,
},
validationSchema: Yup.object({
name: Yup.string().required(),
@@ -67,7 +73,7 @@ export const PublishTemplateVersionDialog: FC<
<FormFields>
<TextField
{...getFieldHelpers("name")}
label="Version name"
label={Language.versionNameLabel}
autoFocus
disabled={isPublishing}
/>
@@ -75,7 +81,7 @@ export const PublishTemplateVersionDialog: FC<
<TextField
{...getFieldHelpers("message")}
label="Message"
placeholder="Write a short message about the changes you made..."
placeholder={Language.messagePlaceholder}
autoFocus
disabled={isPublishing}
multiline
@@ -83,7 +89,7 @@ export const PublishTemplateVersionDialog: FC<
/>
<FormControlLabel
label="Promote to default version"
label={Language.defaultCheckboxLabel}
control={
<Checkbox
size="small"
@@ -3,6 +3,7 @@ import {
MockTemplateVersion,
MockTemplateVersionFileTree,
MockWorkspaceBuildLogs,
MockWorkspaceExtendedBuildLogs,
MockWorkspaceResource,
MockWorkspaceResource2,
MockWorkspaceResource3,
@@ -55,314 +56,12 @@ export const ManyLogs = {
"template import provision for start: terraform plan: exit status 1",
},
},
buildLogs: [
{
id: 938494,
created_at: "2023-08-25T19:07:43.331Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Setting up",
output: "",
},
{
id: 938495,
created_at: "2023-08-25T19:07:43.331Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Parsing template parameters",
output: "",
},
{
id: 938496,
created_at: "2023-08-25T19:07:43.339Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938497,
created_at: "2023-08-25T19:07:44.15Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "Initializing the backend...",
},
{
id: 938498,
created_at: "2023-08-25T19:07:44.215Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "Initializing provider plugins...",
},
{
id: 938499,
created_at: "2023-08-25T19:07:44.216Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: '- Finding coder/coder versions matching "~> 0.11.0"...',
},
{
id: 938500,
created_at: "2023-08-25T19:07:44.668Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: '- Finding kreuzwerker/docker versions matching "~> 3.0.1"...',
},
{
id: 938501,
created_at: "2023-08-25T19:07:44.722Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "- Using coder/coder v0.11.1 from the shared cache directory",
},
{
id: 938502,
created_at: "2023-08-25T19:07:44.857Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"- Using kreuzwerker/docker v3.0.2 from the shared cache directory",
},
{
id: 938503,
created_at: "2023-08-25T19:07:45.081Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"Terraform has created a lock file .terraform.lock.hcl to record the provider",
},
{
id: 938504,
created_at: "2023-08-25T19:07:45.081Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"selections it made above. Include this file in your version control repository",
},
{
id: 938505,
created_at: "2023-08-25T19:07:45.081Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"so that Terraform can guarantee to make the same selections by default when",
},
{
id: 938506,
created_at: "2023-08-25T19:07:45.082Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: 'you run "terraform init" in the future.',
},
{
id: 938507,
created_at: "2023-08-25T19:07:45.083Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "Terraform has been successfully initialized!",
},
{
id: 938508,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
'You may now begin working with Terraform. Try running "terraform plan" to see',
},
{
id: 938509,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"any changes that are required for your infrastructure. All Terraform commands",
},
{
id: 938510,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "should now work.",
},
{
id: 938511,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"If you ever set or change modules or backend configuration for Terraform,",
},
{
id: 938512,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"rerun this command to reinitialize your working directory. If you forget, other",
},
{
id: 938513,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "commands will detect it and remind you to do so if necessary.",
},
{
id: 938514,
created_at: "2023-08-25T19:07:45.143Z",
log_source: "provisioner",
log_level: "info",
stage: "Detecting persistent resources",
output: "Terraform 1.1.9",
},
{
id: 938515,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "Warning: Argument is deprecated",
},
{
id: 938516,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: 'on devcontainer-on-docker.tf line 15, in provider "coder":',
},
{
id: 938517,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: " 15: feature_use_managed_variables = true",
},
{
id: 938518,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938519,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output:
"Terraform variables are now exclusively utilized for template-wide variables after the removal of support for legacy parameters.",
},
{
id: 938520,
created_at: "2023-08-25T19:07:46.3Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: "Error: ephemeral parameter requires the default property",
},
{
id: 938521,
created_at: "2023-08-25T19:07:46.3Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output:
'on devcontainer-on-docker.tf line 27, in data "coder_parameter" "another_one":',
},
{
id: 938522,
created_at: "2023-08-25T19:07:46.3Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: ' 27: data "coder_parameter" "another_one" {',
},
{
id: 938523,
created_at: "2023-08-25T19:07:46.301Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938524,
created_at: "2023-08-25T19:07:46.301Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938525,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "Warning: Argument is deprecated",
},
{
id: 938526,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: 'on devcontainer-on-docker.tf line 15, in provider "coder":',
},
{
id: 938527,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: " 15: feature_use_managed_variables = true",
},
{
id: 938528,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938529,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output:
"Terraform variables are now exclusively utilized for template-wide variables after the removal of support for legacy parameters.",
},
{
id: 938530,
created_at: "2023-08-25T19:07:46.311Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Cleaning Up",
output: "",
},
],
buildLogs: MockWorkspaceExtendedBuildLogs,
},
}
export const Published = {
args: {
publishedVersion: MockTemplateVersion,
},
}
@@ -64,6 +64,9 @@ export interface TemplateVersionEditorProps {
onConfirmPublish: (data: PublishVersionData) => void
onCancelPublish: () => void
publishingError: unknown
publishedVersion?: TemplateVersion
publishedVersionIsDefault?: boolean
onCreateWorkspace: () => void
isAskingPublishParameters: boolean
isPromptingMissingVariables: boolean
isPublishing: boolean
@@ -97,9 +100,12 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
onPublish,
onConfirmPublish,
onCancelPublish,
publishingError,
isAskingPublishParameters,
isPublishing,
publishingError,
publishedVersion,
publishedVersionIsDefault,
onCreateWorkspace,
buildLogs,
resources,
isPromptingMissingVariables,
@@ -107,11 +113,9 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
onSubmitMissingVariableValues,
onCancelSubmitMissingVariableValues,
}) => {
const [selectedTab, setSelectedTab] = useState(() => {
// If resources are provided, show them by default!
// This is for Storybook!
return resources ? 1 : 0
})
// If resources are provided, show them by default!
// This is for Storybook!
const [selectedTab, setSelectedTab] = useState(() => (resources ? 1 : 0))
const [fileTree, setFileTree] = useState(defaultFileTree)
const [createFileOpen, setCreateFileOpen] = useState(false)
const [deleteFileOpen, setDeleteFileOpen] = useState<string>()
@@ -204,6 +208,29 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
</Link>
</div>
{publishedVersion && (
<Alert
severity="success"
dismissible
actions={
// TODO: Only show this button when the version we just published is the
// new primary version. We should remove this condition soon, when we can
// create workspaces using any version, not just the primary.
publishedVersionIsDefault && (
<Button
variant="text"
size="small"
onClick={onCreateWorkspace}
>
Create a workspace
</Button>
)
}
>
Successfully published {publishedVersion.name}!
</Alert>
)}
<div className={styles.topbarSides}>
{/* Only start to show the build when a new template version is building */}
{templateVersion.id !== firstTemplateVersionOnEditor.current.id && (
@@ -7,6 +7,7 @@ import {
MockTemplateVersion,
MockWorkspaceBuildLogs,
} from "testHelpers/entities"
import { Language } from "../../../components/TemplateVersionEditor/PublishTemplateVersionDialog"
// For some reason this component in Jest is throwing a MUI style warning so,
// since we don't need it for this test, we can mock it out
@@ -67,9 +68,6 @@ test("Use custom name, message and set it as active when publishing", async () =
const messageField = within(publishDialog).getByLabelText("Message")
await user.clear(messageField)
await user.type(messageField, "Informative message")
await user.click(
within(publishDialog).getByLabelText("Promote to default version"),
)
await user.click(
within(publishDialog).getByRole("button", { name: "Publish" }),
)
@@ -132,6 +130,9 @@ test("Do not mark as active if promote is not checked", async () => {
const nameField = within(publishDialog).getByLabelText("Version name")
await user.clear(nameField)
await user.type(nameField, "v1.0")
await user.click(
within(publishDialog).getByLabelText(Language.defaultCheckboxLabel),
)
await user.click(
within(publishDialog).getByRole("button", { name: "Publish" }),
)
@@ -4,7 +4,7 @@ import { useOrganizationId } from "hooks/useOrganizationId"
import { usePermissions } from "hooks/usePermissions"
import { FC } from "react"
import { Helmet } from "react-helmet-async"
import { useParams } from "react-router-dom"
import { useNavigate, useParams } from "react-router-dom"
import { pageTitle } from "utils/page"
import { templateVersionEditorMachine } from "xServices/templateVersionEditor/templateVersionEditorXService"
import { useTemplateVersionData } from "./data"
@@ -15,6 +15,7 @@ type Params = {
}
export const TemplateVersionEditorPage: FC = () => {
const navigate = useNavigate()
const { version: versionName, template: templateName } = useParams() as Params
const orgId = useOrganizationId()
const [editorState, sendEvent] = useMachine(templateVersionEditorMachine, {
@@ -72,8 +73,15 @@ export const TemplateVersionEditorPage: FC = () => {
isAskingPublishParameters={editorState.matches(
"askPublishParameters",
)}
publishingError={editorState.context.publishingError}
isPublishing={editorState.matches("publishingVersion")}
publishingError={editorState.context.publishingError}
publishedVersion={editorState.context.lastSuccessfulPublishedVersion}
publishedVersionIsDefault={
editorState.context.lastSuccessfulPublishIsDefault
}
onCreateWorkspace={() => {
navigate(`/templates/${templateName}/workspace`)
}}
disablePreview={editorState.hasTag("loading")}
disableUpdate={
editorState.hasTag("loading") ||
+309
View File
@@ -1407,6 +1407,315 @@ export const MockWorkspaceBuildLogs: TypesGen.ProvisionerJobLog[] = [
},
]
export const MockWorkspaceExtendedBuildLogs: TypesGen.ProvisionerJobLog[] = [
{
id: 938494,
created_at: "2023-08-25T19:07:43.331Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Setting up",
output: "",
},
{
id: 938495,
created_at: "2023-08-25T19:07:43.331Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Parsing template parameters",
output: "",
},
{
id: 938496,
created_at: "2023-08-25T19:07:43.339Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938497,
created_at: "2023-08-25T19:07:44.15Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "Initializing the backend...",
},
{
id: 938498,
created_at: "2023-08-25T19:07:44.215Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "Initializing provider plugins...",
},
{
id: 938499,
created_at: "2023-08-25T19:07:44.216Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: '- Finding coder/coder versions matching "~> 0.11.0"...',
},
{
id: 938500,
created_at: "2023-08-25T19:07:44.668Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: '- Finding kreuzwerker/docker versions matching "~> 3.0.1"...',
},
{
id: 938501,
created_at: "2023-08-25T19:07:44.722Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "- Using coder/coder v0.11.1 from the shared cache directory",
},
{
id: 938502,
created_at: "2023-08-25T19:07:44.857Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "- Using kreuzwerker/docker v3.0.2 from the shared cache directory",
},
{
id: 938503,
created_at: "2023-08-25T19:07:45.081Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"Terraform has created a lock file .terraform.lock.hcl to record the provider",
},
{
id: 938504,
created_at: "2023-08-25T19:07:45.081Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"selections it made above. Include this file in your version control repository",
},
{
id: 938505,
created_at: "2023-08-25T19:07:45.081Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"so that Terraform can guarantee to make the same selections by default when",
},
{
id: 938506,
created_at: "2023-08-25T19:07:45.082Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: 'you run "terraform init" in the future.',
},
{
id: 938507,
created_at: "2023-08-25T19:07:45.083Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "Terraform has been successfully initialized!",
},
{
id: 938508,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
'You may now begin working with Terraform. Try running "terraform plan" to see',
},
{
id: 938509,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"any changes that are required for your infrastructure. All Terraform commands",
},
{
id: 938510,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "should now work.",
},
{
id: 938511,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"If you ever set or change modules or backend configuration for Terraform,",
},
{
id: 938512,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output:
"rerun this command to reinitialize your working directory. If you forget, other",
},
{
id: 938513,
created_at: "2023-08-25T19:07:45.084Z",
log_source: "provisioner",
log_level: "debug",
stage: "Detecting persistent resources",
output: "commands will detect it and remind you to do so if necessary.",
},
{
id: 938514,
created_at: "2023-08-25T19:07:45.143Z",
log_source: "provisioner",
log_level: "info",
stage: "Detecting persistent resources",
output: "Terraform 1.1.9",
},
{
id: 938515,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "Warning: Argument is deprecated",
},
{
id: 938516,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: 'on devcontainer-on-docker.tf line 15, in provider "coder":',
},
{
id: 938517,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: " 15: feature_use_managed_variables = true",
},
{
id: 938518,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938519,
created_at: "2023-08-25T19:07:46.297Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output:
"Terraform variables are now exclusively utilized for template-wide variables after the removal of support for legacy parameters.",
},
{
id: 938520,
created_at: "2023-08-25T19:07:46.3Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: "Error: ephemeral parameter requires the default property",
},
{
id: 938521,
created_at: "2023-08-25T19:07:46.3Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output:
'on devcontainer-on-docker.tf line 27, in data "coder_parameter" "another_one":',
},
{
id: 938522,
created_at: "2023-08-25T19:07:46.3Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: ' 27: data "coder_parameter" "another_one" {',
},
{
id: 938523,
created_at: "2023-08-25T19:07:46.301Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938524,
created_at: "2023-08-25T19:07:46.301Z",
log_source: "provisioner",
log_level: "error",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938525,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "Warning: Argument is deprecated",
},
{
id: 938526,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: 'on devcontainer-on-docker.tf line 15, in provider "coder":',
},
{
id: 938527,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: " 15: feature_use_managed_variables = true",
},
{
id: 938528,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output: "",
},
{
id: 938529,
created_at: "2023-08-25T19:07:46.303Z",
log_source: "provisioner",
log_level: "warn",
stage: "Detecting persistent resources",
output:
"Terraform variables are now exclusively utilized for template-wide variables after the removal of support for legacy parameters.",
},
{
id: 938530,
created_at: "2023-08-25T19:07:46.311Z",
log_source: "provisioner_daemon",
log_level: "info",
stage: "Cleaning Up",
output: "",
},
]
export const MockCancellationMessage = {
message: "Job successfully canceled",
}
@@ -24,13 +24,15 @@ export interface TemplateVersionEditorMachineContext {
buildLogs?: ProvisionerJobLog[]
tarReader?: TarReader
publishingError?: unknown
lastSuccessfulPublishedVersion?: TemplateVersion
lastSuccessfulPublishIsDefault?: boolean
missingVariables?: TemplateVersionVariable[]
missingVariableValues?: VariableValue[]
}
export const templateVersionEditorMachine = createMachine(
{
/** @xstate-layout N4IgpgJg5mDOIC5QBcwFsAOAbAhqgamAE6wCWA9gHYCiEpy5RAdKZfaTlqQF6tQDEASQByggCqCAggBlBALWoBtAAwBdRKAzkyyCpQ0gAHogC0AVgCMAJiZWAnBYDMZu3eVXHdq1YA0IAJ6IFhYAbDZWIe4AHI4hYcoA7BYJAL4pfqiYuATEZFS09IwsEFhg-ADCAErUkmLUAPr41JUAyoIA8sIq6kggWjp6Bs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Kmbcy4PIbTxEnI6BYYIODubdesdoPwujdB6L0Pp4BLW6ds7cGow6eVlOta2YIRkrG3MiTUGIsQ4jxASMFCV8KfkItWZ5pdBgeSlM4GYwtrZOF8ScuM4QkTgX2ASZUaZ6nzNkvbBKtk1IaSgFpHS719KwEMrLGlLihhKgZSUuuQIwg4tcZVYSWp4hSW2GEMluF8qFXSp0xFWzVrDEcNKSY6JDYzxxA4Q64R1ptxBEcw5RqqQzWGjLRyCrhGrEWGzDxVgwjeXWpCHwJzoSuqOkCKEnlwQkLUQs9pESCiO2Jo5eWgbIZwg2nHeeSIrAesOv0o5BIwR6lxLvNNQrU49wzk7Ji+agJeE5QSfyTgUYwjMKvLUGwbl2FGAU7qDberdz-jogBejqEtItS8ty20Y6JkWDCFw0zjkrCxuEFCCxLBxDzF6yd10Ol4QofOkBYCb4MTvrKqBVCQHtrcrKDU66pIlgWJ5HdiAcRKjQQsD1wRtoCvLOm4VWir3QJoY819q0wioo6mjLY2JFg4MVHg6Y4FZzbn7d6goUSYlxISQhicHiEJxCVCMewiotSrwKbYXYwQPAoTxCkFIQA */
predictableActionArguments: true,
id: "templateVersionEditor",
schema: {
@@ -68,7 +70,7 @@ export const templateVersionEditorMachine = createMachine(
data: WorkspaceResource[]
}
publishingVersion: {
data: void
data: { isActiveVersion: boolean }
}
loadMissingVariables: {
data: TemplateVersionVariable[]
@@ -108,7 +110,7 @@ export const templateVersionEditorMachine = createMachine(
publishingVersion: {
tags: "loading",
entry: ["clearPublishingError"],
entry: ["clearPublishingError", "clearLastSuccessfulPublishedVersion"],
invoke: {
id: "publishingVersion",
src: "publishingVersion",
@@ -119,6 +121,7 @@ export const templateVersionEditorMachine = createMachine(
},
onDone: {
actions: ["assignLastSuccessfulPublishedVersion"],
target: ["idle"],
},
},
@@ -256,6 +259,12 @@ export const templateVersionEditorMachine = createMachine(
assignBuild: assign({
version: (_, event) => event.data,
}),
assignLastSuccessfulPublishedVersion: assign({
lastSuccessfulPublishedVersion: (ctx) => ctx.version,
lastSuccessfulPublishIsDefault: (_, event) =>
event.data.isActiveVersion,
version: () => undefined,
}),
addBuildLog: assign({
buildLogs: (context, event) => {
const previousLogs = context.buildLogs ?? []
@@ -285,6 +294,9 @@ export const templateVersionEditorMachine = createMachine(
publishingError: (_, event) => event.data,
}),
clearPublishingError: assign({ publishingError: (_) => undefined }),
clearLastSuccessfulPublishedVersion: assign({
lastSuccessfulPublishedVersion: (_) => undefined,
}),
assignMissingVariables: assign({
missingVariables: (_, event) => event.data,
}),
@@ -420,6 +432,8 @@ export const templateVersionEditorMachine = createMachine(
})
: Promise.resolve(),
])
return { isActiveVersion }
},
loadMissingVariables: ({ version }) => {
if (!version) {