Skip to content

Commit c631160

Browse files
committed
Merge branch 'main' into release-05-12-25.staging
2 parents 8a4d7d7 + cb9619e commit c631160

File tree

6 files changed

+71
-3
lines changed

6 files changed

+71
-3
lines changed

apps/builder/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ POSTGREST_API_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIs
3434
# PUBLISHER_ENDPOINT=https://publisher.webstudio.is
3535
# PUBLISHER_TOKEN=
3636

37+
# Username and password displayed in wstd domain settings
38+
# STAGING_USERNAME=admin
39+
# STAGING_PASSWORD=webstudio
40+
3741
# Base origin for accessing user-generated build (canvas / preview / etc)
3842
# Should contain protocol and host (e.g. https://example.com)
3943
# Will be detected automatically in development environments like localhost or preview deployment

apps/builder/app/builder/builder.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {
3333
$isContentMode,
3434
$userPlanFeatures,
3535
subscribeModifierKeys,
36+
$stagingUsername,
37+
$stagingPassword,
3638
} from "~/shared/nano-states";
3739
import { $settings, type Settings } from "./shared/client-settings";
3840
import { builderUrl, getCanvasUrl } from "~/shared/router-utils";
@@ -224,6 +226,8 @@ export type BuilderProps = {
224226
authPermit: AuthPermit;
225227
authTokenPermissions: TokenPermissions;
226228
userPlanFeatures: UserPlanFeatures;
229+
stagingUsername: string;
230+
stagingPassword: string;
227231
};
228232

229233
export const Builder = ({
@@ -232,6 +236,8 @@ export const Builder = ({
232236
authPermit,
233237
userPlanFeatures,
234238
authTokenPermissions,
239+
stagingUsername,
240+
stagingPassword,
235241
}: BuilderProps) => {
236242
useMount(initBuilderApi);
237243

@@ -241,6 +247,8 @@ export const Builder = ({
241247
$authToken.set(authToken);
242248
$userPlanFeatures.set(userPlanFeatures);
243249
$authTokenPermissions.set(authTokenPermissions);
250+
$stagingUsername.set(stagingUsername);
251+
$stagingPassword.set(stagingPassword);
244252

245253
const controller = new AbortController();
246254

apps/builder/app/builder/features/topbar/publish.tsx

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import {
5757
$project,
5858
$publishedOrigin,
5959
$userPlanFeatures,
60+
$stagingUsername,
61+
$stagingPassword,
6062
} from "~/shared/nano-states";
6163
import {
6264
$publishDialog,
@@ -72,6 +74,7 @@ import {
7274
GearIcon,
7375
UpgradeIcon,
7476
HelpIcon,
77+
InfoCircleIcon,
7578
} from "@webstudio-is/icons";
7679
import { AddDomain } from "./add-domain";
7780
import { humanizeString } from "~/shared/string-utils";
@@ -100,6 +103,8 @@ const ChangeProjectDomain = ({
100103
const id = useId();
101104
const publishedOrigin = useStore($publishedOrigin);
102105
const selectedPagePath = useStore($selectedPagePath);
106+
const stagingUsername = useStore($stagingUsername);
107+
const stagingPassword = useStore($stagingPassword);
103108

104109
const [domain, setDomain] = useState(project.domain);
105110
const [error, setError] = useState<string>();
@@ -201,9 +206,11 @@ const ChangeProjectDomain = ({
201206
</Grid>
202207
}
203208
>
204-
<Grid gap={3}>
205-
<Grid gap={1}>
206-
<Label htmlFor={id}>Domain:</Label>
209+
<Grid gap={2}>
210+
<Grid flow="column" align="center" gap={2}>
211+
<Label htmlFor={id} css={{ width: theme.spacing[20] }}>
212+
Domain:
213+
</Label>
207214
<InputField
208215
text="mono"
209216
id={id}
@@ -231,6 +238,47 @@ const ChangeProjectDomain = ({
231238
/>
232239
{error !== undefined && <Text color="destructive">{error}</Text>}
233240
</Grid>
241+
{stagingUsername && (
242+
<Grid flow="column" align="center" gap={2}>
243+
<Label
244+
htmlFor={`${id}-username`}
245+
css={{ width: theme.spacing[20] }}
246+
>
247+
Username:
248+
</Label>
249+
<InputField
250+
text="mono"
251+
id={`${id}-username`}
252+
type="text"
253+
value={stagingUsername}
254+
readOnly
255+
/>
256+
</Grid>
257+
)}
258+
{stagingPassword && (
259+
<Grid flow="column" align="center" gap={2}>
260+
<Flex align="center" gap={1} css={{ width: theme.spacing[20] }}>
261+
<Label htmlFor={`${id}-password`}>Password:</Label>
262+
<Tooltip
263+
content="This password is read-only and cannot be changed. It is the same for every user. This prevents phishing attacks."
264+
variant="wrapped"
265+
>
266+
<InfoCircleIcon
267+
tabIndex={0}
268+
style={{ flexShrink: 0 }}
269+
color={rawTheme.colors.foregroundSubtle}
270+
/>
271+
</Tooltip>
272+
</Flex>
273+
<InputField
274+
text="mono"
275+
id={`${id}-password`}
276+
type="text"
277+
value={stagingPassword}
278+
readOnly
279+
/>
280+
</Grid>
281+
)}
234282
</Grid>
235283
</CollapsibleDomainSection>
236284
);

apps/builder/app/env/env.server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ const env = {
5656

5757
PUBLISHER_HOST: process.env.PUBLISHER_HOST || "wstd.work",
5858

59+
STAGING_USERNAME: process.env.STAGING_USERNAME ?? "admin",
60+
STAGING_PASSWORD: process.env.STAGING_PASSWORD ?? "webstudio",
61+
5962
FEATURES: process.env.FEATURES ?? "",
6063

6164
// current user plan features (default)

apps/builder/app/routes/_ui.(builder).tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ export const loader = async (loaderArgs: LoaderFunctionArgs) => {
201201
authTokenPermissions,
202202
authPermit,
203203
userPlanFeatures,
204+
stagingUsername: env.STAGING_USERNAME,
205+
stagingPassword: env.STAGING_PASSWORD,
204206
} as const,
205207
{
206208
headers,

apps/builder/app/shared/nano-states/misc.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ export const $authTokenPermissions = atom<TokenPermissions>({
334334

335335
export const $authToken = atom<string | undefined>(undefined);
336336

337+
export const $stagingUsername = atom<string | undefined>();
338+
export const $stagingPassword = atom<string | undefined>();
339+
337340
export const $isContentModeAllowed = computed(
338341
[$authToken, $userPlanFeatures],
339342
(token, userPlanFeatures) => {

0 commit comments

Comments
 (0)