Skip to content

Commit 1e5ffc0

Browse files
author
Feroze Mohideen
authored
Add auto rollback enabled flag to FE (#4229)
1 parent 8d57c45 commit 1e5ffc0

File tree

7 files changed

+41
-12
lines changed

7 files changed

+41
-12
lines changed

dashboard/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"@babel/preset-typescript": "^7.15.0",
103103
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
104104
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
105-
"@porter-dev/api-contracts": "^0.2.97",
105+
"@porter-dev/api-contracts": "^0.2.98",
106106
"@testing-library/jest-dom": "^4.2.4",
107107
"@testing-library/react": "^9.3.2",
108108
"@testing-library/user-event": "^7.1.2",

dashboard/src/lib/porter-apps/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
AutoRollback,
23
Build,
34
EFS,
45
HelmOverrides,
@@ -99,6 +100,12 @@ export const clientAppValidator = z.object({
99100
build: buildValidator,
100101
helmOverrides: z.string().optional(),
101102
requiredApps: z.object({ name: z.string() }).array().default([]),
103+
autoRollback: z
104+
.object({
105+
enabled: z.boolean(),
106+
readOnly: z.boolean().optional(),
107+
})
108+
.default({ enabled: false, readOnly: false }),
102109
});
103110
export type ClientPorterApp = z.infer<typeof clientAppValidator>;
104111

@@ -321,6 +328,9 @@ export function clientAppToProto(data: PorterAppFormData): PorterApp {
321328
requiredApps: app.requiredApps.map((app) => ({
322329
name: app.name,
323330
})),
331+
autoRollback: new AutoRollback({
332+
enabled: app.autoRollback.enabled,
333+
}),
324334
})
325335
)
326336
.with(
@@ -347,6 +357,9 @@ export function clientAppToProto(data: PorterAppFormData): PorterApp {
347357
requiredApps: app.requiredApps.map((app) => ({
348358
name: app.name,
349359
})),
360+
autoRollback: new AutoRollback({
361+
enabled: app.autoRollback.enabled,
362+
}),
350363
})
351364
)
352365
.exhaustive();
@@ -497,6 +510,10 @@ export function clientAppFromProto({
497510
requiredApps: proto.requiredApps.map((app) => ({
498511
name: app.name,
499512
})),
513+
autoRollback: {
514+
enabled: proto.autoRollback?.enabled ?? true, // enabled by default if not found in proto
515+
readOnly: false, // TODO: detect autorollback from porter.yaml
516+
},
500517
};
501518
}
502519

@@ -539,6 +556,10 @@ export function clientAppFromProto({
539556
requiredApps: proto.requiredApps.map((app) => ({
540557
name: app.name,
541558
})),
559+
autoRollback: {
560+
enabled: proto.autoRollback?.enabled ?? true, // enabled by default if not found in proto
561+
readOnly: false, // TODO: detect autorollback from porter.yaml
562+
},
542563
};
543564
}
544565

dashboard/src/main/home/app-dashboard/app-view/AppDataContainer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
239239
await api.updateApp(
240240
"<token>",
241241
{
242-
b64_app_proto: btoa(validatedAppProto.toJsonString()),
242+
b64_app_proto: btoa(
243+
validatedAppProto.toJsonString({ emitDefaultValues: true })
244+
),
243245
deployment_target_id: deploymentTarget.id,
244246
variables,
245247
secrets,

dashboard/src/main/home/app-dashboard/create-app/CreateApp.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { withRouter, type RouteComponentProps } from "react-router";
99
import styled from "styled-components";
1010
import { z } from "zod";
1111

12+
import CreateDeploymentTargetModal from "components/CreateDeploymentTargetModal";
1213
import Back from "components/porter/Back";
1314
import Button from "components/porter/Button";
1415
import Container from "components/porter/Container";
@@ -45,7 +46,6 @@ import { Context } from "shared/Context";
4546
import { valueExists } from "shared/util";
4647
import web from "assets/web.png";
4748

48-
import CreateDeploymentTargetModal from "components/CreateDeploymentTargetModal";
4949
import ImageSettings from "../image-settings/ImageSettings";
5050
import GithubActionModal from "../new-app-flow/GithubActionModal";
5151
import SourceSelector from "../new-app-flow/SourceSelector";
@@ -345,7 +345,11 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
345345
"<token>",
346346
{
347347
deployment_target_id: deploymentTargetID,
348-
b64_app_proto: btoa(app.toJsonString()),
348+
b64_app_proto: btoa(
349+
app.toJsonString({
350+
emitDefaultValues: true,
351+
})
352+
),
349353
secrets,
350354
variables,
351355
is_env_override: true,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ require (
8383
github.com/matryer/is v1.4.0
8484
github.com/nats-io/nats.go v1.24.0
8585
github.com/open-policy-agent/opa v0.44.0
86-
github.com/porter-dev/api-contracts v0.2.97
86+
github.com/porter-dev/api-contracts v0.2.98
8787
github.com/riandyrn/otelchi v0.5.1
8888
github.com/santhosh-tekuri/jsonschema/v5 v5.0.1
8989
github.com/stefanmcshane/helm v0.0.0-20221213002717-88a4a2c6e77d

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
15251525
github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw=
15261526
github.com/porter-dev/api-contracts v0.2.97 h1:JXxg/b0R8hL2IurJAnSakRRSHx4zT9ZQDCqe1gvR0Uc=
15271527
github.com/porter-dev/api-contracts v0.2.97/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
1528+
github.com/porter-dev/api-contracts v0.2.98 h1:bfOmR9SfspEDkO72TF+YewGKvIpW9ZhcC6Nzpt1I9EI=
1529+
github.com/porter-dev/api-contracts v0.2.98/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
15281530
github.com/porter-dev/switchboard v0.0.3 h1:dBuYkiVLa5Ce7059d6qTe9a1C2XEORFEanhbtV92R+M=
15291531
github.com/porter-dev/switchboard v0.0.3/go.mod h1:xSPzqSFMQ6OSbp42fhCi4AbGbQbsm6nRvOkrblFeXU4=
15301532
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=

0 commit comments

Comments
 (0)