@jpmorganchase/mosaic-content-editor-plugin 0.1.0-beta.49 → 0.1.0-beta.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +23 -0
- package/dist/{chunk-L2OH7BJU.js → chunk-7O2SLISS.js} +1 -1
- package/dist/{chunk-G5KHGFL7.js → chunk-CBQZGN4Y.js} +1 -1
- package/dist/{chunk-NRVOINKM.js → chunk-CXTIKD2Y.js} +1 -1
- package/dist/{chunk-YFKHACPP.js → chunk-EPOQVSZ5.js} +1 -1
- package/dist/chunk-GNXBZEEO.js +1 -0
- package/dist/{chunk-U4LYPE2K.js → chunk-ICJP373O.js} +1 -1
- package/dist/chunk-PIYHEBW7.js +1 -0
- package/dist/chunk-VDGHHU3F.js +1 -0
- package/dist/components/Editor.js +1 -1
- package/dist/components/PersistEditDialog/PersistStatus.d.ts +3 -2
- package/dist/components/PersistEditDialog/PersistStatus.js +1 -1
- package/dist/components/PersistEditDialog/index.js +1 -1
- package/dist/components/Toolbar/InsertImage.js +1 -1
- package/dist/components/Toolbar/InsertLink.js +1 -1
- package/dist/components/Toolbar/Toolbar.js +1 -1
- package/dist/hooks/useWorkflowFeed.d.ts +3 -0
- package/dist/hooks/useWorkflowFeed.js +1 -0
- package/dist/index.js +1 -1
- package/dist/plugins/FloatingToolbarPlugin.js +1 -1
- package/dist/plugins/MarkdownLinkPlugin.js +1 -1
- package/dist/plugins/PreviewPlugin.js +1 -1
- package/package.json +4 -4
- package/src/components/PersistEditDialog/PersistStatus.tsx +11 -38
- package/src/components/PersistEditDialog/__tests__/index.test.tsx +7 -10
- package/src/components/PersistEditDialog/index.tsx +40 -27
- package/src/hooks/useWorkflowFeed.ts +56 -0
- package/dist/api/save.d.ts +0 -5
- package/dist/api/save.js +0 -1
- package/dist/chunk-6EO5B7QP.js +0 -1
- package/dist/chunk-TVGVMAJS.js +0 -1
- package/dist/chunk-Z6W7GDHE.js +0 -1
- package/src/api/save.ts +0 -12
- package/src/components/PersistEditDialog/__tests__/handlers.ts +0 -9
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@jpmorganchase/mosaic-content-editor-plugin:build: cache hit, replaying output
|
|
1
|
+
@jpmorganchase/mosaic-content-editor-plugin:build: cache hit, replaying output 40b46b924418f067
|
|
2
2
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ npm-run-all --parallel build:*
|
|
3
3
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ node ../../scripts/bundle.js
|
|
4
4
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ tsc
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @jpmorganchase/mosaic-content-editor-plugin
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.52
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9ad7418c: Use a websocket for workflows
|
|
8
|
+
- @jpmorganchase/mosaic-components@0.1.0-beta.52
|
|
9
|
+
- @jpmorganchase/mosaic-theme@0.1.0-beta.52
|
|
10
|
+
|
|
11
|
+
## 0.1.0-beta.51
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [56bbad4b]
|
|
16
|
+
- @jpmorganchase/mosaic-components@0.1.0-beta.51
|
|
17
|
+
- @jpmorganchase/mosaic-theme@0.1.0-beta.51
|
|
18
|
+
|
|
19
|
+
## 0.1.0-beta.50
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- @jpmorganchase/mosaic-components@0.1.0-beta.50
|
|
24
|
+
- @jpmorganchase/mosaic-theme@0.1.0-beta.50
|
|
25
|
+
|
|
3
26
|
## 0.1.0-beta.49
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-5KRV6UWE.js";import{c as b}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-5KRV6UWE.js";import{c as b}from"./chunk-EPOQVSZ5.js";import{a as u}from"./chunk-YIFLQ5MW.js";import{a as d}from"./chunk-TSWYSURQ.js";import{a as y}from"./chunk-7JRJTNUG.js";import{a as c}from"./chunk-GYUEXLD6.js";import o,{useCallback as U,useEffect as h,useState as T}from"react";import{useLexicalComposerContext as L}from"@lexical/react/LexicalComposerContext";import{mergeRegister as A}from"@lexical/utils";import{$getSelection as B,$isRangeSelection as M,COMMAND_PRIORITY_LOW as R,SELECTION_CHANGE_COMMAND as _}from"lexical";import{flip as k,inline as w,useInteractions as D,useDismiss as $}from"@floating-ui/react";import{useFloatingUI as v}from"@salt-ds/core";function tt(){let[e]=L(),[t,i]=T(null),[m,r]=T(!1),C=t?{middleware:[w(t),k({fallbackPlacements:["bottom-start","top-start"]})]}:{placement:"bottom-start",strategy:"absolute"},{context:P,floating:x,reference:p,strategy:F}=v({placement:"bottom-start",open:m,onOpenChange:r,strategy:"absolute",...C}),{getFloatingProps:I}=D([$(P,{ancestorScroll:!0})]),n=U(()=>{let l=B(),s=window.getSelection(),g=s?.anchorNode?.parentElement;if(M(l)&&g&&!s?.isCollapsed){p(g);let S=s.getRangeAt(0),{x:E,y:O,height:N}=S.getBoundingClientRect();i({x:E,y:O+N}),r(!0)}else i(null),r(!1)},[p]);h(()=>A(e.registerUpdateListener(({editorState:l})=>{l.read(()=>{n()})}),e.registerCommand(_,()=>(n(),!1),R)),[e,n]);let a={position:F};return t&&(a={...a,top:t.y,left:t.x}),o.createElement(u,{ref:x,open:m,style:a,...I({})},o.createElement(y,{"aria-label":"page editing toolbar",className:d.toolbar},o.createElement(f,{floating:!0}),o.createElement(c,{"aria-label":"text format tooltray"},o.createElement(b,null))))}export{tt as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l}from"./chunk-4B2NDAA2.js";import{a as s}from"./chunk-DLRFTDUZ.js";import{a as d}from"./chunk-
|
|
1
|
+
import{a as l}from"./chunk-4B2NDAA2.js";import{a as s}from"./chunk-DLRFTDUZ.js";import{a as d}from"./chunk-CXTIKD2Y.js";import{a as b}from"./chunk-DXTVYP7D.js";import{a as n}from"./chunk-PC66Q33O.js";import{a as m}from"./chunk-FW7CHFWO.js";import{a as e}from"./chunk-5KRV6UWE.js";import{c as p}from"./chunk-EPOQVSZ5.js";import{a as T}from"./chunk-7JRJTNUG.js";import{a as r}from"./chunk-GYUEXLD6.js";import{a as t}from"./chunk-3QIETKQW.js";import{c as i}from"./chunk-G57W376H.js";import o from"react";import{Icon as a}from"@jpmorganchase/mosaic-components";var I=()=>{let{canRedo:f,canUndo:y,redoEdit:u,undoEdit:g}=m(),{setPageState:B}=i();return o.createElement(T,{"aria-label":"page editing toolbar"},o.createElement(r,{"aria-label":"history tooltray"},o.createElement(t,{label:"Undo",disabled:!y,onClick:g},o.createElement(a,{name:"undo"})),o.createElement(t,{label:"Redo",disabled:!f,onClick:u},o.createElement(a,{name:"redo"})),o.createElement(l,null)),o.createElement(e,null),o.createElement(r,{"aria-label":"text format tooltray"},o.createElement(p,null),o.createElement(b,null),o.createElement(d,null),o.createElement(s,null),o.createElement(l,null)),o.createElement(r,{"aria-label":"stop editing tooltray",align:"right"},o.createElement(t,{label:"Cancel Editing",onClick:()=>B("VIEW")},o.createElement(a,{name:"delete"})),o.createElement(l,null)),o.createElement(r,{"aria-label":"copy tooltray"},o.createElement(n,null)))},W=I;export{W as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b}from"./chunk-KZXCNQER.js";import{a as I}from"./chunk-YBFKG74H.js";import{a as
|
|
1
|
+
import{a as b}from"./chunk-KZXCNQER.js";import{a as I}from"./chunk-YBFKG74H.js";import{a as h}from"./chunk-XSZUCLBY.js";import{a as v}from"./chunk-3QIETKQW.js";import e,{useState as i}from"react";import{useLexicalComposerContext as M}from"@lexical/react/LexicalComposerContext";import{Button as c,Icon as P}from"@jpmorganchase/mosaic-components";import{string as C,object as V}from"yup";import{Input as S,FormField as D,FormFieldLabel as y,FormFieldHelperText as A}from"@salt-ds/core";import{ButtonBar as q,DialogTitle as w,DialogContent as L,DialogActions as N}from"@salt-ds/lab";var B=V({alt:C().required("Alternative Information is a required field").max(100,"Alternative Information must be fewer than 100 characters"),url:C().required("Url is required").url("Must be a valid Url")}),E={url:"https://"},Y=()=>{let[T]=M(),[s,m]=i(!1),[r,u]=i(E),[n,d]=i(),f=t=>{m(t),t||u(E)},x=()=>m(!0),p=()=>{f(!1)},g=t=>{let o=t.inner.reduce((l,{path:a,message:O})=>({...l,[a]:O}),{});d(o)},F=t=>{let{name:o,value:l}=t.target,a={...r,[o]:l};B.validateAt(o,a,{abortEarly:!1}).then(()=>{d({...n,[o]:void 0})},g),u(a)};return e.createElement(e.Fragment,null,e.createElement(v,{active:s,onClick:x,label:"Insert Image"},e.createElement(P,{name:"addDocument"})),e.createElement(h,{onOpenChange:f,open:s},e.createElement("form",{onSubmit:async t=>{t.preventDefault(),B.validate(r,{abortEarly:!1}).then(()=>{let o={alt:r&&r.alt!==void 0?r.alt:null,url:r&&r.url!==void 0?r.url:null};T.dispatchCommand(I,o),p()},g)},noValidate:!0},e.createElement(w,null,"Insert Image"),e.createElement(L,null,e.createElement("div",{className:b.fullWidth},e.createElement(D,{validationStatus:n?.url?"error":void 0},e.createElement(y,null,"Url for image"),e.createElement(S,{value:r?.url,inputProps:{name:"url"},onChange:F}),e.createElement(A,null,n?.url)),e.createElement(D,{validationStatus:n?.alt?"error":void 0},e.createElement(y,null,"Alternative Information (alt)"),e.createElement(S,{value:r?.alt,inputProps:{name:"alt"},onChange:F}),e.createElement(A,null,n?.alt||"Provides alternative information for the image if for some reason it cannot be viewed")))),e.createElement(N,null,e.createElement(q,null,e.createElement(c,{onClick:p},"Cancel"),e.createElement(c,{variant:"cta",type:"submit"},"Insert"))))))};export{Y as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C}from"./chunk-WZYDYWT3.js";import{a as
|
|
1
|
+
import{a as C}from"./chunk-WZYDYWT3.js";import{a as k}from"./chunk-XSZUCLBY.js";import{a as I}from"./chunk-3QIETKQW.js";import{e as p}from"./chunk-G57W376H.js";import{$createLinkNode as W,TOGGLE_LINK_COMMAND as G}from"@lexical/link";import{useLexicalComposerContext as U}from"@lexical/react/LexicalComposerContext";import{$wrapNodes as j}from"@lexical/selection";import{$createParagraphNode as Y,$createTextNode as z,$getSelection as J,$isRangeSelection as Q,$isTextNode as X,COMMAND_PRIORITY_EDITOR as Z,createCommand as R}from"lexical";import ee,{useCallback as te,useEffect as ne}from"react";import e,{useEffect as O,useState as F}from"react";import{useLexicalComposerContext as B}from"@lexical/react/LexicalComposerContext";import{Button as N,Icon as _}from"@jpmorganchase/mosaic-components";import{string as h,object as A}from"yup";import{Input as T,FormField as D,FormFieldLabel as S,FormFieldHelperText as E}from"@salt-ds/core";import{ButtonBar as $,DialogTitle as w,DialogContent as K,DialogActions as q}from"@salt-ds/lab";import{$getSelection as V,$isRangeSelection as H}from"lexical";var b=A({url:h().required("Url is required"),text:h().required("Text is required").max(100,"Text must be fewer than 100 characters")}),Le=()=>{let{isInsertingLink:t,setIsInsertingLink:r}=p();return e.createElement(I,{active:t,onClick:()=>r(!0),label:"Insert Link"},e.createElement(_,{name:"linked"}))},v={url:"https://",text:""},y=()=>{let[t]=B(),{isInsertingLink:r,setIsInsertingLink:s}=p(),[o,i]=F(v),[a,d]=F(),m=n=>{s(n),n||(d(void 0),i(v))},g=()=>{m(!1)};O(()=>{t.getEditorState().read(()=>{if(r){let n=V();if(H(n)){let l=n.getTextContent();i(u=>({...u,text:l}))}}})},[t,r]);let x=n=>{let l=n.inner.reduce((u,{path:c,message:P})=>({...u,[c]:P}),{});d(l)},L=n=>{let{name:l,value:u}=n.target,c={...o,[l]:u};b.validateAt(l,c,{abortEarly:!1}).then(()=>{d({...a,[l]:void 0})},x),i(c)},M=async()=>{b.validate(o,{abortEarly:!1}).then(()=>{let n={url:o?.url,text:o?.text};t.dispatchCommand(f,n),g()},x)};return e.createElement(k,{onOpenChange:m,open:r},e.createElement(w,null,"Insert Link"),e.createElement(K,null,e.createElement("div",{className:C.fullWidth},e.createElement(D,{validationStatus:a?.url?"error":void 0},e.createElement(S,null,"Image URL text"),e.createElement(T,{value:o?.url,inputProps:{name:"url"},onChange:L}),e.createElement(E,null,a?.url)),e.createElement(D,{validationStatus:a?.text?"error":void 0},e.createElement(S,null,"Link Text"),e.createElement(T,{value:o?.text,inputProps:{name:"text"},onChange:L}),e.createElement(E,null,a?.text)))),e.createElement(q,null,e.createElement($,null,e.createElement(N,{onClick:g},"Cancel"),e.createElement(N,{variant:"cta",onClick:M},"Insert"))))};var f=R();function oe(){let[t]=U(),r=te(({url:s,text:o})=>{t.update(()=>{let i=J();if(Q(i)&&s!==void 0&&o!==void 0){let a=i.focus.getNode();if(X(a))t.dispatchCommand(G,s);else{let d=W(s),m=z(o);m.setFormat(i.focus.getNode().getFormat()),d.append(m),j(i,()=>d,Y())}}})},[t]);ne(()=>t.registerCommand(f,s=>(r(s),!0),Z),[t,r])}function Se(){return oe(),ee.createElement(y,null)}export{f as a,Se as b,Le as c,y as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect as l,useRef as c}from"react";var u=process.env.NEXT_PUBLIC_MOSAIC_WORKFLOWS_URL||"";function g(o,a,f){let e=c(),t=c();return l(function(){try{e.current=new WebSocket(u),e.current.onopen=()=>console.log(`Workflows websocket open: ${u}`),e.current.onclose=()=>console.log("Workflows websocket closed"),e.current.onmessage=r=>{let s=JSON.parse(r.data);s.channel===t.current&&(s.status==="ERROR"&&o(s),s.status==="COMPLETE"&&f(s),(s.status==="IN_PROGRESS"||s.status==="SUCCESS")&&a(s))}}catch(r){o(r)}return()=>{e.current&&e.current?.OPEN&&(t.current=null,e.current.close())}},[]),{sendWorkflowProgressMessage:(n,r)=>{e.current?.OPEN&&(t.current=r,e.current?.send(n))}}}export{g as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E}from"./chunk-
|
|
1
|
+
import{a as E}from"./chunk-CBQZGN4Y.js";import{a as y}from"./chunk-PIYHEBW7.js";import{a as f}from"./chunk-UWF3FV3R.js";import{a as x}from"./chunk-QHE4U3WR.js";import{a}from"./chunk-M4ISRNFD.js";import{b as w}from"./chunk-YBFKG74H.js";import{a as M}from"./chunk-ROQUYURQ.js";import{a as h}from"./chunk-3FJGHVH5.js";import{a as k}from"./chunk-QKOQTH4L.js";import{a as P}from"./chunk-RO6ARCLZ.js";import{a as b}from"./chunk-7O2SLISS.js";import{b as S}from"./chunk-EPOQVSZ5.js";import{a as T}from"./chunk-FKL4ZGDB.js";import{a as g}from"./chunk-PXUVNH4P.js";import{a as n}from"./chunk-NXV7KCC5.js";import{a as C,d as v,f as l}from"./chunk-G57W376H.js";import R from"react";import{$convertToMarkdownString as oo}from"@lexical/markdown";import{OnChangePlugin as ro}from"@lexical/react/LexicalOnChangePlugin";import to from"lodash/debounce";import o,{useRef as B,useState as D}from"react";import H from"clsx";import j from"gray-matter";import{LexicalComposer as A}from"@lexical/react/LexicalComposer";import{ListPlugin as I}from"@lexical/react/LexicalListPlugin";import{TablePlugin as J}from"@lexical/react/LexicalTablePlugin";import{LinkPlugin as W}from"@lexical/react/LexicalLinkPlugin";import{HistoryPlugin as X}from"@lexical/react/LexicalHistoryPlugin";import{MarkdownShortcutPlugin as q}from"@lexical/react/LexicalMarkdownShortcutPlugin";import G from"react-split";import{$convertFromMarkdownString as K}from"@lexical/markdown";function Q(r){console.error(r)}var V={namespace:"mosaic-content-editor",onError:Q,nodes:P,theme:h},Y=()=>{let r=document.createElement("div");return r.className=n.gutter,r},Z=({components:r,content:e,persistUrl:m,PreviewComponent:i,previewUrl:s,source:p,user:t})=>{let L=C()||p,{setUser:N}=v(),[c,u]=D(!1),U=B(null),{data:d,content:z}=j(e),$=()=>{u(!0),N(t)},O=()=>{u(!1)};return o.createElement(A,{initialConfig:{...V,editorState:()=>K(z,a)}},o.createElement("div",{className:n.root,onFocus:$,onBlur:O},o.createElement("div",{className:n.toolbarContainer},o.createElement(E,null),o.createElement(y,{meta:d,persistUrl:m}),o.createElement(k,null)),o.createElement("div",{className:n.editorRoot},o.createElement(G,{className:n.splitter,cursor:"col-resize",direction:"horizontal",dragInterval:1,expandToMin:!1,gutter:Y,gutterAlign:"center",minSize:100,sizes:[50,50],snapOffset:30},o.createElement(f,{className:H({[n.focused]:c,[n.unfocused]:!c}),ref:U},o.createElement(g,null)),o.createElement(f,null,i&&o.createElement(i,{source:L,meta:d,components:r}))),o.createElement(X,null),o.createElement(I,null),o.createElement(J,null),o.createElement(W,null),o.createElement(q,{transformers:a}),s?o.createElement(F,{previewUrl:s}):null,o.createElement(w,null),o.createElement(S,null),o.createElement(x,null),o.createElement(T,null),o.createElement(b,null),o.createElement(M,null))))},_=Z;async function eo(r,e){return await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"markdown",text:e})})).json()}function no(r){let e=to(r,250,{maxWait:500});return{onChange:i=>{i.read(()=>{let s=oo(a);s&&e(s)})}}}var F=({previewUrl:r})=>{let{setErrorMessage:e,setPreviewContent:m}=l(),i=async p=>{try{if(p){let t=await eo(r,p);!t.error&&t?.source?m(t.source):e(`${t.error?.toUpperCase()}: ${t?.exception}`)}}catch(t){t instanceof Error&&e(`MDX Error: ${t.message}`)}},{onChange:s}=no(i);return R.createElement(ro,{onChange:s,ignoreSelectionChange:!0})};export{F as a,_ as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as D}from"./chunk-VDGHHU3F.js";import{a as k}from"./chunk-R2MEEU32.js";import{a as h}from"./chunk-M4ISRNFD.js";import{a as y}from"./chunk-GNXBZEEO.js";import{a as S}from"./chunk-XSZUCLBY.js";import{c as P,d as C}from"./chunk-G57W376H.js";import e,{useState as g}from"react";import F from"md5";import{useLexicalComposerContext as G}from"@lexical/react/LexicalComposerContext";import{$convertToMarkdownString as O}from"@lexical/markdown";import{Link as $,P2 as b,Button as w}from"@jpmorganchase/mosaic-components";import{ButtonBar as J,DialogTitle as U,DialogContent as V,DialogActions as _}from"@salt-ds/lab";var j=({isRaising:f,prHref:l,error:c})=>!f&&!l&&!c?e.createElement(e.Fragment,null,e.createElement(b,null,"The content of this page resides in a Git repository and to update it requires a Pull Request which will be reviewed by the content owners."),e.createElement("br",null),e.createElement(b,null,"Should you decide to stop editing before creating the Pull Request then all changes will be lost.")):null,le=({meta:f,persistUrl:l})=>{let{pageState:c,setPageState:v}=P(),{user:p}=C(),[B]=G(),[s,t]=g(!1),[r,n]=g(null),[i,m]=g(null),[q,a]=g([]),E=c==="SAVING",I=r!==null?"success":"info",d=o=>{t(o),o||(v("EDIT"),n(null),a([]))},M=()=>{d(!1)},x=o=>{m(o||"Sorry - an unexpected error has occurred"),n(null),a([]),t(!1)},T=o=>{n(o.message?.links?.self[0]?.href),t(!1)},A=o=>{a(u=>[...u,o])},{sendWorkflowProgressMessage:H}=y(x,A,T),L=()=>{t(!0),n(null),m(null);try{B.update(()=>{let o=O(h);if(o&&p&&l){let{sid:u,displayName:N,email:W}=p;H(JSON.stringify({user:{sid:u,name:N,email:W},route:f.route,markdown:o,name:"save"}),F(`${u.toLowerCase()} - save`))}})}catch{m("Sorry - an unexpected error has occurred"),n(null),t(!1),a([])}};return e.createElement(S,{onOpenChange:d,open:E,status:i?"error":I},e.createElement(U,{className:k.title},r?"Pull Request Created Successfully":"Save Changes"),e.createElement(V,null,(s||i)&&!r&&e.createElement(D,{error:i,progress:q}),e.createElement(j,{isRaising:s,prHref:r,error:i}),!s&&r&&e.createElement($,{href:r,target:"_blank"},"A Pull Request for your changes has been created")),e.createElement(_,null,e.createElement(J,null,e.createElement(w,{disabled:s,onClick:M},r?"Done":"Cancel"),e.createElement(w,{disabled:l===void 0||s||r!==null,onClick:L,variant:"cta"},"Raise Pull Request"))))};export{le as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"./chunk-6TM3EYFS.js";import e from"react";import p from"clsx";import{P2 as n,P6 as i}from"@jpmorganchase/mosaic-components";var l=({children:t,isComplete:r,isCurrent:o})=>e.createElement("div",{className:p(s.step,{[s.stepComplete]:r,[s.stepActive]:o})},e.createElement("span",{role:"img","aria-label":r?"emoji with party hat":"hourglass"},r?"\u{1F973}":"\u231B"),e.createElement("span",{className:s.stepText},t)),h=({error:t,progress:r})=>t?e.createElement(e.Fragment,null,e.createElement(n,null,"\u{1F622} Sorry something has went wrong. Please try again later."),e.createElement(i,null,"Error - ",t)):e.createElement(e.Fragment,null,r.map((o,a)=>e.createElement(l,{key:`step -${a}`,isComplete:a<r.length-1,isCurrent:r.length-1===a},o.message)));export{h as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"../chunk-
|
|
1
|
+
import{b as a}from"../chunk-ICJP373O.js";import"../chunk-CBQZGN4Y.js";import"../chunk-4B2NDAA2.js";import"../chunk-4LQ77YZW.js";import"../chunk-DLRFTDUZ.js";import"../chunk-CXTIKD2Y.js";import"../chunk-KZXCNQER.js";import"../chunk-DXTVYP7D.js";import"../chunk-NFA3MZOC.js";import"../chunk-PIYHEBW7.js";import"../chunk-VDGHHU3F.js";import"../chunk-R2MEEU32.js";import"../chunk-UWF3FV3R.js";import"../chunk-KQ2ZCDYD.js";import"../chunk-QHE4U3WR.js";import"../chunk-BFF3MNBV.js";import"../chunk-5YCBSSDA.js";import"../chunk-NFSXCTUU.js";import"../chunk-6TM3EYFS.js";import"../chunk-M4ISRNFD.js";import"../chunk-ESJNOEFD.js";import"../chunk-WNTJMWYJ.js";import"../chunk-RT5CJ7T5.js";import"../chunk-G4LBXKDE.js";import"../chunk-YBFKG74H.js";import"../chunk-ROQUYURQ.js";import"../chunk-ESKW4XF6.js";import"../chunk-6YPAVQF4.js";import"../chunk-3FJGHVH5.js";import"../chunk-JQUDHJIQ.js";import"../chunk-PC66Q33O.js";import"../chunk-QKOQTH4L.js";import"../chunk-FW7CHFWO.js";import"../chunk-GNXBZEEO.js";import"../chunk-RO6ARCLZ.js";import"../chunk-7O2SLISS.js";import"../chunk-5KRV6UWE.js";import"../chunk-SOMQOHNT.js";import"../chunk-U7COOUR6.js";import"../chunk-EPOQVSZ5.js";import"../chunk-WZYDYWT3.js";import"../chunk-YIFLQ5MW.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-TSWYSURQ.js";import"../chunk-FKL4ZGDB.js";import"../chunk-PXUVNH4P.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";import"../chunk-NXV7KCC5.js";import"../chunk-ZHZ4E2MI.js";import"../chunk-7JRJTNUG.js";import"../chunk-GYUEXLD6.js";import"../chunk-FH2LMMJT.js";import"../chunk-7LK4O57W.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";import"../chunk-6X665P47.js";export{a as default};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { SourceWorkflowMessageEvent } from '@jpmorganchase/mosaic-types';
|
|
2
3
|
interface StatusProps {
|
|
3
|
-
isRaising: boolean;
|
|
4
4
|
error: string | null;
|
|
5
|
+
progress: SourceWorkflowMessageEvent[];
|
|
5
6
|
}
|
|
6
|
-
export declare const PersistStatus: ({
|
|
7
|
+
export declare const PersistStatus: ({ error, progress }: StatusProps) => JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-VDGHHU3F.js";import"../../chunk-6TM3EYFS.js";export{a as PersistStatus};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-PIYHEBW7.js";import"../../chunk-VDGHHU3F.js";import"../../chunk-R2MEEU32.js";import"../../chunk-6TM3EYFS.js";import"../../chunk-M4ISRNFD.js";import"../../chunk-ESJNOEFD.js";import"../../chunk-WNTJMWYJ.js";import"../../chunk-RT5CJ7T5.js";import"../../chunk-GNXBZEEO.js";import"../../chunk-XSZUCLBY.js";import"../../chunk-OW5SK4AJ.js";import"../../chunk-G57W376H.js";export{a as PersistDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-CXTIKD2Y.js";import"../../chunk-KZXCNQER.js";import"../../chunk-YBFKG74H.js";import"../../chunk-XSZUCLBY.js";import"../../chunk-OW5SK4AJ.js";import"../../chunk-3QIETKQW.js";import"../../chunk-Y2A2ULLZ.js";export{a as InsertImage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a,d as b}from"../../chunk-
|
|
1
|
+
import{c as a,d as b}from"../../chunk-EPOQVSZ5.js";import"../../chunk-WZYDYWT3.js";import"../../chunk-XSZUCLBY.js";import"../../chunk-OW5SK4AJ.js";import"../../chunk-3QIETKQW.js";import"../../chunk-Y2A2ULLZ.js";import"../../chunk-G57W376H.js";export{a as InsertLinkButton,b as InsertLinkDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-CBQZGN4Y.js";import"../../chunk-4B2NDAA2.js";import"../../chunk-4LQ77YZW.js";import"../../chunk-DLRFTDUZ.js";import"../../chunk-CXTIKD2Y.js";import"../../chunk-KZXCNQER.js";import"../../chunk-DXTVYP7D.js";import"../../chunk-NFA3MZOC.js";import"../../chunk-YBFKG74H.js";import"../../chunk-PC66Q33O.js";import"../../chunk-FW7CHFWO.js";import"../../chunk-5KRV6UWE.js";import"../../chunk-SOMQOHNT.js";import"../../chunk-U7COOUR6.js";import"../../chunk-EPOQVSZ5.js";import"../../chunk-WZYDYWT3.js";import"../../chunk-YIFLQ5MW.js";import"../../chunk-XP37MJCS.js";import"../../chunk-P5OBPOC4.js";import"../../chunk-XSZUCLBY.js";import"../../chunk-OW5SK4AJ.js";import"../../chunk-7JRJTNUG.js";import"../../chunk-GYUEXLD6.js";import"../../chunk-FH2LMMJT.js";import"../../chunk-7LK4O57W.js";import"../../chunk-3QIETKQW.js";import"../../chunk-Y2A2ULLZ.js";import"../../chunk-G57W376H.js";export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-GNXBZEEO.js";export{a as default};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c}from"./chunk-
|
|
1
|
+
import{b as c}from"./chunk-ICJP373O.js";import"./chunk-CBQZGN4Y.js";import"./chunk-4B2NDAA2.js";import"./chunk-4LQ77YZW.js";import"./chunk-DLRFTDUZ.js";import"./chunk-CXTIKD2Y.js";import"./chunk-KZXCNQER.js";import"./chunk-DXTVYP7D.js";import"./chunk-NFA3MZOC.js";import"./chunk-PIYHEBW7.js";import"./chunk-VDGHHU3F.js";import"./chunk-R2MEEU32.js";import"./chunk-UWF3FV3R.js";import"./chunk-KQ2ZCDYD.js";import"./chunk-QHE4U3WR.js";import"./chunk-BFF3MNBV.js";import"./chunk-5YCBSSDA.js";import"./chunk-NFSXCTUU.js";import"./chunk-6TM3EYFS.js";import"./chunk-M4ISRNFD.js";import"./chunk-ESJNOEFD.js";import"./chunk-WNTJMWYJ.js";import"./chunk-RT5CJ7T5.js";import"./chunk-G4LBXKDE.js";import"./chunk-YBFKG74H.js";import"./chunk-ROQUYURQ.js";import"./chunk-ESKW4XF6.js";import"./chunk-6YPAVQF4.js";import"./chunk-3FJGHVH5.js";import"./chunk-JQUDHJIQ.js";import"./chunk-PC66Q33O.js";import"./chunk-QKOQTH4L.js";import"./chunk-FW7CHFWO.js";import"./chunk-GNXBZEEO.js";import"./chunk-RO6ARCLZ.js";import"./chunk-7O2SLISS.js";import"./chunk-5KRV6UWE.js";import"./chunk-SOMQOHNT.js";import"./chunk-U7COOUR6.js";import"./chunk-EPOQVSZ5.js";import"./chunk-WZYDYWT3.js";import"./chunk-YIFLQ5MW.js";import"./chunk-XP37MJCS.js";import"./chunk-P5OBPOC4.js";import"./chunk-TSWYSURQ.js";import"./chunk-FKL4ZGDB.js";import"./chunk-PXUVNH4P.js";import"./chunk-XSZUCLBY.js";import"./chunk-OW5SK4AJ.js";import"./chunk-NXV7KCC5.js";import{a as d}from"./chunk-ZHZ4E2MI.js";import"./chunk-7JRJTNUG.js";import"./chunk-GYUEXLD6.js";import"./chunk-FH2LMMJT.js";import"./chunk-7LK4O57W.js";import"./chunk-3QIETKQW.js";import"./chunk-Y2A2ULLZ.js";import{c as a,f as b}from"./chunk-G57W376H.js";import"./chunk-6X665P47.js";export{c as Editor,d as EditorControls,b as useContentEditor,a as usePageState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-7O2SLISS.js";import"../chunk-5KRV6UWE.js";import"../chunk-SOMQOHNT.js";import"../chunk-U7COOUR6.js";import"../chunk-EPOQVSZ5.js";import"../chunk-WZYDYWT3.js";import"../chunk-YIFLQ5MW.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-TSWYSURQ.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";import"../chunk-7JRJTNUG.js";import"../chunk-GYUEXLD6.js";import"../chunk-FH2LMMJT.js";import"../chunk-7LK4O57W.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";export{a as FloatingToolbarPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-EPOQVSZ5.js";import"../chunk-WZYDYWT3.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";export{a as INSERT_MARKDOWN_LINK_COMMAND,b as MarkdownLinkPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-ICJP373O.js";import"../chunk-CBQZGN4Y.js";import"../chunk-4B2NDAA2.js";import"../chunk-4LQ77YZW.js";import"../chunk-DLRFTDUZ.js";import"../chunk-CXTIKD2Y.js";import"../chunk-KZXCNQER.js";import"../chunk-DXTVYP7D.js";import"../chunk-NFA3MZOC.js";import"../chunk-PIYHEBW7.js";import"../chunk-VDGHHU3F.js";import"../chunk-R2MEEU32.js";import"../chunk-UWF3FV3R.js";import"../chunk-KQ2ZCDYD.js";import"../chunk-QHE4U3WR.js";import"../chunk-BFF3MNBV.js";import"../chunk-5YCBSSDA.js";import"../chunk-NFSXCTUU.js";import"../chunk-6TM3EYFS.js";import"../chunk-M4ISRNFD.js";import"../chunk-ESJNOEFD.js";import"../chunk-WNTJMWYJ.js";import"../chunk-RT5CJ7T5.js";import"../chunk-G4LBXKDE.js";import"../chunk-YBFKG74H.js";import"../chunk-ROQUYURQ.js";import"../chunk-ESKW4XF6.js";import"../chunk-6YPAVQF4.js";import"../chunk-3FJGHVH5.js";import"../chunk-JQUDHJIQ.js";import"../chunk-PC66Q33O.js";import"../chunk-QKOQTH4L.js";import"../chunk-FW7CHFWO.js";import"../chunk-GNXBZEEO.js";import"../chunk-RO6ARCLZ.js";import"../chunk-7O2SLISS.js";import"../chunk-5KRV6UWE.js";import"../chunk-SOMQOHNT.js";import"../chunk-U7COOUR6.js";import"../chunk-EPOQVSZ5.js";import"../chunk-WZYDYWT3.js";import"../chunk-YIFLQ5MW.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-TSWYSURQ.js";import"../chunk-FKL4ZGDB.js";import"../chunk-PXUVNH4P.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";import"../chunk-NXV7KCC5.js";import"../chunk-ZHZ4E2MI.js";import"../chunk-7JRJTNUG.js";import"../chunk-GYUEXLD6.js";import"../chunk-FH2LMMJT.js";import"../chunk-7LK4O57W.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";import"../chunk-6X665P47.js";export{a as PreviewPlugin};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-content-editor-plugin",
|
|
3
3
|
"description": "Mosaic - In Browser content editing plugin",
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.52",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "",
|
|
7
7
|
"repository": {
|
|
@@ -34,12 +34,11 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.16.5",
|
|
35
35
|
"@testing-library/react": "^13.4.0",
|
|
36
36
|
"@testing-library/user-event": "^14.0.0",
|
|
37
|
-
"msw": "^0.49.1",
|
|
38
37
|
"typescript": "^4.8.3"
|
|
39
38
|
},
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@jpmorganchase/mosaic-components": "^0.1.0-beta.
|
|
42
|
-
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.
|
|
40
|
+
"@jpmorganchase/mosaic-components": "^0.1.0-beta.52",
|
|
41
|
+
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.52",
|
|
43
42
|
"@salt-ds/core": "^1.8.1",
|
|
44
43
|
"@salt-ds/icons": "^1.6.0",
|
|
45
44
|
"@salt-ds/lab": "1.0.0-alpha.16",
|
|
@@ -60,6 +59,7 @@
|
|
|
60
59
|
"lexical": "^0.11.1",
|
|
61
60
|
"react-split": "^2.0.14",
|
|
62
61
|
"lodash": "^4.17.21",
|
|
62
|
+
"md5": "*",
|
|
63
63
|
"yup": "^0.32.9",
|
|
64
64
|
"zustand": "^4.1.1"
|
|
65
65
|
},
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import React, { FC, ReactNode
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
2
|
import classnames from 'clsx';
|
|
3
3
|
import { P2, P6 } from '@jpmorganchase/mosaic-components';
|
|
4
4
|
|
|
5
5
|
import styles from './PersistStatus.css';
|
|
6
|
-
|
|
7
|
-
const steps = ['Making a copy...', 'Applying changes...', 'Creating a Pull Request...'];
|
|
8
|
-
const lastStep = steps.length - 1;
|
|
6
|
+
import { SourceWorkflowMessageEvent } from '@jpmorganchase/mosaic-types';
|
|
9
7
|
|
|
10
8
|
interface StepProps {
|
|
11
9
|
children?: ReactNode;
|
|
@@ -20,43 +18,20 @@ const Step: FC<StepProps> = ({ children, isComplete, isCurrent }) => (
|
|
|
20
18
|
[styles.stepActive]: isCurrent
|
|
21
19
|
})}
|
|
22
20
|
>
|
|
23
|
-
<span role="img" aria-label=
|
|
24
|
-
{isComplete ? '🥳' :
|
|
25
|
-
</span>
|
|
26
|
-
<span role="img" aria-label="person grimacing emoji ">
|
|
27
|
-
{isCurrent ? '😃' : null}
|
|
28
|
-
</span>
|
|
29
|
-
<span role="img" aria-label="sleepy emoji">
|
|
30
|
-
{!isCurrent && !isComplete ? '💤' : null}
|
|
21
|
+
<span role="img" aria-label={isComplete ? 'emoji with party hat' : 'hourglass'}>
|
|
22
|
+
{isComplete ? '🥳' : '⌛'}
|
|
31
23
|
</span>
|
|
24
|
+
|
|
32
25
|
<span className={styles.stepText}>{children}</span>
|
|
33
|
-
<span role="img" aria-label="hourglass">
|
|
34
|
-
{isCurrent ? '⌛' : null}
|
|
35
|
-
</span>
|
|
36
26
|
</div>
|
|
37
27
|
);
|
|
38
28
|
|
|
39
29
|
interface StatusProps {
|
|
40
|
-
isRaising: boolean;
|
|
41
30
|
error: string | null;
|
|
31
|
+
progress: SourceWorkflowMessageEvent[];
|
|
42
32
|
}
|
|
43
33
|
|
|
44
|
-
export const PersistStatus = ({
|
|
45
|
-
const [currentStep, setCurrentStep] = useState(0);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const stepInterval = setInterval(() => {
|
|
49
|
-
if (currentStep === steps.length - 1) {
|
|
50
|
-
clearInterval(stepInterval);
|
|
51
|
-
} else {
|
|
52
|
-
setCurrentStep(prevState => prevState + 1);
|
|
53
|
-
}
|
|
54
|
-
}, 2000);
|
|
55
|
-
return function cleanUpStepInterval() {
|
|
56
|
-
clearInterval(stepInterval);
|
|
57
|
-
};
|
|
58
|
-
}, [currentStep]);
|
|
59
|
-
|
|
34
|
+
export const PersistStatus = ({ error, progress }: StatusProps) => {
|
|
60
35
|
if (error) {
|
|
61
36
|
return (
|
|
62
37
|
<>
|
|
@@ -68,15 +43,13 @@ export const PersistStatus = ({ isRaising, error }: StatusProps) => {
|
|
|
68
43
|
|
|
69
44
|
return (
|
|
70
45
|
<>
|
|
71
|
-
{
|
|
46
|
+
{progress.map((message, index) => (
|
|
72
47
|
<Step
|
|
73
48
|
key={`step -${index}`}
|
|
74
|
-
isComplete={
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
isCurrent={currentStep === index}
|
|
49
|
+
isComplete={index < progress.length - 1}
|
|
50
|
+
isCurrent={progress.length - 1 === index}
|
|
78
51
|
>
|
|
79
|
-
{
|
|
52
|
+
{message.message}
|
|
80
53
|
</Step>
|
|
81
54
|
))}
|
|
82
55
|
</>
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import { setupServer } from 'msw/node';
|
|
5
4
|
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
6
5
|
|
|
7
6
|
import { PersistDialog } from '../index';
|
|
8
7
|
import { usePageState } from '../../../store';
|
|
9
8
|
import { nodes } from '../../../nodes';
|
|
10
|
-
import
|
|
9
|
+
import useWorkflowFeed from '../../../hooks/useWorkflowFeed';
|
|
11
10
|
|
|
12
11
|
jest.mock('../../../store', () => ({
|
|
13
12
|
...jest.requireActual('../../../store'),
|
|
@@ -15,6 +14,12 @@ jest.mock('../../../store', () => ({
|
|
|
15
14
|
usePageState: jest.fn()
|
|
16
15
|
}));
|
|
17
16
|
|
|
17
|
+
const mockSendWorkflowProgressMessage = jest.fn();
|
|
18
|
+
jest.mock('../../../hooks/useWorkflowFeed');
|
|
19
|
+
jest
|
|
20
|
+
.mocked(useWorkflowFeed)
|
|
21
|
+
.mockReturnValue({ sendWorkflowProgressMessage: mockSendWorkflowProgressMessage });
|
|
22
|
+
|
|
18
23
|
const setPageStateSpy = jest.fn();
|
|
19
24
|
const setErrorMessageSpy = jest.fn();
|
|
20
25
|
const mockMeta = { sourceId: 'source-1', route: 'route' };
|
|
@@ -24,8 +29,6 @@ jest.mock('@lexical/markdown', () => ({
|
|
|
24
29
|
$convertToMarkdownString: jest.fn().mockReturnValue('## Test Markdown')
|
|
25
30
|
}));
|
|
26
31
|
|
|
27
|
-
const server = setupServer();
|
|
28
|
-
|
|
29
32
|
const renderPersistDialog = (props = { meta: mockMeta }) => {
|
|
30
33
|
render(
|
|
31
34
|
<LexicalComposer
|
|
@@ -38,8 +41,6 @@ const renderPersistDialog = (props = { meta: mockMeta }) => {
|
|
|
38
41
|
|
|
39
42
|
describe('GIVEN a PersistEditDialog', () => {
|
|
40
43
|
beforeAll(() => {
|
|
41
|
-
server.listen({ onUnhandledRequest: 'error' });
|
|
42
|
-
|
|
43
44
|
jest.mocked(usePageState).mockReturnValue({
|
|
44
45
|
pageState: 'SAVING',
|
|
45
46
|
setErrorMessage: setErrorMessageSpy,
|
|
@@ -48,10 +49,6 @@ describe('GIVEN a PersistEditDialog', () => {
|
|
|
48
49
|
});
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
afterAll(() => {
|
|
52
|
-
server.close();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
52
|
test('THEN the dialog is open when SAVING', () => {
|
|
56
53
|
// arrange
|
|
57
54
|
renderPersistDialog();
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React, { FC, useState } from 'react';
|
|
2
|
+
import md5 from 'md5';
|
|
2
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
4
|
import { $convertToMarkdownString } from '@lexical/markdown';
|
|
4
5
|
import { Link, P2, Button } from '@jpmorganchase/mosaic-components';
|
|
5
6
|
import { ButtonBar, DialogTitle, DialogContent, DialogActions } from '@salt-ds/lab';
|
|
7
|
+
import { SourceWorkflowMessageEvent } from '@jpmorganchase/mosaic-types';
|
|
6
8
|
|
|
7
9
|
import { useEditorUser, usePageState } from '../../store';
|
|
8
|
-
import { save } from '../../api/save';
|
|
9
10
|
import transformers from '../../transformers';
|
|
10
11
|
import { PersistStatus } from './PersistStatus';
|
|
11
12
|
import { Dialog } from '../Dialog';
|
|
12
13
|
import style from './index.css';
|
|
14
|
+
import useWorkflowFeed from '../../hooks/useWorkflowFeed';
|
|
13
15
|
|
|
14
16
|
interface InfoProps {
|
|
15
17
|
isRaising: boolean;
|
|
@@ -44,6 +46,7 @@ export const PersistDialog = ({ meta, persistUrl }: PersistDialogProps) => {
|
|
|
44
46
|
const [isRaising, setIsRaising] = useState(false);
|
|
45
47
|
const [prHref, setPrHref] = useState<string | null>(null);
|
|
46
48
|
const [error, setError] = useState<string | null>(null);
|
|
49
|
+
const [progress, setProgress] = useState<SourceWorkflowMessageEvent[]>([]);
|
|
47
50
|
|
|
48
51
|
const open = pageState === 'SAVING';
|
|
49
52
|
const state = prHref !== null ? 'success' : 'info';
|
|
@@ -53,6 +56,7 @@ export const PersistDialog = ({ meta, persistUrl }: PersistDialogProps) => {
|
|
|
53
56
|
if (!newOpen) {
|
|
54
57
|
setPageState('EDIT');
|
|
55
58
|
setPrHref(null);
|
|
59
|
+
setProgress([]);
|
|
56
60
|
}
|
|
57
61
|
};
|
|
58
62
|
|
|
@@ -60,46 +64,55 @@ export const PersistDialog = ({ meta, persistUrl }: PersistDialogProps) => {
|
|
|
60
64
|
handleOpenChange(false);
|
|
61
65
|
};
|
|
62
66
|
|
|
67
|
+
const handleErrorMessage = (errorMessage: string) => {
|
|
68
|
+
setError(errorMessage ? errorMessage : 'Sorry - an unexpected error has occurred');
|
|
69
|
+
setPrHref(null);
|
|
70
|
+
setProgress([]);
|
|
71
|
+
setIsRaising(false);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleCompleteMessage = message => {
|
|
75
|
+
setPrHref(message.message?.links?.self[0]?.href);
|
|
76
|
+
setIsRaising(false);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const handleSuccessMessage = message => {
|
|
80
|
+
setProgress(prevState => [...prevState, message]);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const { sendWorkflowProgressMessage } = useWorkflowFeed(
|
|
84
|
+
handleErrorMessage,
|
|
85
|
+
handleSuccessMessage,
|
|
86
|
+
handleCompleteMessage
|
|
87
|
+
);
|
|
88
|
+
|
|
63
89
|
const handleRaisePr = () => {
|
|
64
90
|
setIsRaising(true);
|
|
65
91
|
setPrHref(null);
|
|
66
92
|
setError(null);
|
|
93
|
+
|
|
67
94
|
try {
|
|
68
|
-
editor.update(
|
|
95
|
+
editor.update(() => {
|
|
69
96
|
const markdown = $convertToMarkdownString(transformers);
|
|
70
97
|
if (markdown && user && persistUrl) {
|
|
71
98
|
const { sid, displayName, email } = user;
|
|
72
|
-
const response = await save(
|
|
73
|
-
{ sid, name: displayName, email },
|
|
74
|
-
meta.route,
|
|
75
|
-
markdown,
|
|
76
|
-
persistUrl
|
|
77
|
-
);
|
|
78
99
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (response.status === 500 || response.status === 404) {
|
|
92
|
-
const errorText = await response.text();
|
|
93
|
-
setError(errorText);
|
|
94
|
-
setPrHref(null);
|
|
95
|
-
setIsRaising(false);
|
|
96
|
-
}
|
|
100
|
+
sendWorkflowProgressMessage(
|
|
101
|
+
JSON.stringify({
|
|
102
|
+
user: { sid, name: displayName, email },
|
|
103
|
+
route: meta.route,
|
|
104
|
+
markdown,
|
|
105
|
+
name: 'save'
|
|
106
|
+
}),
|
|
107
|
+
md5(`${sid.toLowerCase()} - save`)
|
|
108
|
+
);
|
|
97
109
|
}
|
|
98
110
|
});
|
|
99
111
|
} catch (e) {
|
|
100
112
|
setError('Sorry - an unexpected error has occurred');
|
|
101
113
|
setPrHref(null);
|
|
102
114
|
setIsRaising(false);
|
|
115
|
+
setProgress([]);
|
|
103
116
|
}
|
|
104
117
|
};
|
|
105
118
|
|
|
@@ -109,7 +122,7 @@ export const PersistDialog = ({ meta, persistUrl }: PersistDialogProps) => {
|
|
|
109
122
|
{!prHref ? 'Save Changes' : 'Pull Request Created Successfully'}
|
|
110
123
|
</DialogTitle>
|
|
111
124
|
<DialogContent>
|
|
112
|
-
{(isRaising || error) && !prHref && <PersistStatus
|
|
125
|
+
{(isRaising || error) && !prHref && <PersistStatus error={error} progress={progress} />}
|
|
113
126
|
<Info isRaising={isRaising} prHref={prHref} error={error} />
|
|
114
127
|
{!isRaising && prHref && (
|
|
115
128
|
<Link href={prHref} target="_blank">
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import type { SourceWorkflowMessageEvent } from '@jpmorganchase/mosaic-types';
|
|
3
|
+
|
|
4
|
+
const ENDPOINT = process.env.NEXT_PUBLIC_MOSAIC_WORKFLOWS_URL || '';
|
|
5
|
+
|
|
6
|
+
export default function useDataFeed(onError, onSuccess, onComplete) {
|
|
7
|
+
const webSocketRef = useRef<WebSocket>();
|
|
8
|
+
const channelRef = useRef<string | null>();
|
|
9
|
+
|
|
10
|
+
useEffect(function subscribe() {
|
|
11
|
+
try {
|
|
12
|
+
webSocketRef.current = new WebSocket(ENDPOINT);
|
|
13
|
+
webSocketRef.current.onopen = () => console.log(`Workflows websocket open: ${ENDPOINT}`);
|
|
14
|
+
webSocketRef.current.onclose = () => console.log('Workflows websocket closed');
|
|
15
|
+
|
|
16
|
+
webSocketRef.current.onmessage = (msg: MessageEvent) => {
|
|
17
|
+
const message: SourceWorkflowMessageEvent = JSON.parse(msg.data);
|
|
18
|
+
|
|
19
|
+
if (message.channel !== channelRef.current) {
|
|
20
|
+
// message is not for us;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (message.status === 'ERROR') {
|
|
25
|
+
onError(message);
|
|
26
|
+
}
|
|
27
|
+
if (message.status === 'COMPLETE') {
|
|
28
|
+
onComplete(message);
|
|
29
|
+
}
|
|
30
|
+
if (message.status === 'IN_PROGRESS' || message.status === 'SUCCESS') {
|
|
31
|
+
onSuccess(message);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
} catch (ex) {
|
|
35
|
+
onError(ex);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
if (webSocketRef.current && webSocketRef.current?.OPEN) {
|
|
40
|
+
channelRef.current = null;
|
|
41
|
+
webSocketRef.current.close();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
const sendWorkflowProgressMessage = (message, channel) => {
|
|
47
|
+
if (webSocketRef.current?.OPEN) {
|
|
48
|
+
channelRef.current = channel;
|
|
49
|
+
webSocketRef.current?.send(message);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
sendWorkflowProgressMessage
|
|
55
|
+
};
|
|
56
|
+
}
|
package/dist/api/save.d.ts
DELETED
package/dist/api/save.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"../chunk-Z6W7GDHE.js";export{a as save};
|
package/dist/chunk-6EO5B7QP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-6TM3EYFS.js";import e,{useEffect as m,useState as g}from"react";import u from"clsx";import{P2 as S,P6 as c}from"@jpmorganchase/mosaic-components";var o=["Making a copy...","Applying changes...","Creating a Pull Request..."],p=o.length-1,f=({children:l,isComplete:r,isCurrent:s})=>e.createElement("div",{className:u(a.step,{[a.stepComplete]:r,[a.stepActive]:s})},e.createElement("span",{role:"img","aria-label":"emoji with party hat"},r?"\u{1F973}":null),e.createElement("span",{role:"img","aria-label":"person grimacing emoji "},s?"\u{1F603}":null),e.createElement("span",{role:"img","aria-label":"sleepy emoji"},!s&&!r?"\u{1F4A4}":null),e.createElement("span",{className:a.stepText},l),e.createElement("span",{role:"img","aria-label":"hourglass"},s?"\u231B":null)),C=({isRaising:l,error:r})=>{let[s,i]=g(0);return m(()=>{let n=setInterval(()=>{s===o.length-1?clearInterval(n):i(t=>t+1)},2e3);return function(){clearInterval(n)}},[s]),r?e.createElement(e.Fragment,null,e.createElement(S,null,"\u{1F622} Sorry something has went wrong. Please try again later."),e.createElement(c,null,"Error - ",r)):e.createElement(e.Fragment,null,o.map((n,t)=>e.createElement(f,{key:`step -${t}`,isComplete:s===p&&t===p?!l:s>t,isCurrent:s===t},n)))};export{C as a};
|
package/dist/chunk-TVGVMAJS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as y}from"./chunk-6EO5B7QP.js";import{a as S}from"./chunk-R2MEEU32.js";import{a as h}from"./chunk-M4ISRNFD.js";import{c as P,d as C}from"./chunk-G57W376H.js";import{a as b}from"./chunk-Z6W7GDHE.js";import{a as D}from"./chunk-XSZUCLBY.js";import e,{useState as p}from"react";import{useLexicalComposerContext as L}from"@lexical/react/LexicalComposerContext";import{$convertToMarkdownString as N}from"@lexical/markdown";import{Link as F,P2 as k,Button as w}from"@jpmorganchase/mosaic-components";import{ButtonBar as G,DialogTitle as j,DialogContent as M,DialogActions as O}from"@salt-ds/lab";var V=({isRaising:g,prHref:i,error:c})=>!g&&!i&&!c?e.createElement(e.Fragment,null,e.createElement(k,null,"The content of this page resides in a Git repository and to update it requires a Pull Request which will be reviewed by the content owners."),e.createElement("br",null),e.createElement(k,null,"Should you decide to stop editing before creating the Pull Request then all changes will be lost.")):null,ee=({meta:g,persistUrl:i})=>{let{pageState:c,setPageState:B}=P(),{user:m}=C(),[q]=L(),[t,r]=p(!1),[o,s]=p(null),[u,f]=p(null),x=c==="SAVING",I=o!==null?"success":"info",d=n=>{r(n),n||(B("EDIT"),s(null))},T=()=>{d(!1)},v=()=>{r(!0),s(null),f(null);try{q.update(async()=>{let n=N(h);if(n&&m&&i){let{sid:A,displayName:H,email:E}=m,l=await b({sid:A,name:H,email:E},g.route,n,i);if(l.ok){let a=await l.json();a.error?(f(a.error),s(null),r(!1)):(s(a?.links?.self[0]?.href),r(!1))}if(l.status===500||l.status===404){let a=await l.text();f(a),s(null),r(!1)}}})}catch{f("Sorry - an unexpected error has occurred"),s(null),r(!1)}};return e.createElement(D,{onOpenChange:d,open:x,status:u?"error":I},e.createElement(j,{className:S.title},o?"Pull Request Created Successfully":"Save Changes"),e.createElement(M,null,(t||u)&&!o&&e.createElement(y,{isRaising:t,error:u}),e.createElement(V,{isRaising:t,prHref:o,error:u}),!t&&o&&e.createElement(F,{href:o,target:"_blank"},"A Pull Request for your changes has been created")),e.createElement(O,null,e.createElement(G,null,e.createElement(w,{disabled:t,onClick:T},o?"Done":"Cancel"),e.createElement(w,{disabled:i===void 0||t||o!==null,onClick:v,variant:"cta"},"Raise Pull Request"))))};export{ee as a};
|
package/dist/chunk-Z6W7GDHE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function s(n,t,i,e){return fetch(e,{method:"POST",body:JSON.stringify({user:n,route:t,markdown:i,name:"save"}),headers:{Accept:"application/json","Content-Type":"application/json"}})}export{s as a};
|
package/src/api/save.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function save(
|
|
2
|
-
user: { sid: string; name: string; email: string },
|
|
3
|
-
route: string,
|
|
4
|
-
markdown: string,
|
|
5
|
-
persistUrl: string
|
|
6
|
-
) {
|
|
7
|
-
return fetch(persistUrl, {
|
|
8
|
-
method: 'POST',
|
|
9
|
-
body: JSON.stringify({ user, route, markdown, name: 'save' }),
|
|
10
|
-
headers: { Accept: 'application/json', 'Content-Type': 'application/json' }
|
|
11
|
-
});
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { rest } from 'msw';
|
|
2
|
-
|
|
3
|
-
export const postSaveContentSuccessHandler = rest.post('/api/content/save', (req, res, ctx) =>
|
|
4
|
-
res(ctx.status(500), ctx.json({ links: { self: [{ href: 'http://pull-request-url' }] } }))
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
export const postSaveContentFailureHandler = rest.post('/api/content/save', (req, res, ctx) =>
|
|
8
|
-
res(ctx.status(500))
|
|
9
|
-
);
|