Skip to content

Commit 865a7dd

Browse files
committed
feat: add info-only local instance update
1 parent 26671dc commit 865a7dd

2 files changed

Lines changed: 51 additions & 18 deletions

File tree

src/base/components/instanceCreator.js

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { typedQuerySelector } from "../scripts/dom.js";
1616
* @property {string} [tag]
1717
* @property {string} [enableInstanceTelemetry]
1818
* @property {string} [enableElevatedAccess]
19+
* @property {string} [runContainerUpdate]
1920
*
2021
* @typedef {Object} ExistingInstanceDetails
2122
* @property {string} id
@@ -154,11 +155,16 @@ export class InstanceCreator extends HTMLElement {
154155
}
155156
form {
156157
display: grid;
157-
row-gap: var(--sl-spacing-medium);
158+
row-gap: var(--sl-spacing-2x-large);
158159
159160
align-content: flex-start;
160161
}
161162
163+
instance-info, container-settings, form-footer {
164+
display: grid;
165+
row-gap: var(--sl-spacing-medium);
166+
}
167+
162168
sl-button,
163169
sl-icon-button {
164170
--sl-border-width: 2px;
@@ -237,24 +243,39 @@ export class InstanceCreator extends HTMLElement {
237243
${infoSection}
238244
<div>
239245
<form id="instance-creator-form">
240-
<div class="columns columns-2 side-right align-bottom">
241-
<sl-input name="label" label="Label" required></sl-input>
242-
<sl-color-picker name="color" label="Color" format="hsl" opacity="true"></sl-color-picker>
243-
</div>
244-
${!isLocalInstanceCreator ? `<sl-input name="origin" label="Origin" required></sl-input>` : ""}
246+
<instance-info>
247+
<div class="columns columns-2 side-right align-bottom">
248+
<sl-input name="label" label="Label" required></sl-input>
249+
<sl-color-picker name="color" label="Color" format="hsl" opacity="true"></sl-color-picker>
250+
</div>
251+
${!isLocalInstanceCreator ? `<sl-input name="origin" label="Origin" required></sl-input>` : ""}
252+
</instance-info>
253+
254+
${
255+
isLocalInstanceCreator
256+
? `<container-settings>
257+
<sl-input name="tag" label="Tag" value="latest" required></sl-input>
258+
<sl-checkbox name="enableInstanceTelemetry" checked help-text="When enabled, a periodical process will send anonymous data about this instance.">
259+
Enable instance telemetry
260+
</sl-checkbox>
261+
<sl-details summary="Advanced options">
262+
<sl-checkbox name="enableElevatedAccess" help-text="Docker commands will run as super user, with elevated privileges. You will be prompted by the system to allow the actions.">
263+
Enable elevated access
264+
</sl-checkbox>
265+
</sl-details>
266+
</container-settings>`
267+
: ""
268+
}
269+
270+
245271
${
246-
isLocalInstanceCreator
247-
? `<sl-input name="tag" label="Tag" value="latest" required></sl-input>
248-
<sl-checkbox name="enableInstanceTelemetry" checked help-text="When enabled, a periodical process will send anonymous data about this instance.">
249-
Enable instance telemetry
250-
</sl-checkbox>
251-
<sl-details summary="Advanced options">
252-
<sl-checkbox name="enableElevatedAccess" help-text="Docker commands will run as super user, with elevated privileges. You will be prompted by the system to allow the actions.">
253-
Enable elevated access
254-
</sl-checkbox>
255-
</sl-details>`
272+
this._instance?.localInstance
273+
? `<form-footer>
274+
<sl-checkbox name="runContainerUpdate" help-text='When enabled, performs a Penpot upgrade (if tag is set to "latest") and updates container settings (tag, telemetry).'>Run container update</sl-checkbox>
275+
</form-footer>`
256276
: ""
257277
}
278+
258279
</form>
259280
<div class="footer">
260281
<div>
@@ -428,8 +449,13 @@ export class InstanceCreator extends HTMLElement {
428449

429450
const formData = new FormData(form);
430451
/** @type {InstanceCreationDetails} */
431-
const { tag, enableInstanceTelemetry, enableElevatedAccess, ...instance } =
432-
Object.fromEntries(formData.entries());
452+
const {
453+
tag,
454+
enableInstanceTelemetry,
455+
enableElevatedAccess,
456+
runContainerUpdate,
457+
...instance
458+
} = Object.fromEntries(formData.entries());
433459
const { id: instanceId } = this._instance || {};
434460
const isLocalInstanceCreator = !instanceId || this._instance?.localInstance;
435461
const eventName = instanceId
@@ -445,6 +471,7 @@ export class InstanceCreator extends HTMLElement {
445471
tag,
446472
enableInstanceTelemetry,
447473
enableElevatedAccess,
474+
runContainerUpdate,
448475
},
449476
}),
450477
...(instanceId && { id: instanceId }),

src/process/instance.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const instanceFormSchema = z.object({
5151
tag: dockerTag,
5252
enableElevatedAccess: checkboxSchema,
5353
enableInstanceTelemetry: checkboxSchema,
54+
runContainerUpdate: checkboxSchema.optional(),
5455
})
5556
.optional(),
5657
});
@@ -252,8 +253,13 @@ ipcMain.handle(INSTANCE_EVENTS.UPDATE, async (_event, id, instance) => {
252253
tag: newTag,
253254
enableInstanceTelemetry,
254255
enableElevatedAccess,
256+
runContainerUpdate,
255257
} = localInstance;
256258

259+
if (!runContainerUpdate) {
260+
return;
261+
}
262+
257263
localInstances[id] = {
258264
...localInstances[id],
259265
tag: newTag,

0 commit comments

Comments
 (0)