Skip to content

Commit

Permalink
Merge pull request #118 from RBND-studio/dev
Browse files Browse the repository at this point in the history
Merge dev
  • Loading branch information
VojtechVidra committed Feb 26, 2024
2 parents e792aea + c2eee4e commit c9fb6ff
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ type Props = {
};

const CDNSnippet: FC<Props> = async ({ projectId }) => {
const latestPackageJson = await fetch("https://www.unpkg.com/@flows/js@latest/package.json").then(
(res) => res.json() as Promise<{ version?: string } | undefined>,
);
const latestPackageJson = await fetch("https://unpkg.com/@flows/js@latest/package.json", {
cache: "no-store",
}).then((res) => res.json() as Promise<{ version?: string } | undefined>);
const latestVersion = latestPackageJson?.version;

return (
Expand All @@ -25,17 +25,17 @@ const CDNSnippet: FC<Props> = async ({ projectId }) => {
</Text>
<CodeHighlight className={css({ margin: "0!", width: "100%" })}>
<pre>
<code className="index.html">{`<script src="https://cdn.jsdelivr.net/npm/@flows/js@${latestVersion}/dist/cloud/index.global.js" />`}</code>
<code className="index.html">{`<script defer src="https://cdn.jsdelivr.net/npm/@flows/js@${latestVersion}/dist/index.global.js"></script>`}</code>
</pre>
</CodeHighlight>
<Text>
After that start using Flows by calling <strong>window.Flows.init</strong> anywhere in your
code to initialize the script.
After that start using Flows by calling <strong>flows.init()</strong> anywhere in your code
to initialize the script.
</Text>
<CodeHighlight className={css({ margin: "0!", width: "100%" })}>
<pre>
<code className="index.html">{`<script>
FlowsJS.init({
flows.init({
projectId: "${projectId}",
// Optionally define local flows.
flows: [],
Expand Down Expand Up @@ -72,7 +72,7 @@ init({
);
};

export const InstalInstructions: FC<Props> = ({ projectId }) => {
export const InstallInstructions: FC<Props> = ({ projectId }) => {
return (
<Flex gap="space12">
<NumberCircle>1</NumberCircle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Flex } from "@flows/styled-system/jsx";
import { Text } from "ui";

import { CreateFlow } from "./create-flow";
import { InstalInstructions } from "./instal-instructions";
import { InstallInstructions } from "./install-instructions";
import { LearnMore } from "./learn-more";

type Props = {
Expand All @@ -18,7 +18,7 @@ export default function ProjectSettingsPage({ params }: Props): JSX.Element {
Here&apos;s how to get up and running with Flows in two easy steps.
</Text>
</Flex>
<InstalInstructions organizationId={params.organizationId} projectId={params.projectId} />
<InstallInstructions organizationId={params.organizationId} projectId={params.projectId} />
<CreateFlow organizationId={params.organizationId} projectId={params.projectId} />
<LearnMore />
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export const TemplatePreview: FC = () => {
useEffect(() => {
if (firstRender) return;
void init({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- internal option
// @ts-expect-error
validate: false,
rootElement: "#template-preview-root",
flows: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export const InviteForm: FC<Props> = ({ organizationId, projectId }) => {
Send invites
</Button>
<Button asChild variant="secondary">
<Link href={routes.project({ organizationId, projectId })}>Continue alone</Link>
<Link href={routes.projectGettingStarted({ organizationId, projectId })}>
Continue alone
</Link>
</Button>
</Flex>
</Flex>
Expand Down
3 changes: 2 additions & 1 deletion apps/app/src/components/sidebar/settings-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const SettingsMenu: FC = () => {
? [
{
label: "Personal settings",
href: routes.userSettings({ userId: auth.user.id }),
// TODO: enable when user settings are implemented
// href: routes.userSettings({ userId: auth.user.id }),
},
]
: []),
Expand Down
4 changes: 3 additions & 1 deletion apps/backend/src/flows/flows.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ export class FlowsService {
JSON.stringify(createVersionData({ compareVersion: flow.publishedVersion }));
const changedFromDraft =
JSON.stringify(updatedVersionData) !==
JSON.stringify(createVersionData({ compareVersion: flow.draftVersion }));
JSON.stringify(
createVersionData({ compareVersion: flow.draftVersion ?? flow.publishedVersion }),
);

const currentDrafts = await (async () => {
if (!changedFromPublished) {
Expand Down
4 changes: 1 addition & 3 deletions apps/backend/src/lib/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const verifyVersion = (version: string): string => {
};

const getSdkFile = (version: string, path: string): Promise<string> =>
fetch(`https://cdn.jsdelivr.net/npm/@flows/js@${verifyVersion(version)}${path}`).then((res) =>
res.text(),
);
fetch(`https://unpkg.com/@flows/js@${verifyVersion(version)}${path}`).then((res) => res.text());

export const getDefaultCssMinVars = (version = "latest"): Promise<string> =>
getSdkFile(version, "/css.min/vars.css");
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/sdk/sdk.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export class CreateEventDto {

@IsString()
location: string;

@ApiProperty({ enum: EventTypeEnum })
@IsString()
type: EventType;
}

Expand Down
8 changes: 4 additions & 4 deletions apps/docs/src/pages/getting-started/install-flows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useData } from "nextra/data";
import { Tabs, Pre, Code } from "nextra/components";

export const getServerSideProps = () => {
return fetch("https://www.unpkg.com/@flows/js@latest/package.json")
return fetch("https://unpkg.com/@flows/js@latest/package.json")
.then((res) => res.json())
.then((pkgJson) => ({
props: {
Expand All @@ -21,7 +21,7 @@ export const getServerSideProps = () => {
export const LatestScript = ({children}) => {
const {version} = useData()

return <Pre hasCopyCode data-language="html" data-theme="default"><Code><span className="line"><span style={{color:"var(--shiki-color-text)"}}>&lt;</span><span style={{color:"var(--shiki-token-string-expression)"}}>script</span><span style={{color:"var(--shiki-color-text)"}}> </span><span style={{color:"var(--shiki-token-function)"}}>src</span><span style={{color:"var(--shiki-token-keyword)"}}>=</span><span style={{color:"var(--shiki-token-string-expression)"}}>"https://cdn.jsdelivr.net/npm/@flows/js@{version}/dist/cloud/index.global.js"</span><span style={{color:"var(--shiki-color-text)"}}>&gt;&lt;/</span><span style={{color:"var(--shiki-token-string-expression)"}}>script</span><span style={{color:"var(--shiki-color-text)"}}>&gt;</span></span></Code></Pre>
return <Pre hasCopyCode data-language="html" data-theme="default"><Code><span className="line"><span style={{color:"var(--shiki-color-text)"}}>&lt;</span><span style={{color:"var(--shiki-token-string-expression)"}}>script</span> <span style={{color:"var(--shiki-token-function)"}}>defer</span> <span style={{color:"var(--shiki-token-function)"}}>src</span><span style={{color:"var(--shiki-token-keyword)"}}>=</span><span style={{color:"var(--shiki-token-string-expression)"}}>"https://cdn.jsdelivr.net/npm/@flows/js@{version}/dist/index.global.js"</span><span style={{color:"var(--shiki-color-text)"}}>&gt;&lt;/</span><span style={{color:"var(--shiki-token-string-expression)"}}>script</span><span style={{color:"var(--shiki-color-text)"}}>&gt;</span></span></Code></Pre>
}

# Install Flows
Expand All @@ -34,11 +34,11 @@ Copy the snippet bellow and paste it within the `<head>` tag of your product - i

<LatestScript />

When you're done, you can start using Flows by calling `window.Flows` anywhere in your code. You can find the `projectId` in your project settings.
When you're done, you can start using Flows by calling `flows.init()` anywhere in your code. You can find the `projectId` in your project settings.

```html
<script>
window.FlowsJS.init({
flows.init({
// Insert your Flows Cloud projectId
projectId: "xxxx",
// Optionally define local flows.
Expand Down

0 comments on commit c9fb6ff

Please sign in to comment.