2. Drafts, publishing and history
Level: procedure. This page describes the life of a configuration: what exactly Save draft does, what Publish changes, how to go back. The previous page is Concepts and coordinates, the next one is Configuration format.
The three states of a version
Every save produces a numbered version (v1, v2, v3…). Each version is in one of three states, and one single rule governs everything: for each app, in each environment, there is at most one published version, and it is the only one the apps receive.
| State | In the dashboard | Meaning |
|---|---|---|
| draft | gray badge vN draft next to the app's name | It can be edited. No app receives it. |
| published | green badge vN published | It can no longer be edited. It is the one every app of the environment receives. It carries who published it and when. |
| archived | status archived in the history | Withdrawn: it is not served, compared, restored or published. It stays for the record. |
The life of a configuration, step by step:
- A new app has no version. Save draft creates
v1 draft; every further Save draft updates it and it staysv1 draft. - Publish makes it
v1 published. - Save draft creates
v2 draft; meanwhile the apps keep receivingv1. - Publish makes
v2 published;v1goes back to draft. - Delete archives every version: the apps no longer receive anything.
Saving a draft
Save draft is the only action that writes the document, and it behaves in three ways depending on what is already there:
| Situation | Effect |
|---|---|
| The app has no configuration yet | Creates v1 as a draft. |
| The current version is a draft | Overwrites it: same version number, no new row in the history. |
| The current version is published | Leaves it alone. It creates a new draft vN+1 with your content; the apps keep receiving the published one. |
The third case is the one that matters: a published version is never edited, so working on a configuration already in use is not risky. You edit it, save it, try it with the Tester, and meanwhile the apps keep receiving the old one until you publish.
Saving is tolerant. It only checks that the document is a JSON object of the expected shape: it accepts keys that are not part of the format, incomplete blocks, empty fields. That is on purpose, because a draft is work in progress, and it has a consequence worth knowing: much more can be saved than can be published. Validation shows the problems as you write (page 5), but it does not stop you from saving.
The button is disabled when there is nothing to save (no change since the last save) and for whoever does not have at least the Editor role.
Discarding changes. To the right of Save draft, Discard changes throws away what you wrote after the last save and puts the editor back on the last saved draft (for an app never saved, on the starting template). It asks first (Discard your changes?), because that text cannot be had back: Keep editing leaves everything as it is. This button too is enabled only when there are unsaved changes, and for whoever has at least the Editor role.
Unsaved changes are not lost. If you go to another page of the dashboard or switch organization, a window (Unsaved changes) asks, before going, whether to save them as a draft (Save draft) or discard them (Discard changes); if you close it you stay where you are, with your changes. If the save is refused you stay on the configuration, and the editor says why. For the exits the window cannot stop (a reloaded page, a closed tab, an expired session) the browser keeps a copy of what you have not saved: when you open the configuration again, the Unsaved changes found box offers Restore changes or Discard. The copy stays on that browser only.
Two sessions on the same configuration. If someone (a colleague, or you in another tab) saves the configuration after you opened it, the editor says so (A newer version was saved) and your save will be refused: copy what you want to keep, then press Reload latest version.
Publishing
Publish makes the saved version the one the apps receive. It is the action that reaches furthest, because it concerns every app of that environment, production included: that is why it asks for a confirmation (Publish configuration).
The button is active only when all these conditions hold:
- a saved version exists (an app just opened and never saved has nothing to publish);
- there are no unsaved changes in the editor;
- validation reports no problems;
- you have at least the Editor role.
When you confirm, Squiddy checks everything again, strictly. Here the tolerance of saving ends: publishing stops if it finds problems or keys the format does not know (appUpdates instead of appUpdate, typ instead of type). The error lists the exact fields. There is no half publishing: either everything goes through, or the published version stays the one before.
What happens at the moment of publishing:
- the version receives its
configVersion, before the check: if it is still the one of the published version, its last part goes up by one (1.0.3→1.0.4); if you changed it by hand, or it is the first publishing, yours stays; empty becomes1.0.0. The complete rules, with the special cases, are on page 3. It is the only change publishing makes to the document; - the version published before, if there was one, goes back to draft: the apps no longer receive it, but it stays in the history and can be restored;
- the new version becomes published, with who published it and when;
- the apps receive the new configuration at their next request;
- the publishing ends up in the audit log with the version published before and the one published now, each with its
configVersion.
After publishing the editor shows the new configVersion, in the text and in the line above the tabs, and the notification says how it was decided: “Version 6 published: configVersion went up by itself to 1.0.4.”, or “Version 6 published with configVersion 2.0.0.” if you chose it, or “Version 6 published: configVersion was empty and became 1.0.0.”. If the last part is not a number (1.0.0-beta) the value stays the one already published, and a yellow warning, which stays until you close it, asks you to change it in the JSON before the next publishing.
Publish and notify. Next to Publish there is Publish and notify, which right after publishing sends the push update, so that the installed apps check now instead of at their next check. It asks for the same conditions as Publish, plus the app's Firebase credential and an active API key in the environment; the push update leaves only if publishing succeeded, and if the push update does not leave, the publishing stays anyway. The details are on page 7.
The apps that ask to receive the configuration only if it has changed (with the configFingerprint fingerprint, as Squiddy's SDK does) need to do nothing special: the fingerprint changes because the configuration has changed, so they receive the complete configuration instead of the “not modified” answer.
If two people publish the same app at the same instant, one of the two receives “Another change was published at the same time. Reload and try again.”. There are never two published versions at once, not even for an instant.
History and going back
The History tab lists every version, from the most recent, with the columns Version, Status, Updated and Published (who published it and when). The most recent version that is not archived carries the word Current. The list loads a page at a time: when you reach the bottom the older versions appear by themselves, and the Load older versions button does the same from the keyboard.
Restoring. Restore on an earlier version does not publish: it takes that content and makes it the current working draft. The history is not rewritten: a new version is born, and the notification says so (“Version 4 restored as the working draft.”). Going back completely therefore takes two deliberate steps: Restore, then Publish. Restore is not there on the current version (there is nothing to bring back) nor on an archived one.
Comparing. In the Compare versions tab, next to History, pick a Base version and a version in Compare with, and you see the two JSON documents side by side with the differences. It is the way to answer “what changed in yesterday's publishing” without reading two whole documents again. Archived versions cannot be compared. The two menus offer the versions loaded so far: scrolling a menu to the bottom, or Load older versions, brings in the older ones too. The button at the end of the menus' row opens the comparison in Full screen, with the menus still at hand and the two documents as tall as the screen; the same button, or Esc, closes it.
The history and the comparison are seen by every member, Viewers included; Restore only from Editor upwards.
Deleting an app's configuration
The red button with the bin in the editor, Delete app configuration, archives every version of the app in that environment, after a confirmation. Effects:
- the app leaves the list of the environment's configurations;
- the apps no longer receive the configuration: from the next request they receive the “configuration not found” error (code
5003), not an empty answer. An app that in that case does not use the last configuration saved on the device is left without a configuration; - the history is kept: the versions stay, archived;
- if you create the same app again in the future, the numbering of the versions picks up where it left off (archived versions count), so the new draft will not be called v1.
So it is not a deletion: it is a withdrawal from service, which stays on record. To stop an app without taking its configuration away all of a sudden, the right way is a maintenance block with halt (recipe on page 6).