Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uikit-playground): Adding Templates, Mutli Screen, Projects, Flow Diagram and Prototype #30059

Merged
merged 78 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
216b5cf
chore(uikit-playground): Fixed Prettier
intVivek Jun 10, 2023
a05b56b
feat(uikit-playground): Added Templates
intVivek Jun 10, 2023
869a232
chore(uikit-playground): Fixed padding in preview of payloads
intVivek Jun 10, 2023
cf38256
feat(uikit-playground): Add Home and protected layout
intVivek Jun 10, 2023
02ce030
feat(uikit-playground): Added Multi screen support
intVivek Jun 10, 2023
29df11b
fix(uikit-playground): Added Screens and flow btn
intVivek Jun 10, 2023
271aab6
refactor(uikit-playground): Uikit and surface Renderer
intVivek Jun 10, 2023
8a2fff2
chores(uikit-playground): revamp Reactflow and screen selector
intVivek Jun 10, 2023
e4fd1a4
refactor(uikit-playground): Fix Types in context
intVivek Jun 11, 2023
acd21b3
fix(uikit-playground): Added Prettier
intVivek Jun 13, 2023
73b405c
feat(uikit-playground): Added context for "projects"
intVivek Jun 18, 2023
74d31dc
feat(uikit-playground): Added projects ui
intVivek Jul 8, 2023
85b1423
fix(uikit-playground): Fixed layout
intVivek Jul 8, 2023
1cc1008
chore(uikit-playground): Fixed routing
intVivek Jul 8, 2023
0399082
refactor(uikit-playground): Added project specific routes
intVivek Jul 9, 2023
2d87331
refactor(uikit-playground): Moved Edit Menu
intVivek Jul 10, 2023
342196e
feat(uikik-playground): Added ContextualBar
intVivek Jul 10, 2023
05cb1f5
fix(uikit-playground): Saving edges state
intVivek Jul 12, 2023
d15af3e
Fix(uikit-playground): preserve flow edges after reorder from dnd
intVivek Jul 15, 2023
8f3494a
fix(Uikit-playground): fix syntax highlighting in codemirror
intVivek Jul 16, 2023
c91807b
fix(Uikit-playground): fix contextual bar
intVivek Jul 16, 2023
6997038
refactor(uikit-playground): added useNodesAndEdges hook
intVivek Jul 23, 2023
29c49a4
fix(uikit-playground): added psition save on reactflow
intVivek Jul 23, 2023
63dcfae
chores(uikit-playground): fix lint warnings
intVivek Jul 23, 2023
8147170
feat(uikit-playground): added prototype
intVivek Jul 28, 2023
8411924
refactor(uikit-playground): Added flow and prototype in tabs
intVivek Jul 29, 2023
9aa2843
fix(uikit-playground): fix delete screen
intVivek Jul 30, 2023
341915e
feat(uikit-playground): added persist in localstorage
intVivek Jul 30, 2023
acb9107
chores(uikit-playground): fix delete project bug
intVivek Jul 31, 2023
d4af4d0
fix(uikit-playground): fix edges rerender
intVivek Aug 5, 2023
b38a9ea
chores(uikit-playground): fix ui bugs
intVivek Aug 6, 2023
cc13399
chores(uikit-playground): fix action preview
intVivek Aug 6, 2023
9acac55
fix rebase result :s
ggazzo Aug 8, 2023
4c40dd8
Merge branch 'develop' into intVivek/develop
intVivek Aug 8, 2023
dc09024
Merge branch 'develop' into intVivek/develop
intVivek Aug 8, 2023
bacae79
fix(uikit-playground): fix imports
intVivek Aug 8, 2023
38b20ec
Merge branch 'intVivek/develop' into develop
intVivek Aug 10, 2023
975e347
chores(uikit-playground): delete duplicate hook
intVivek Aug 10, 2023
718929e
Merge branch 'develop' into develop
intVivek Aug 10, 2023
4acdea9
refactor(uikit-playground): Moved Edit Menu
intVivek Aug 10, 2023
8df51d9
Merge branch 'RocketChat:develop' into develop
intVivek Aug 10, 2023
1135f38
Merge branch 'RocketChat:develop' into develop
intVivek Aug 13, 2023
1cf8d3d
fix(uikit-playground): fix trmplates to support surface
intVivek Aug 13, 2023
d9f1385
refactor(uikit-playground): moved surface inside payload
intVivek Aug 13, 2023
cbcbf72
Merge branch 'RocketChat:develop' into develop
intVivek Aug 14, 2023
f5dfbb6
fix(uikit-playground): fix dnd hover effect
intVivek Aug 14, 2023
e812e4b
Merge branch 'RocketChat:develop' into develop
intVivek Aug 15, 2023
a9dbb1c
fix(uikit-playground): fix code formatting
intVivek Aug 15, 2023
7b03e81
Merge branch 'RocketChat:develop' into develop
intVivek Aug 21, 2023
35c0cba
chores(uikit-playground): fix editor on screen change
intVivek Aug 21, 2023
c9eafb8
chores(uikit-playground): fix build
intVivek Aug 21, 2023
7ddb97b
Merge branch 'RocketChat:develop' into develop
intVivek Aug 25, 2023
5fe16e1
chore: Callback smol fixes (#29942)
KevLehman Aug 25, 2023
5a0fa24
fix: stop blinking Room not found before dm creation (#30157)
ggazzo Aug 25, 2023
74244d7
test: bump playwright (#30176)
ggazzo Aug 25, 2023
3306476
fix: Unread mark not showing (#30084)
gabriellsh Aug 25, 2023
3de6320
feat: [videoconf] mobile ringing (#30131)
pierre-lehnen-rc Aug 25, 2023
c30d2fa
chore: Update name or username from SAML even if one of them is undef…
matheusbsilva137 Aug 25, 2023
a5befba
chore: swap flaky current chats e2e tests for unit tests (#30182)
MartinSchoeler Aug 26, 2023
4e83b5a
chore(deps): Bump TypeScript to version 5.2 (#30180)
tassoevan Aug 26, 2023
1ac23f9
Merge branch 'RocketChat:develop' into develop
intVivek Aug 28, 2023
3366ad9
Merge branch 'RocketChat:develop' into develop
intVivek Aug 29, 2023
ab26019
Merge remote-tracking branch 'upstream/develop' into develop
intVivek Sep 1, 2023
cddb51d
Merge branch 'RocketChat:develop' into develop
intVivek Sep 1, 2023
67abbd7
Merge branch 'RocketChat:develop' into develop
intVivek Sep 4, 2023
525a2e0
Merge branch 'RocketChat:develop' into develop
intVivek Sep 6, 2023
b3fc116
Merge branch 'RocketChat:develop' into develop
intVivek Sep 8, 2023
019f2de
Merge branch 'RocketChat:develop' into develop
intVivek Sep 9, 2023
c049e5f
Merge branch 'RocketChat:develop' into develop
intVivek Sep 11, 2023
55b51a3
Merge branch 'RocketChat:develop' into develop
intVivek Sep 14, 2023
8ecf146
Merge branch 'RocketChat:develop' into develop
intVivek Sep 16, 2023
13c7198
Merge branch 'RocketChat:develop' into develop
intVivek Sep 22, 2023
a63feb9
Merge branch 'RocketChat:develop' into develop
intVivek Sep 23, 2023
92126bc
Merge branch 'RocketChat:develop' into develop
intVivek Sep 26, 2023
52227e1
Merge branch 'RocketChat:develop' into develop
intVivek Oct 1, 2023
61fbcfa
Merge branch 'RocketChat:develop' into develop
intVivek Oct 6, 2023
4053cf9
Merge branch 'RocketChat:develop' into develop
intVivek Oct 19, 2023
497bc9d
Merge remote-tracking branch 'origin/develop' into intVivek/develop
ggazzo Jan 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/uikit-playground/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": true
}
3 changes: 3 additions & 0 deletions packages/uikit-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@rocket.chat/fuselage": "^0.44.2",
"@rocket.chat/fuselage-hooks": "^0.33.0",
"@rocket.chat/fuselage-polyfills": "~0.31.25",
"@rocket.chat/fuselage-toastbar": "^0.31.25",
"@rocket.chat/fuselage-tokens": "~0.32.0",
"@rocket.chat/fuselage-ui-kit": "workspace:~",
"@rocket.chat/icons": "^0.33.0",
Expand All @@ -26,13 +27,15 @@
"@rocket.chat/ui-contexts": "workspace:~",
"codemirror": "^6.0.1",
"eslint4b-prebuilt": "^6.7.2",
"moment": "^2.29.4",
"rc-scrollbars": "^1.1.6",
"react": "^17.0.2",
"react-beautiful-dnd": "^13.1.1",
"react-dom": "^17.0.2",
"react-router-dom": "^6.11.2",
"react-split-pane": "^0.1.92",
"react-virtuoso": "^4.3.10",
"reactflow": "^11.7.2",
"use-subscription": "^1.8.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/uikit-playground/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
39 changes: 4 additions & 35 deletions packages/uikit-playground/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,7 @@
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}
#toastBarRoot{
position: fixed;
z-index: 9999;
}
62 changes: 55 additions & 7 deletions packages/uikit-playground/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,65 @@
import { useContext, useEffect } from 'react';
import './App.css';
import './_global.css';
import './cssVariables.css';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { ToastBarProvider } from '@rocket.chat/fuselage-toastbar';
import { BrowserRouter, Route, Routes } from 'react-router-dom';

import { HomeLayout } from './Components/Routes/HomeLayout';
import Playground from './Pages/Playground';
import SignInToWorkspace from './Pages/SignInSignUp';
import routes from './Routes/Routes';
import Home from './Pages/Home';
import { context, isMobileAction, isTabletAction } from './Context';
import { useMediaQueries } from '@rocket.chat/fuselage-hooks';
import { Box } from '@rocket.chat/fuselage';
import FlowDiagram from './Pages/FlowDiagram';
import { ProjectSpecificLayout } from './Components/Routes/ProjectSpecificLayout';
import Prototype from './Pages/Prototype';

function App() {
const { dispatch } = useContext(context);

const [isMobile, isTablet] = useMediaQueries(
'(max-width: 630px)',
'(max-width: 1050px)'
);

useEffect(() => {
dispatch(isMobileAction(isMobile));
}, [isMobile, dispatch]);

useEffect(() => {
dispatch(isTabletAction(isTablet));
}, [isTablet, dispatch]);
return (
<BrowserRouter>
<Routes>
<Route path='/' element={<Playground />} />
<Route path='*' element={<Playground />} />
</Routes>
</BrowserRouter>
<Box w="100vw" h="100vh" display="flex" flexDirection="column">
<ToastBarProvider>
<BrowserRouter>
<Routes>
<Route element={<HomeLayout />}>
<Route
path={routes.login}
element={<SignInToWorkspace route={routes.login} />}
/>
<Route
path={routes.signup}
element={<SignInToWorkspace route={routes.signup} />}
/>
</Route>
{/* <Route element={<ProtectedLayout />}> */}
<Route path={routes.home} element={<Home />} />
<Route path={routes.projectId} element={<ProjectSpecificLayout />}>
<Route path={routes.flow} element={<FlowDiagram />} />
<Route path={routes.project} element={<Playground />} />
<Route path={routes.prototype} element={<Prototype />} />
</Route>
<Route path={`*`} element={<Home />} />
{/* </Route> */}
</Routes>
</BrowserRouter>
</ToastBarProvider>
</Box>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* eslint-disable react-hooks/exhaustive-deps */
import type { Extension } from '@codemirror/state';
import { Box } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import { useEffect, useContext } from 'react';

import { updatePayloadAction, context } from '../../Context';
import useCodeMirror from '../../hooks/useCodeMirror';
import intendCode from '../../utils/intendCode';
import { IPayload } from '../../Context/initialState';
import useFormatCodeMirrorValue from '../../hooks/useFormatCodeMirrorValue';

type CodeMirrorProps = {
extensions?: Extension[];
};

const BlockEditor = ({ extensions }: CodeMirrorProps) => {
const {
state: { screens, activeScreen },
dispatch,
} = useContext(context);

const { editor, changes, setValue } = useCodeMirror(
extensions,
intendCode(screens[activeScreen]?.payload)
);
const debounceValue = useDebouncedValue(changes, 1500);

useFormatCodeMirrorValue(
(
parsedCode: IPayload,
prettifiedCode: { formatted: string; cursorOffset: number }
) => {
dispatch(
updatePayloadAction({
blocks: parsedCode.blocks,
surface: parsedCode.surface,
})
);
setValue(prettifiedCode.formatted, {
cursor: prettifiedCode.cursorOffset,
});
},
debounceValue
);

useEffect(() => {
if (!screens[activeScreen]?.changedByEditor) {
setValue(intendCode(screens[activeScreen]?.payload), {});
}
}, [
screens[activeScreen]?.payload.blocks,
screens[activeScreen]?.payload.surface,
activeScreen,
]);

useEffect(() => {
setValue(intendCode(screens[activeScreen]?.payload), {});
}, [activeScreen]);

return (
<>
<Box display="grid" height="100%" width={'100%'} ref={editor} />
</>
);
};

export default BlockEditor;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { json } from '@codemirror/lang-json';
import { EditorView } from 'codemirror';

import highlightStyle from './HighlightStyle';
import basicSetup from './basicSetup';
import jsonLinter from './jsonLinter';
// import payloadLinter from './payloadLinter';
import theme from './theme';

export const actionBlockExtensions = [
highlightStyle,
json(),
jsonLinter,
basicSetup,
// payloadLinter,
...theme,
];

export const actionPreviewExtensions = [
EditorView.contentAttributes.of({ contenteditable: 'false' }),
highlightStyle,
json(),
basicSetup,
...theme,
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const highLightStyle = () => {
{ tag: t.literal, color: 'var(--RCPG-primary-color)' },
{ tag: t.bool, color: 'var(--RCPG-tertary-color)' },
{ tag: t.number, color: 'var(--RCPG-secondary-color)' },
{ tag: t.null, color: 'var(--RCPG-tertary-color)' },
]);

return syntaxHighlighting(style);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { javascript } from '@codemirror/lang-javascript';

import highlightStyle from './HighlightStyle';
import basicSetup from './basicSetup';
import lint from './lint';
import theme from './theme';

const extensions = [highlightStyle, javascript(), lint, basicSetup, ...theme];
const extensions = [highlightStyle, javascript(), basicSetup, ...theme];

export default extensions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { jsonParseLinter } from '@codemirror/lang-json';
import { lintGutter, linter } from '@codemirror/lint';

export default [lintGutter(), linter(jsonParseLinter())];

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { syntaxTree } from '@codemirror/language';
import type { Diagnostic } from '@codemirror/lint';
import { linter } from '@codemirror/lint';
import type { EditorView } from 'codemirror';

import parsePayload from '../Parser';

const payloadLinter = linter((view: EditorView) => {
const diagnostics: Diagnostic[] = [];
const tree = syntaxTree(view.state);
let head = tree.topNode.firstChild;
if (!head || !head.matchContext(['Script'])) {
diagnostics.push({
from: 0,
to: 0,
message: 'Expecting a Script',
severity: 'error',
});
return diagnostics;
}
head = head.firstChild;
if (!head || !head.matchContext(['ExpressionStatement'])) {
diagnostics.push({
from: 0,
to: 0,
message: 'Expecting an expression statement',
severity: 'error',
});
return diagnostics;
}
head = head.firstChild;
if (!head || !head.matchContext(['ArrayExpression'])) {
diagnostics.push({
from: 0,
to: 0,
message: 'Expecting an array expression',
severity: 'error',
});
return diagnostics;
}
// while (head.nextSibling && head.nextSibling.name !== ']') {
// }
do {
if (
head.name !== '[' &&
head.name !== ',' &&
head.name !== ']' &&
head.name !== 'ObjectExpression'
) {
diagnostics.push({
from: head.from,
to: head.to,
message: 'Expecting an Object expression',
severity: 'error',
});
return diagnostics;
}
if (head.name === 'ObjectExpression') parsePayload(head, view);
head = head.nextSibling;
} while (head);

return diagnostics;
});

export default payloadLinter;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './parsePayload';
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// import type { Diagnostic } from '@codemirror/lint';
import type { EditorView } from 'codemirror';

const parsePayload = (
head: { from: number; to: number },
// Diagnostic: Diagnostic[],
view: EditorView
) => {
const payload = JSON.parse(
view.state.doc.toString().slice(head.from, head.to)
);
payload && 1;
};

export default parsePayload;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Extension } from '@codemirror/state';
import { Box } from '@rocket.chat/fuselage';
import { useEffect, useContext } from 'react';

import { context } from '../../Context';
import useCodeMirror from '../../hooks/useCodeMirror';
import intendCode from '../../utils/intendCode';

type CodeMirrorProps = {
extensions?: Extension[];
};

const PreviewEditor = ({ extensions }: CodeMirrorProps) => {
const {
state: { screens, activeScreen },
} = useContext(context);
const { editor, setValue } = useCodeMirror(
extensions,
intendCode(screens[activeScreen]?.actionPreview)
);

useEffect(() => {
setValue(intendCode(screens[activeScreen]?.actionPreview), {});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [screens[activeScreen]?.actionPreview]);

return (
<>
<Box display="grid" height="100%" width={'100%'} ref={editor} />
</>
);
};

export default PreviewEditor;
Loading
Loading