Repository navigation
Expand file tree
/
Copy pathsavedToCustomization.tsx
More file actions
53 lines (46 loc) · 2.32 KB
/
Copy pathsavedToCustomization.tsx
File metadata and controls
53 lines (46 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
/**
* objectstack ADR-0146 D3 — the one sentence that names where a customization
* of a read-only base is saved: "Saved to BASE's customizations". The
* pending-changes sheet (`DraftChangesPanel`) draws it under its title, and
* the Studio item header draws it on its note line (objectstack#29691), so
* both say the same words from the same key.
*
* Its own module, not the sheet's: many Studio tests replace the whole
* `DraftChangesPanel` module with a stub, and the header must not depend on
* what such a stub happens to export.
*/
import { useObjectTranslation } from '@object-ui/i18n';
type Translate = ReturnType<typeof useObjectTranslation>['t'];
export function savedToCustomizationText(t: Translate, baseLabel: string): string {
return t('preview.changes.savedToCustomization', {
package: baseLabel,
defaultValue: 'Saved to {{package}}’s customizations',
});
}
/**
* The command that moves a customization to another environment, spelled
* verbatim in every language: it is typed, not read (objectstack#30119).
*/
export const PACKAGE_EXPORT_COMMAND = 'os package export';
/**
* objectstack#30119 (ADR-0146 D2) — the sentence under "Saved to BASE's
* customizations" in the pending-changes sheet: the changes live in this
* environment's database as items of `pairId`, the `<base>.custom` package
* the server answered for the base, not in the project's source, and only
* {@link PACKAGE_EXPORT_COMMAND} takes them to another environment. True on
* every deployment, so it is not switched by the served `environment`.
*/
export function customizationEnvironmentText(t: Translate, pairId: string): string {
return t('preview.changes.customizationEnvironment', {
pair: pairId,
command: PACKAGE_EXPORT_COMMAND,
defaultValue:
'These changes are kept in this environment’s database as items of {{pair}}, not in your project’s source. They reach another environment only through {{command}}.',
});
}
/** {@link savedToCustomizationText} as an element, for the Studio item header's note line. */
export function SavedToCustomizationNote({ baseLabel, testId }: { baseLabel: string; testId?: string }) {
const { t } = useObjectTranslation();
return <span data-testid={testId}>{savedToCustomizationText(t, baseLabel)}</span>;
}