From 5e5fd99396cb55042ef49f7ddaec23df59134c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carina=20Akaia=20=F0=9F=A6=BE=F0=9F=A6=8A=F0=9F=AA=90?= =?UTF-8?q?=F0=9F=9A=80=20root=2Eakaia=28=20=2Enear=20=7C=20=2Eeth=20=29?= Date: Thu, 20 Jul 2023 10:27:22 +0400 Subject: [PATCH 01/81] chore: Format --- .../kanban-board-editor.jsx | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/gigs-board/feature/github-integration/kanban-board-editor.jsx b/src/gigs-board/feature/github-integration/kanban-board-editor.jsx index a966fd3e5..979e59d59 100644 --- a/src/gigs-board/feature/github-integration/kanban-board-editor.jsx +++ b/src/gigs-board/feature/github-integration/kanban-board-editor.jsx @@ -101,37 +101,37 @@ const useForm = ({ initialValues, stateKey: formStateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [formStateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [formStateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); - }; + values: updatedValues, + }, + })); + }; if ( !uninitialized && @@ -419,10 +419,12 @@ const GithubKanbanBoardEditor = ({ communityHandle, pageURL }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onSubmit = () => DevHub.edit_community_github({ From 8a525964217bd67a3d83e87f614ac7713dd2b60f Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Sat, 2 Sep 2023 07:24:21 +0400 Subject: [PATCH 02/81] wip: Assign alias for gh ticket author --- .../entity/workspace/github-ticket.jsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gigs-board/entity/workspace/github-ticket.jsx b/src/gigs-board/entity/workspace/github-ticket.jsx index 94786c28a..c4aced668 100644 --- a/src/gigs-board/entity/workspace/github-ticket.jsx +++ b/src/gigs-board/entity/workspace/github-ticket.jsx @@ -38,7 +38,15 @@ const ticketTypes = { }; const GithubTicket = ({ - data: { _links, labels, number, state: ticketState, title, type, user }, + data: { + _links, + labels, + number, + state: ticketState, + title, + type, + user: author, + }, }) => (
@@ -47,17 +55,17 @@ const GithubTicket = ({
{`${user.login}'s - @{user.login} + @{author.login}
From fb7f14127778dc49f399733ae9fc91d281bd846b Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 5 Sep 2023 01:24:25 +0400 Subject: [PATCH 03/81] wip --- .../entity/workspace/github-ticket.jsx | 62 +++--- .../entity/workspace/github-view.jsx | 3 +- .../entity/workspace/kanban-view.jsx | 2 +- .../entity/workspace/post-ticket.jsx | 194 +++++++++--------- .../workspace/github-view-configurator.jsx | 90 ++++---- .../workspace/kanban-view-configurator.jsx | 82 ++++---- 6 files changed, 225 insertions(+), 208 deletions(-) diff --git a/src/gigs-board/entity/workspace/github-ticket.jsx b/src/gigs-board/entity/workspace/github-ticket.jsx index c4aced668..cfc5fd335 100644 --- a/src/gigs-board/entity/workspace/github-ticket.jsx +++ b/src/gigs-board/entity/workspace/github-ticket.jsx @@ -38,6 +38,8 @@ const ticketTypes = { }; const GithubTicket = ({ + config, + data: { _links, labels, @@ -50,39 +52,33 @@ const GithubTicket = ({ }) => (
diff --git a/src/gigs-board/entity/workspace/github-view.jsx b/src/gigs-board/entity/workspace/github-view.jsx index 3f3c361d5..5e5e10677 100644 --- a/src/gigs-board/entity/workspace/github-view.jsx +++ b/src/gigs-board/entity/workspace/github-view.jsx @@ -147,6 +147,7 @@ const withType = (type) => (data) => ({ ...data, type }); const GithubView = ({ columns, + config, dataTypesIncluded, description, isUnderConfiguration, @@ -298,7 +299,7 @@ const GithubView = ({ {(state.ticketsByColumn[column.id] ?? []).map((data) => widget( "entity.workspace.github-ticket", - { data }, + { config: config?.ticket ?? {}, data }, data.id ) )} diff --git a/src/gigs-board/entity/workspace/kanban-view.jsx b/src/gigs-board/entity/workspace/kanban-view.jsx index dbdfe9ca7..0c082faaa 100644 --- a/src/gigs-board/entity/workspace/kanban-view.jsx +++ b/src/gigs-board/entity/workspace/kanban-view.jsx @@ -320,7 +320,7 @@ const KanbanView = ({ {column.postIds.map((postId) => widget( ["entity.workspace", config.ticket_kind].join("."), - { id: postId }, + { id: postId, config: config.ticket ?? {} }, postId ) )} diff --git a/src/gigs-board/entity/workspace/post-ticket.jsx b/src/gigs-board/entity/workspace/post-ticket.jsx index 89af66126..c9ecaa60f 100644 --- a/src/gigs-board/entity/workspace/post-ticket.jsx +++ b/src/gigs-board/entity/workspace/post-ticket.jsx @@ -80,116 +80,120 @@ const AttractableImage = styled.img` `; /* END_INCLUDE: "core/lib/gui/attractable" */ -const postId = props.post.id ?? (props.id ? parseInt(props.id) : 0); -const post = - props.post ?? - Near.view(nearDevGovGigsContractAccountId, "get_post", { post_id: postId }); -if (!post) { - return
Loading ...
; -} -const snapshot = post.snapshot; - -const shareButton = ( - -
-
-); - -const header = ( -
- -
-
+const iconsByPostType = { + Idea: "bi-lightbulb", + Comment: "bi-chat", + Submission: "bi-rocket", + Attestation: "bi-check-circle", + Sponsorship: "bi-cash-coin", +}; + +const authorProfileImageStyle = { + height: "1.5em", + width: "1.5em", + minWidth: "1.5em", +}; + +const PostTicket = ({ id, config, post }) => { + const postId = post.id ?? (id ? parseInt(id) : 0); + + const postData = + post ?? + Near.view(nearDevGovGigsContractAccountId, "get_post", { post_id: postId }); + + if (!postData) { + return
Loading ...
; + } + + const { snapshot } = postData; + + const header = ( +
+
+ {(config.propVisibility.author ?? true) && ( - @{post.author_id} + + @{postData.author_id} -
-
-
{shareButton}
+ )} + + + + +
+
+ ); + + const tagList = + snapshot.labels && (config.propVisibility.tags ?? true) ? ( +
+ {snapshot.labels.map((label) => ( + + {label} + + ))} +
+ ) : null; + + const titleArea = + snapshot.post_type !== "Comment" && + ((config.propVisibility.title ?? true) || + (config.propVisibility.type ?? true)) ? ( +
+
+
+ + + + {`${ + snapshot.post_type === "Submission" + ? "Solution" + : snapshot.post_type + }${typeof snapshot.name === "string" ? ": " : ""}`} + + + {snapshot.name} +
-
-
-); + ) : null; -const emptyIcons = { - Idea: "bi-lightbulb", - Comment: "bi-chat", - Submission: "bi-rocket", - Attestation: "bi-check-circle", - Sponsorship: "bi-cash-coin", -}; + const descriptionArea = + snapshot.post_type == "Comment" ? ( +
+ +
+ ) : null; -const borders = { - Idea: "border-secondary", - Comment: "border-secondary", - Submission: "border-secondary", - Attestation: "border-secondary", - Sponsorship: "border-secondary", -}; + return ( + + {header} -const renamedPostType = - snapshot.post_type == "Submission" ? "Solution" : snapshot.post_type; - -const postLabels = post.snapshot.labels ? ( -
- {post.snapshot.labels.map((label) => ( - - {label} - - ))} -
-) : null; - -const postTitle = - snapshot.post_type == "Comment" ? null : ( -
-
-
- - {renamedPostType}: {snapshot.name} -
+
+ {titleArea} + {descriptionArea} + {tagList}
-
+ ); +}; -const limitedMarkdown = styled.div` - max-height: 6em; -`; - -// Should make sure the posts under the currently top viewed post are limited in size. -const descriptionArea = - snapshot.post_type == "Comment" ? ( - - - - ) : null; - -return ( - - {header} -
- {postTitle} - {descriptionArea} - {postLabels} -
-
-); +return PostTicket(props); diff --git a/src/gigs-board/feature/workspace/github-view-configurator.jsx b/src/gigs-board/feature/workspace/github-view-configurator.jsx index aeb31c7a1..3c6b267f1 100644 --- a/src/gigs-board/feature/workspace/github-view-configurator.jsx +++ b/src/gigs-board/feature/workspace/github-view-configurator.jsx @@ -101,37 +101,37 @@ const useForm = ({ initialValues, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); - }; + values: updatedValues, + }, + })); + }; if ( !uninitialized && @@ -337,7 +337,7 @@ const CompactContainer = styled.div` max-width: 100%; `; -const BoardConfigDefaults = { +const GithubViewDefaults = { id: uuid(), kind: "github-view", columns: {}, @@ -346,13 +346,21 @@ const BoardConfigDefaults = { repoURL: "", ticketState: "all", title: "", + + config: { + ticket: { + propVisibility: { + author: true, + name: true, + labels: true, + title: true, + type: true, + }, + }, + }, }; -const GithubKanbanViewConfigurator = ({ - communityHandle, - link, - permissions, -}) => { +const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { State.init({ editingMode: "form", isActive: false, @@ -394,7 +402,7 @@ const GithubKanbanViewConfigurator = ({ const newViewInit = () => State.update((lastKnownState) => ({ ...lastKnownState, - board: { hasUnsubmittedChanges: false, values: BoardConfigDefaults }, + board: { hasUnsubmittedChanges: false, values: GithubViewDefaults }, isActive: true, })); @@ -411,12 +419,10 @@ const GithubKanbanViewConfigurator = ({ } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onSubmit = () => DevHub.update_community_github({ @@ -712,4 +718,4 @@ const GithubKanbanViewConfigurator = ({ ); }; -return GithubKanbanViewConfigurator(props); +return GithubViewConfigurator(props); diff --git a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx b/src/gigs-board/feature/workspace/kanban-view-configurator.jsx index 80513b020..9f4e101f7 100644 --- a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx +++ b/src/gigs-board/feature/workspace/kanban-view-configurator.jsx @@ -152,37 +152,37 @@ const useForm = ({ initialValues, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); - }; + values: updatedValues, + }, + })); + }; if ( !uninitialized && @@ -345,9 +345,21 @@ const KanbanViewDefaults = { }, config: { - ticket_kind: "post-ticket", - tags: { excluded: [], required: [] }, columns: {}, + tags: { excluded: [], required: [] }, + + ticket: { + propVisibility: { + author: true, + name: true, + replyCount: true, + tags: true, + title: true, + type: true, + }, + }, + + ticket_kind: "post-ticket", }, }; @@ -405,12 +417,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); From fb0d093f331d13e05486add07ec7709201b79432 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 5 Sep 2023 05:02:47 +0400 Subject: [PATCH 04/81] wip --- .../entity/workspace/github-ticket.jsx | 85 +++++++++----- .../entity/workspace/post-ticket.jsx | 105 +++++++++--------- 2 files changed, 107 insertions(+), 83 deletions(-) diff --git a/src/gigs-board/entity/workspace/github-ticket.jsx b/src/gigs-board/entity/workspace/github-ticket.jsx index cfc5fd335..2e794ba36 100644 --- a/src/gigs-board/entity/workspace/github-ticket.jsx +++ b/src/gigs-board/entity/workspace/github-ticket.jsx @@ -49,24 +49,26 @@ const GithubTicket = ({ type, user: author, }, -}) => ( - +}) => { + const header = (
- - {`${author.login}'s - - @{author.login} - + {config.propVisibility?.author ?? true ? ( + + {`${author.login}'s + + @{author.login} + + ) : null}
+ ); -
-
- - + const titleArea = ( +
+ + + {config.propVisibility?.type ?? true ? ( - {`${ticketTypes[type].displayName} #${number}`} + ) : null} + + + {`${ + config.propVisibility?.type ?? true + ? ticketTypes[type].displayName + : "" + } #${number}`.trim()} + - {title} -
+ {config.propVisibility?.title ?? true ? {title} : null} +
+ ); -
- -); + ) : null; + + return ( + + {header} + +
+ {titleArea} + {labelList} +
+
+ ); +}; return GithubTicket(props); diff --git a/src/gigs-board/entity/workspace/post-ticket.jsx b/src/gigs-board/entity/workspace/post-ticket.jsx index c9ecaa60f..78b68d90b 100644 --- a/src/gigs-board/entity/workspace/post-ticket.jsx +++ b/src/gigs-board/entity/workspace/post-ticket.jsx @@ -97,89 +97,88 @@ const authorProfileImageStyle = { const PostTicket = ({ id, config, post }) => { const postId = post.id ?? (id ? parseInt(id) : 0); - const postData = + const data = post ?? Near.view(nearDevGovGigsContractAccountId, "get_post", { post_id: postId }); - if (!postData) { + if (!data) { return
Loading ...
; } - const { snapshot } = postData; + const authorAvatar = ( + + ); const header = (
- ); - const tagList = - snapshot.labels && (config.propVisibility.tags ?? true) ? ( -
- {snapshot.labels.map((label) => ( - - {label} - - ))} -
- ) : null; + const title = [ + config.propVisibility?.type ?? true + ? data.snapshot.post_type === "Submission" + ? "Solution" + : data.snapshot.post_type + : null, + + config.propVisibility?.title ?? true ? data.snapshot.name : null, + ] + .filter((prop) => typeof prop === "string") + .join(": "); const titleArea = - snapshot.post_type !== "Comment" && - ((config.propVisibility.title ?? true) || - (config.propVisibility.type ?? true)) ? ( -
-
-
- - - - {`${ - snapshot.post_type === "Submission" - ? "Solution" - : snapshot.post_type - }${typeof snapshot.name === "string" ? ": " : ""}`} - - - {snapshot.name} -
-
-
+ data.snapshot.post_type !== "Comment" && title.length > 0 ? ( + + + {title} + ) : null; const descriptionArea = - snapshot.post_type == "Comment" ? ( + data.snapshot.post_type === "Comment" && + (config.propVisibility?.type ?? true) ? (
- + +
+ ) : null; + + const tagList = + data.snapshot.labels && (config.propVisibility?.tags ?? true) ? ( +
+ {data.snapshot.labels.map((label) => ( + + {label} + + ))}
) : null; @@ -187,7 +186,7 @@ const PostTicket = ({ id, config, post }) => { {header} -
+
{titleArea} {descriptionArea} {tagList} From a9ed58e0dd99ab1305024d84db7984249809e9ad Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 6 Sep 2023 13:18:37 +0400 Subject: [PATCH 05/81] wip --- module/core/lib/gui/form.js | 9 +- src/gigs-board/components/atom/toggle.jsx | 9 +- .../components/molecule/breadcrumbs.jsx | 6 +- src/gigs-board/components/molecule/tile.jsx | 13 +- .../components/organism/configurator.jsx | 150 +++++++++------- .../community/branding-configurator.jsx | 5 +- .../entity/community/configurator.jsx | 20 ++- src/gigs-board/entity/community/layout.jsx | 6 +- src/gigs-board/entity/community/sidebar.jsx | 20 +-- .../entity/workspace/github-ticket.jsx | 3 +- .../entity/workspace/post-ticket.jsx | 12 +- .../workspace/github-view-configurator.jsx | 84 ++++----- .../workspace/kanban-view-configurator.jsx | 160 +++++++++++------- src/gigs-board/pages/community/github.jsx | 14 +- src/gigs-board/pages/community/teams.jsx | 37 ++-- src/gigs-board/pages/community/wiki.jsx | 2 +- 16 files changed, 309 insertions(+), 241 deletions(-) diff --git a/module/core/lib/gui/form.js b/module/core/lib/gui/form.js index 88b6c1b31..44ab31b5e 100644 --- a/module/core/lib/gui/form.js +++ b/module/core/lib/gui/form.js @@ -31,7 +31,7 @@ const defaultFieldUpdate = ({ } }; -const useForm = ({ initialValues, stateKey, uninitialized }) => { +const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { const initialFormState = { hasUnsubmittedChanges: false, values: initialValues ?? {}, @@ -77,6 +77,13 @@ const useForm = ({ initialValues, stateKey, uninitialized }) => { values: updatedValues, }, })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } }; if ( diff --git a/src/gigs-board/components/atom/toggle.jsx b/src/gigs-board/components/atom/toggle.jsx index a81b7d9bf..951a02d79 100644 --- a/src/gigs-board/components/atom/toggle.jsx +++ b/src/gigs-board/components/atom/toggle.jsx @@ -43,13 +43,13 @@ const ToggleLabel = styled.label` `; const Toggle = ({ - active, className, direction, disabled, key, label, onSwitch, + value: checked, ...rest }) => ( {label} {!disabled && } diff --git a/src/gigs-board/components/molecule/breadcrumbs.jsx b/src/gigs-board/components/molecule/breadcrumbs.jsx index 75c592e13..d78875a9f 100644 --- a/src/gigs-board/components/molecule/breadcrumbs.jsx +++ b/src/gigs-board/components/molecule/breadcrumbs.jsx @@ -73,11 +73,9 @@ const Breadcrumbs = ({ classNames, path }) => ( ].join(" ")} > {label} diff --git a/src/gigs-board/components/molecule/tile.jsx b/src/gigs-board/components/molecule/tile.jsx index 7d58dfb7d..b8b8e22a8 100644 --- a/src/gigs-board/components/molecule/tile.jsx +++ b/src/gigs-board/components/molecule/tile.jsx @@ -29,6 +29,7 @@ const AttractableImage = styled.img` const Tile = ({ children, + className, fullWidth, headerSlotRight, heading, @@ -42,17 +43,15 @@ const Tile = ({ }) => ( { diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index d47352e18..b0dfadf59 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -136,7 +136,7 @@ const defaultFieldUpdate = ({ } }; -const useForm = ({ initialValues, stateKey, uninitialized }) => { +const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { const initialFormState = { hasUnsubmittedChanges: false, values: initialValues ?? {}, @@ -182,6 +182,13 @@ const useForm = ({ initialValues, stateKey, uninitialized }) => { values: updatedValues, }, })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } }; if ( @@ -201,7 +208,7 @@ const useForm = ({ initialValues, stateKey, uninitialized }) => { }; /* END_INCLUDE: "core/lib/gui/form" */ -const ValueWrapper = styled.div` +const ValueView = styled.div` & > p { margin: 0; } @@ -214,7 +221,7 @@ const fieldParamsByType = { }, boolean: { - name: "components.atom.switch", + name: "components.atom.toggle", }, string: { @@ -227,69 +234,74 @@ const defaultFieldsRender = ({ schema, form, isEditable }) => ( <> {Object.entries(schema).map( ( - [fieldKey, { format, inputProps, label, order, style, ...fieldProps }], + [key, { format, inputProps, label, order, style, ...fieldProps }], idx ) => { - const contentDisplayClassName = [ - (form.values[fieldKey]?.length ?? 0) > 0 ? "" : "text-muted", - "m-0", - ].join(" "); + const fieldKey = `${idx}-${key}`, + fieldValue = form.values[key]; - const fieldType = Array.isArray(form.values[fieldKey]) + const fieldType = Array.isArray(fieldValue) ? "array" - : typeof (form.values[fieldKey] ?? ""); + : typeof (fieldValue ?? ""); + + const viewClassName = [ + (fieldValue?.length ?? 0) > 0 ? "" : "text-muted", + "m-0", + ].join(" "); return ( <> - {!isEditable ? ( -
- - - - {format !== "markdown" ? ( - - {(fieldType === "array" && format === "comma-separated" - ? form.values[fieldKey] - .filter((string) => string.length > 0) - .join(", ") - : form.values[fieldKey] - )?.toString?.() || "none"} - - ) : (form.values[fieldKey]?.length ?? 0) > 0 ? ( - - ) : ( - none - )} - -
- ) : ( - widget(fieldParamsByType[fieldType].name, { - ...fieldProps, - className: "w-100", - format, - key: `${idx}-${fieldKey}--editable`, - label, - onChange: form.update({ path: [fieldKey] }), - style: { ...style, order }, - - value: - fieldType === "array" && format === "comma-separated" - ? form.values[fieldKey].join(", ") - : form.values[fieldKey], - - inputProps: { - ...(inputProps ?? {}), - ...(fieldParamsByType[fieldType].inputProps ?? {}), - tabIndex: order, - }, - }) - )} +
+ + + + {format !== "markdown" ? ( + + {(fieldType === "array" && format === "comma-separated" + ? fieldValue + .filter((string) => string.length > 0) + .join(", ") + : fieldValue + )?.toString?.() || "none"} + + ) : (fieldValue?.length ?? 0) > 0 ? ( + + ) : ( + none + )} + +
+ + {widget(fieldParamsByType[fieldType].name, { + ...fieldProps, + + className: [ + "w-100", + fieldProps.className ?? "", + isEditable ? "" : "d-none", + ].join(" "), + + format, + key: `${fieldKey}--editable`, + label, + onChange: form.update({ path: [key] }), + style: { ...style, order }, + + value: + fieldType === "array" && format === "comma-separated" + ? fieldValue.join(", ") + : fieldValue, + + inputProps: { + ...(inputProps ?? {}), + ...(fieldParamsByType[fieldType].inputProps ?? {}), + tabIndex: order, + }, + })} ); } @@ -307,12 +319,14 @@ const Configurator = ({ fullWidth, heading, isActive, + isEmbedded, isHidden, - isSubform, isUnlocked, isValid, + noBorder, noFrame, onCancel, + onChange, onSubmit, schema, submitIcon, @@ -332,7 +346,7 @@ const Configurator = ({ ? Struct.pick(data ?? {}, Object.keys(schema)) : {}; - const form = useForm({ initialValues, stateKey: "form" }); + const form = useForm({ initialValues, onUpdate: onChange, stateKey: "form" }); const formFormattedValues = typeof toFormatted === "function" ? toFormatted(form.values) : form.values; @@ -349,7 +363,7 @@ const Configurator = ({ const onCancelClick = () => { if (!isActive) formToggle(false); form.reset(); - if (isSubform && typeof onSubmit === "function") onSubmit(initialValues); + if (isEmbedded && typeof onSubmit === "function") onSubmit(initialValues); if (typeof onCancel === "function") onCancel(); }; @@ -366,6 +380,7 @@ const Configurator = ({ fullWidth, heading, isHidden, + noBorder, noFrame, ...otherProps, @@ -391,8 +406,15 @@ const Configurator = ({ })}
- {!noFrame && isUnlocked && state.isActive ? ( -
+ {!noFrame ? ( +
{actionsAdditional ? (
{actionsAdditional}
) : null} diff --git a/src/gigs-board/entity/community/branding-configurator.jsx b/src/gigs-board/entity/community/branding-configurator.jsx index 74e801ba7..50bc9e771 100644 --- a/src/gigs-board/entity/community/branding-configurator.jsx +++ b/src/gigs-board/entity/community/branding-configurator.jsx @@ -243,10 +243,7 @@ const CommunityBrandingConfigurator = ({ } return ( - + { return community.isLoading ? (
Loading...
) : ( -
+
{community.data === null ? (
{ {widget("components.organism.configurator", { heading: "Community information", data: state.communityData, - isSubform: true, + fullWidth: true, + isEmbedded: true, isUnlocked: permissions.can_configure, onSubmit: sectionSubmit, schema: CommunityInformationSchema, @@ -413,7 +417,8 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "About", data: state.communityData, - isSubform: true, + fullWidth: true, + isEmbedded: true, isUnlocked: permissions.can_configure, onSubmit: sectionSubmit, schema: CommunityAboutSchema, @@ -423,8 +428,9 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "Access control", data: state.communityData, + fullWidth: true, formatter: communityAccessControlFormatter, - isSubform: true, + isEmbedded: true, isUnlocked: permissions.can_configure, onSubmit: sectionSubmit, schema: CommunityAccessControlSchema, @@ -434,7 +440,8 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "Wiki page 1", data: state.communityData?.wiki1, - isSubform: true, + fullWidth: true, + isEmbedded: true, isUnlocked: permissions.can_configure, onSubmit: (value) => sectionSubmit({ wiki1: value }), submitLabel: "Accept", @@ -444,7 +451,8 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "Wiki page 2", data: state.communityData?.wiki2, - isSubform: true, + fullWidth: true, + isEmbedded: true, isUnlocked: permissions.can_configure, onSubmit: (value) => sectionSubmit({ wiki2: value }), submitLabel: "Accept", diff --git a/src/gigs-board/entity/community/layout.jsx b/src/gigs-board/entity/community/layout.jsx index 85162678c..9fdf4460e 100644 --- a/src/gigs-board/entity/community/layout.jsx +++ b/src/gigs-board/entity/community/layout.jsx @@ -67,7 +67,11 @@ const CommunityLayout = ({ children, handle, noHeader, path, title }) => ), children: - typeof handle === "string" ?
{children}
: null, + typeof handle === "string" ? ( +
+ {children} +
+ ) : null, }); return CommunityLayout(props); diff --git a/src/gigs-board/entity/community/sidebar.jsx b/src/gigs-board/entity/community/sidebar.jsx index 46791ce36..e45649428 100644 --- a/src/gigs-board/entity/community/sidebar.jsx +++ b/src/gigs-board/entity/community/sidebar.jsx @@ -203,21 +203,13 @@ const CommunitySummary = (community) => { const UserList = (users) => { return ( -
+
{users.map((user, i) => ( -
-
- - {widget("components.molecule.profile-card", { - accountId: user, - })} - -
-
+ + {widget("components.molecule.profile-card", { + accountId: user, + })} + ))}
); diff --git a/src/gigs-board/entity/workspace/github-ticket.jsx b/src/gigs-board/entity/workspace/github-ticket.jsx index 2e794ba36..ab27bf980 100644 --- a/src/gigs-board/entity/workspace/github-ticket.jsx +++ b/src/gigs-board/entity/workspace/github-ticket.jsx @@ -64,9 +64,10 @@ const GithubTicket = ({ alt={`${author.login}'s GitHub avatar`} className="img-fluid rounded" src={author.avatar_url} + style={{ width: 24, height: 24 }} /> - @{author.login} + @{author.login} ) : null} diff --git a/src/gigs-board/entity/workspace/post-ticket.jsx b/src/gigs-board/entity/workspace/post-ticket.jsx index 78b68d90b..94753820c 100644 --- a/src/gigs-board/entity/workspace/post-ticket.jsx +++ b/src/gigs-board/entity/workspace/post-ticket.jsx @@ -88,12 +88,6 @@ const iconsByPostType = { Sponsorship: "bi-cash-coin", }; -const authorProfileImageStyle = { - height: "1.5em", - width: "1.5em", - minWidth: "1.5em", -}; - const PostTicket = ({ id, config, post }) => { const postId = post.id ?? (id ? parseInt(id) : 0); @@ -112,7 +106,11 @@ const PostTicket = ({ id, config, post }) => { metadata, accountId: data.author_id, widgetName, - style: authorProfileImageStyle, + style: { + height: "1.5em", + width: "1.5em", + minWidth: "1.5em", + }, }} /> ); diff --git a/src/gigs-board/feature/workspace/github-view-configurator.jsx b/src/gigs-board/feature/workspace/github-view-configurator.jsx index 3c6b267f1..7ce473f9f 100644 --- a/src/gigs-board/feature/workspace/github-view-configurator.jsx +++ b/src/gigs-board/feature/workspace/github-view-configurator.jsx @@ -85,7 +85,7 @@ const defaultFieldUpdate = ({ } }; -const useForm = ({ initialValues, stateKey, uninitialized }) => { +const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { const initialFormState = { hasUnsubmittedChanges: false, values: initialValues ?? {}, @@ -101,37 +101,44 @@ const useForm = ({ initialValues, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); - }; + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -351,7 +358,6 @@ const GithubViewDefaults = { ticket: { propVisibility: { author: true, - name: true, labels: true, title: true, type: true, @@ -419,10 +425,12 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onSubmit = () => DevHub.update_community_github({ @@ -479,7 +487,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { "components.atom.toggle", { - active: enabled, + value: enabled, className: "w-100", key: typeName, label: typeName, @@ -614,9 +622,9 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { `Community with handle ${communityHandle} not found.`)}
) : ( -
+
{state.isActive && Object.keys(form.values).length > 0 ? ( - +
@@ -686,7 +694,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { Save
- +
) : null} {Object.keys(form.values).length > 0 ? ( diff --git a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx b/src/gigs-board/feature/workspace/kanban-view-configurator.jsx index 9f4e101f7..c7033eb8d 100644 --- a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx +++ b/src/gigs-board/feature/workspace/kanban-view-configurator.jsx @@ -136,7 +136,7 @@ const defaultFieldUpdate = ({ } }; -const useForm = ({ initialValues, stateKey, uninitialized }) => { +const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { const initialFormState = { hasUnsubmittedChanges: false, values: initialValues ?? {}, @@ -152,37 +152,44 @@ const useForm = ({ initialValues, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - }; + }; if ( !uninitialized && @@ -337,6 +344,30 @@ const KanbanViewConfiguratorSettings = { maxColumnsNumber: 10, }; +const TagsSchema = { + required: { + label: + "Enter tags you want to include. Posts with these tags will display.", + + placeholder: "tag1, tag2", + }, + + excluded: { + label: + "Enter tags you want to exclude. Posts with these tags will not show.", + + placeholder: "tag3, tag4", + }, +}; + +const TicketFeaturesSchema = { + author: { label: "Author" }, + replyCount: { label: "Reply count" }, + tags: { label: "Tags" }, + title: { label: "Post title" }, + type: { label: "Post type" }, +}; + const KanbanViewDefaults = { metadata: { kind: "kanban-view", @@ -351,7 +382,6 @@ const KanbanViewDefaults = { ticket: { propVisibility: { author: true, - name: true, replyCount: true, tags: true, title: true, @@ -417,10 +447,12 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); @@ -460,37 +492,37 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { value: form.values.metadata.description, })} - -
- {widget("components.molecule.text-input", { - className: "flex-shrink-0", - format: "comma-separated", - key: "kanban-view-tags-required", +
+ {widget("components.organism.configurator", { + heading: "Tags", + classNames: { root: "col-12 col-md-8" }, + data: form.values.config.tags, + isActive: true, + isEmbedded: true, + isUnlocked: permissions.can_configure, + onChange: form.update({ path: ["config", "tags"] }), + schema: TagsSchema, + })} - label: - "Enter tags you want to include. Posts with these tags will display.", + {widget("components.organism.configurator", { + heading: "Ticket features", + classNames: { root: "col-12 col-md-4" }, - onChange: form.update({ path: ["config", "tags", "required"] }), - placeholder: "tag1, tag2", - value: form.values.config.tags.required.join(", "), - })} -
+ data: + form.values.config.ticket?.propVisibility ?? + KanbanViewDefaults.config.ticket.propVisibility, -
- {widget("components.molecule.text-input", { - className: "flex-shrink-0", - format: "comma-separated", - key: "kanban-view-tags-excluded", + isActive: true, + isEmbedded: true, + isUnlocked: permissions.can_configure, - label: - "Enter tags you want to exclude. Posts with these tags will not show.", + onChange: form.update({ + path: ["config", "ticket", "propVisibility"], + }), - onChange: form.update({ path: ["config", "tags", "excluded"] }), - placeholder: "tag3, tag4", - value: form.values.config.tags.excluded.join(", "), - })} -
- + schema: TicketFeaturesSchema, + })} +
@@ -576,7 +608,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { ) : (
{isViewInitialized && state.isActive ? ( - +
@@ -646,7 +678,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { Save
- +
) : null} {isViewInitialized ? ( diff --git a/src/gigs-board/pages/community/github.jsx b/src/gigs-board/pages/community/github.jsx index e0dc17504..282bd7481 100644 --- a/src/gigs-board/pages/community/github.jsx +++ b/src/gigs-board/pages/community/github.jsx @@ -159,15 +159,11 @@ const CommunityGithubPage = ({ handle }) => { handle, title: "GitHub", - children: ( -
- {widget("feature.workspace.github-view-configurator", { - communityHandle: handle, - link: "near.org" + href("community.github", { handle }), - permissions, - })} -
- ), + children: widget("feature.workspace.github-view-configurator", { + communityHandle: handle, + link: "near.org" + href("community.github", { handle }), + permissions, + }), }); }; diff --git a/src/gigs-board/pages/community/teams.jsx b/src/gigs-board/pages/community/teams.jsx index 23f1da16b..e43f1d6de 100644 --- a/src/gigs-board/pages/community/teams.jsx +++ b/src/gigs-board/pages/community/teams.jsx @@ -174,24 +174,29 @@ const UserList = (name, users) => { ); }; -const Teams = ( -
- {widget("components.molecule.tile", { - heading: "Admins", - minHeight: 0, - children: UserList("Admin", admins), - })} - {widget("components.molecule.tile", { - heading: "Community Moderators", - minHeight: 0, - children: UserList("Moderator", moderators), - })} -
-); - return widget("entity.community.layout", { path: [{ label: "Communities", pageId: "communities" }], handle: props.handle, title: "Teams", - children: Teams, + + children: ( +
+ {widget("components.molecule.tile", { + heading: "Admins", + fullWidth: true, + minHeight: 0, + children: UserList("Admin", admins), + })} + + {widget("components.molecule.tile", { + heading: "Community Moderators", + fullWidth: true, + minHeight: 0, + children: UserList("Moderator", moderators), + })} +
+ ), }); diff --git a/src/gigs-board/pages/community/wiki.jsx b/src/gigs-board/pages/community/wiki.jsx index 5e762a6b7..2ef0d06ce 100644 --- a/src/gigs-board/pages/community/wiki.jsx +++ b/src/gigs-board/pages/community/wiki.jsx @@ -162,7 +162,7 @@ const WikiPage = ({ handle, id }) => { children: communityData !== null ? ( -
+
) : ( From a0ea45f1808ab3cae740880772f04d0fb6094433 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 6 Sep 2023 13:49:26 +0400 Subject: [PATCH 06/81] wip --- src/gigs-board/components/molecule/tile.jsx | 12 +++++++--- src/gigs-board/entity/community/sidebar.jsx | 26 ++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/gigs-board/components/molecule/tile.jsx b/src/gigs-board/components/molecule/tile.jsx index b8b8e22a8..19b9c4e79 100644 --- a/src/gigs-board/components/molecule/tile.jsx +++ b/src/gigs-board/components/molecule/tile.jsx @@ -29,6 +29,7 @@ const AttractableImage = styled.img` const Tile = ({ children, + borderRadius, className, fullWidth, headerSlotRight, @@ -36,10 +37,10 @@ const Tile = ({ headingAdornment, id, isHidden, + noBorder, noFrame, minHeight, - noBorder, - borderRadius, + style, }) => ( { diff --git a/src/gigs-board/entity/community/sidebar.jsx b/src/gigs-board/entity/community/sidebar.jsx index e45649428..2425027ed 100644 --- a/src/gigs-board/entity/community/sidebar.jsx +++ b/src/gigs-board/entity/community/sidebar.jsx @@ -201,20 +201,6 @@ const CommunitySummary = (community) => { ); }; -const UserList = (users) => { - return ( -
- {users.map((user, i) => ( - - {widget("components.molecule.profile-card", { - accountId: user, - })} - - ))} -
- ); -}; - const Sidebar = ({ handle }) => { const community = DevHub.get_community({ handle }) ?? null; @@ -229,7 +215,7 @@ const Sidebar = ({ handle }) => { return community === null ? (
Loading...
) : ( -
+
{widget("components.molecule.tile", { minHeight: 0, children: CommunitySummary(community), @@ -241,10 +227,18 @@ const Sidebar = ({ handle }) => { {widget("components.molecule.tile", { heading: "Admins", + + children: (community?.admins ?? []).map((accountId) => ( +
+ {widget("components.molecule.profile-card", { accountId })} +
+ )), + + fullWidth: true, minHeight: 0, - children: UserList(community.admins), noBorder: true, borderRadius: "rounded", + style: { overflowX: "scroll" }, })}
); From f82a4aae2b54f149cf0b11bbf93f5ccafe2e06f7 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 6 Sep 2023 14:40:21 +0400 Subject: [PATCH 07/81] wip --- .../components/organism/configurator.jsx | 79 ++++++++-------- .../workspace/github-view-configurator.jsx | 78 ++++++++-------- .../workspace/kanban-view-configurator.jsx | 93 ++++++++++--------- 3 files changed, 126 insertions(+), 124 deletions(-) diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index b0dfadf59..f4b1e537b 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -152,44 +152,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, } - }; + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -314,6 +314,7 @@ const Configurator = ({ cancelLabel, classNames, data, + fieldGap, fieldsRender: customFieldsRender, formatter: toFormatted, fullWidth, @@ -397,7 +398,9 @@ const Configurator = ({ children: (
{fieldsRender({ form, diff --git a/src/gigs-board/feature/workspace/github-view-configurator.jsx b/src/gigs-board/feature/workspace/github-view-configurator.jsx index 7ce473f9f..b9edaf45e 100644 --- a/src/gigs-board/feature/workspace/github-view-configurator.jsx +++ b/src/gigs-board/feature/workspace/github-view-configurator.jsx @@ -101,44 +101,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); + values: updatedValues, + }, + })); - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -425,12 +425,10 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onSubmit = () => DevHub.update_community_github({ diff --git a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx b/src/gigs-board/feature/workspace/kanban-view-configurator.jsx index c7033eb8d..f21d7e6a2 100644 --- a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx +++ b/src/gigs-board/feature/workspace/kanban-view-configurator.jsx @@ -152,44 +152,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, } - }; + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -412,6 +412,8 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { uninitialized: (view.metadata ?? null) === null, }); + console.log(form.values); + const isViewInitialized = (form.values.metadata ?? null) !== null; const formToggle = (forcedState) => @@ -447,12 +449,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); @@ -492,10 +492,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { value: form.values.metadata.description, })} -
+
{widget("components.organism.configurator", { heading: "Tags", - classNames: { root: "col-12 col-md-8" }, + classNames: { root: "col-12 col-md-7 col-lg-8" }, data: form.values.config.tags, isActive: true, isEmbedded: true, @@ -506,12 +506,13 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { {widget("components.organism.configurator", { heading: "Ticket features", - classNames: { root: "col-12 col-md-4" }, + classNames: { root: "col-12 col-md-4 col-lg-3" }, data: form.values.config.ticket?.propVisibility ?? KanbanViewDefaults.config.ticket.propVisibility, + fieldGap: 3, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, From ffe44c855975d41a19f8ee1e1f5d3f65f1d519a7 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 8 Sep 2023 11:30:39 +0400 Subject: [PATCH 08/81] wip --- .../components/organism/configurator.jsx | 8 +- .../entity/community/configurator.jsx | 10 +- src/gigs-board/entity/community/spawner.jsx | 2 +- .../kanban-github.jsx} | 0 .../kanban-post.jsx} | 4 +- .../view/github-configurator.jsx} | 124 ++++++++++-------- .../github-view.jsx => view/github.jsx} | 10 +- .../view/kanban-configurator.jsx} | 49 +++---- .../kanban-view.jsx => view/kanban.jsx} | 10 +- src/gigs-board/pages/community/board.jsx | 2 +- src/gigs-board/pages/community/github.jsx | 2 +- 11 files changed, 129 insertions(+), 92 deletions(-) rename src/gigs-board/entity/{workspace/github-ticket.jsx => ticket/kanban-github.jsx} (100%) rename src/gigs-board/entity/{workspace/post-ticket.jsx => ticket/kanban-post.jsx} (98%) rename src/gigs-board/{feature/workspace/github-view-configurator.jsx => entity/view/github-configurator.jsx} (92%) rename src/gigs-board/entity/{workspace/github-view.jsx => view/github.jsx} (97%) rename src/gigs-board/{feature/workspace/kanban-view-configurator.jsx => entity/view/kanban-configurator.jsx} (95%) rename src/gigs-board/entity/{workspace/kanban-view.jsx => view/kanban.jsx} (97%) diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index f4b1e537b..e909ad101 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -230,7 +230,7 @@ const fieldParamsByType = { }, }; -const defaultFieldsRender = ({ schema, form, isEditable }) => ( +const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( <> {Object.entries(schema).map( ( @@ -297,6 +297,7 @@ const defaultFieldsRender = ({ schema, form, isEditable }) => ( : fieldValue, inputProps: { + disabled: !isUnlocked, ...(inputProps ?? {}), ...(fieldParamsByType[fieldType].inputProps ?? {}), tabIndex: order, @@ -313,7 +314,7 @@ const Configurator = ({ actionsAdditional, cancelLabel, classNames, - data, + externalState, fieldGap, fieldsRender: customFieldsRender, formatter: toFormatted, @@ -344,7 +345,7 @@ const Configurator = ({ }); const initialValues = Struct.typeMatch(schema) - ? Struct.pick(data ?? {}, Object.keys(schema)) + ? Struct.pick(externalState ?? {}, Object.keys(schema)) : {}; const form = useForm({ initialValues, onUpdate: onChange, stateKey: "form" }); @@ -405,6 +406,7 @@ const Configurator = ({ {fieldsRender({ form, isEditable: isUnlocked && state.isActive, + isUnlocked, schema, })}
diff --git a/src/gigs-board/entity/community/configurator.jsx b/src/gigs-board/entity/community/configurator.jsx index db083d79f..a8af102fa 100644 --- a/src/gigs-board/entity/community/configurator.jsx +++ b/src/gigs-board/entity/community/configurator.jsx @@ -405,7 +405,7 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "Community information", - data: state.communityData, + externalState: state.communityData, fullWidth: true, isEmbedded: true, isUnlocked: permissions.can_configure, @@ -416,7 +416,7 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "About", - data: state.communityData, + externalState: state.communityData, fullWidth: true, isEmbedded: true, isUnlocked: permissions.can_configure, @@ -427,7 +427,7 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "Access control", - data: state.communityData, + externalState: state.communityData, fullWidth: true, formatter: communityAccessControlFormatter, isEmbedded: true, @@ -439,7 +439,7 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "Wiki page 1", - data: state.communityData?.wiki1, + externalState: state.communityData?.wiki1, fullWidth: true, isEmbedded: true, isUnlocked: permissions.can_configure, @@ -450,7 +450,7 @@ const CommunityConfigurator = ({ handle, link }) => { {widget("components.organism.configurator", { heading: "Wiki page 2", - data: state.communityData?.wiki2, + externalState: state.communityData?.wiki2, fullWidth: true, isEmbedded: true, isUnlocked: permissions.can_configure, diff --git a/src/gigs-board/entity/community/spawner.jsx b/src/gigs-board/entity/community/spawner.jsx index f4750a8ad..fd424c18a 100644 --- a/src/gigs-board/entity/community/spawner.jsx +++ b/src/gigs-board/entity/community/spawner.jsx @@ -278,7 +278,7 @@ const onCommunitySubmit = (inputs) => const CommunitySpawner = ({ isHidden, ...otherProps }) => widget("components.organism.configurator", { heading: "Community information", - data: CommunityInputsDefaults, + externalState: CommunityInputsDefaults, fullWidth: true, isActive: true, isHidden, diff --git a/src/gigs-board/entity/workspace/github-ticket.jsx b/src/gigs-board/entity/ticket/kanban-github.jsx similarity index 100% rename from src/gigs-board/entity/workspace/github-ticket.jsx rename to src/gigs-board/entity/ticket/kanban-github.jsx diff --git a/src/gigs-board/entity/workspace/post-ticket.jsx b/src/gigs-board/entity/ticket/kanban-post.jsx similarity index 98% rename from src/gigs-board/entity/workspace/post-ticket.jsx rename to src/gigs-board/entity/ticket/kanban-post.jsx index 94753820c..bc0a57e2b 100644 --- a/src/gigs-board/entity/workspace/post-ticket.jsx +++ b/src/gigs-board/entity/ticket/kanban-post.jsx @@ -88,7 +88,7 @@ const iconsByPostType = { Sponsorship: "bi-cash-coin", }; -const PostTicket = ({ id, config, post }) => { +const KanbanPostTicket = ({ id, config, post }) => { const postId = post.id ?? (id ? parseInt(id) : 0); const data = @@ -193,4 +193,4 @@ const PostTicket = ({ id, config, post }) => { ); }; -return PostTicket(props); +return KanbanPostTicket(props); diff --git a/src/gigs-board/feature/workspace/github-view-configurator.jsx b/src/gigs-board/entity/view/github-configurator.jsx similarity index 92% rename from src/gigs-board/feature/workspace/github-view-configurator.jsx rename to src/gigs-board/entity/view/github-configurator.jsx index b9edaf45e..c3a8511d1 100644 --- a/src/gigs-board/feature/workspace/github-view-configurator.jsx +++ b/src/gigs-board/entity/view/github-configurator.jsx @@ -356,7 +356,9 @@ const GithubViewDefaults = { config: { ticket: { - propVisibility: { + type: "kanban-ticket", + kind: "github", + features: { author: true, labels: true, title: true, @@ -366,6 +368,18 @@ const GithubViewDefaults = { }, }; +const TicketFeaturesSchema = { + author: { label: "Author" }, + labels: { label: "Labels" }, + title: { label: "Title" }, + type: { label: "Type" }, +}; + +const TicketTypesSchema = { + Issue: { label: "Issue" }, + PullRequest: { label: "Pull Request" }, +}; + const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { State.init({ editingMode: "form", @@ -449,7 +463,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { {widget( "components.molecule.text-input", { - className: "flex-shrink-0", + className: "w-100", key: `${form.values.id}-title`, label: "Title", onChange: form.update({ path: ["title"] }), @@ -467,43 +481,38 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { placeholder: "https://github.com/example-org/example-repo", value: form.values.repoURL, })} -
-
- - - - Ticket type - + {widget("components.molecule.text-input", { + className: "w-100", + key: `${form.values.id}-column-${id}-description`, + label: "Description", - {Object.entries(form.values.dataTypesIncluded ?? {}).map( - ([typeName, enabled]) => - widget( - "components.atom.toggle", + onChange: form.update({ + path: ["columns", id, "description"], + }), - { - value: enabled, - className: "w-100", - key: typeName, - label: typeName, + placeholder: "NEPs that need a review by Subject Matter Experts.", - onSwitch: form.update({ - path: ["dataTypesIncluded", typeName], - }), - }, + value: description, + })} +
- typeName - ) - )} - +
+ {widget("components.organism.configurator", { + heading: "Ticket types", + classNames: { root: "col-12 col-md-7 col-lg-8" }, + externalState: form.values.dataTypesIncluded, + isActive: true, + isEmbedded: true, + isUnlocked: permissions.can_configure, + onChange: form.update({ path: ["dataTypesIncluded"] }), + schema: TicketTypesSchema, + })} Ticket state @@ -524,15 +533,20 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { })} - {widget("components.molecule.text-input", { - className: "w-100", - inputProps: { className: "h-75" }, - key: `${form.values.id}-description`, - label: "Description", - multiline: true, - onChange: form.update({ path: ["description"] }), - placeholder: "Latest NEAR Enhancement Proposals by status.", - value: form.values.description, + {widget("components.organism.configurator", { + heading: "Ticket features", + classNames: { root: "col-12 col-md-4 col-lg-3" }, + + externalState: + form.values.config.ticket?.features ?? + GithubViewDefaults.config.ticket.features, + + fieldGap: 3, + isActive: true, + isEmbedded: true, + isUnlocked: permissions.can_configure, + onChange: form.update({ path: ["config", "ticket", "features"] }), + schema: TicketFeaturesSchema, })}
@@ -560,21 +574,6 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { value: title, })} - {widget("components.molecule.text-input", { - className: "flex-grow-1", - key: `${form.values.id}-column-${id}-description`, - label: "Description", - - onChange: form.update({ - path: ["columns", id, "description"], - }), - - placeholder: - "NEPs that need a review by Subject Matter Experts.", - - value: description, - })} - {widget("components.molecule.text-input", { format: "comma-separated", key: `${form.values.id}-column-${title}-labelSearchTerms`, @@ -589,6 +588,21 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { placeholder: "WG-, draft, review, proposal, ...", value: labelSearchTerms.join(", "), })} + + {widget("components.molecule.text-input", { + className: "flex-grow-1", + key: `${form.values.id}-column-${id}-description`, + label: "Description", + + onChange: form.update({ + path: ["columns", id, "description"], + }), + + placeholder: + "NEPs that need a review by Subject Matter Experts.", + + value: description, + })}
{ ) : null} {Object.keys(form.values).length > 0 ? ( - widget("entity.workspace.github-view", { + widget("entity.view.github", { ...form.values, isUnderConfiguration: state.isActive, link, diff --git a/src/gigs-board/entity/workspace/github-view.jsx b/src/gigs-board/entity/view/github.jsx similarity index 97% rename from src/gigs-board/entity/workspace/github-view.jsx rename to src/gigs-board/entity/view/github.jsx index 5e5e10677..0dbc0b25e 100644 --- a/src/gigs-board/entity/workspace/github-view.jsx +++ b/src/gigs-board/entity/view/github.jsx @@ -158,6 +158,14 @@ const GithubView = ({ ticketState, title, }) => { + const ticketViewId = [ + "entity.ticket", + + typeof config?.ticket?.type === "string" + ? [config.ticket.type.split("-")[0], config.ticket.kind].join("-") + : "kanban-github", + ].join("."); + const ticketStateFilter = ticketState === "open" || ticketState === "closed" || ticketState === "all" ? ticketState @@ -298,7 +306,7 @@ const GithubView = ({
{(state.ticketsByColumn[column.id] ?? []).map((data) => widget( - "entity.workspace.github-ticket", + ticketViewId, { config: config?.ticket ?? {}, data }, data.id ) diff --git a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx b/src/gigs-board/entity/view/kanban-configurator.jsx similarity index 95% rename from src/gigs-board/feature/workspace/kanban-view-configurator.jsx rename to src/gigs-board/entity/view/kanban-configurator.jsx index f21d7e6a2..910fecea9 100644 --- a/src/gigs-board/feature/workspace/kanban-view-configurator.jsx +++ b/src/gigs-board/entity/view/kanban-configurator.jsx @@ -170,6 +170,8 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { } ); + console.log(fieldInput); + State.update((lastKnownComponentState) => ({ ...lastKnownComponentState, @@ -370,7 +372,7 @@ const TicketFeaturesSchema = { const KanbanViewDefaults = { metadata: { - kind: "kanban-view", + type: "kanban-view", title: "", description: "", }, @@ -380,7 +382,10 @@ const KanbanViewDefaults = { tags: { excluded: [], required: [] }, ticket: { - propVisibility: { + type: "kanban-ticket", + kind: "post", + + features: { author: true, replyCount: true, tags: true, @@ -388,8 +393,6 @@ const KanbanViewDefaults = { type: true, }, }, - - ticket_kind: "post-ticket", }, }; @@ -412,7 +415,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { uninitialized: (view.metadata ?? null) === null, }); - console.log(form.values); + console.log(form.values.config); const isViewInitialized = (form.values.metadata ?? null) !== null; @@ -496,7 +499,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { {widget("components.organism.configurator", { heading: "Tags", classNames: { root: "col-12 col-md-7 col-lg-8" }, - data: form.values.config.tags, + externalState: form.values.config.tags, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, @@ -508,19 +511,15 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { heading: "Ticket features", classNames: { root: "col-12 col-md-4 col-lg-3" }, - data: - form.values.config.ticket?.propVisibility ?? - KanbanViewDefaults.config.ticket.propVisibility, + externalState: + form.values.config.ticket?.features ?? + KanbanViewDefaults.config.ticket.features, fieldGap: 3, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, - - onChange: form.update({ - path: ["config", "ticket", "propVisibility"], - }), - + onChange: form.update({ path: ["config", "ticket", "features"] }), schema: TicketFeaturesSchema, })}
@@ -683,14 +682,20 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { ) : null} {isViewInitialized ? ( - widget(["entity.workspace", form.values.metadata.kind].join("."), { - ...form.values, - isUnderConfiguration: state.isActive, - onConfigureClick: () => formToggle(true), - onDeleteClick: isViewInitialized ? viewDelete : null, - link, - permissions, - }) + widget( + [ + "entity.view", + form.values.metadata.type ?? form.values.metadata.kind, + ].join("."), + { + ...form.values, + isUnderConfiguration: state.isActive, + onConfigureClick: () => formToggle(true), + onDeleteClick: isViewInitialized ? viewDelete : null, + link, + permissions, + } + ) ) : (
{ + const ticketViewId = [ + "entity.ticket", + + typeof config.ticket?.type === "string" + ? [config.ticket.type.split("-")[0], config.ticket.kind].join("-") + : "kanban-post", + ].join("."); + const columns = configToColumns(config); return ( @@ -319,7 +327,7 @@ const KanbanView = ({
{column.postIds.map((postId) => widget( - ["entity.workspace", config.ticket_kind].join("."), + ticketViewId, { id: postId, config: config.ticket ?? {} }, postId ) diff --git a/src/gigs-board/pages/community/board.jsx b/src/gigs-board/pages/community/board.jsx index 2303a4bfd..d707765b3 100644 --- a/src/gigs-board/pages/community/board.jsx +++ b/src/gigs-board/pages/community/board.jsx @@ -161,7 +161,7 @@ const CommunityBoardPage = ({ handle }) => { children: (
- {widget("feature.workspace.kanban-view-configurator", { + {widget("entity.view.kanban-configurator", { communityHandle: handle, link: "https://near.org" + href("community.board", { handle }), permissions, diff --git a/src/gigs-board/pages/community/github.jsx b/src/gigs-board/pages/community/github.jsx index 282bd7481..ac604aa95 100644 --- a/src/gigs-board/pages/community/github.jsx +++ b/src/gigs-board/pages/community/github.jsx @@ -159,7 +159,7 @@ const CommunityGithubPage = ({ handle }) => { handle, title: "GitHub", - children: widget("feature.workspace.github-view-configurator", { + children: widget("entity.view.github-configurator", { communityHandle: handle, link: "near.org" + href("community.github", { handle }), permissions, From 48dae96c80ce60147a144e4536ab8a92399e759f Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 8 Sep 2023 14:49:54 +0400 Subject: [PATCH 09/81] wip --- .../components/organism/configurator.jsx | 74 ++++----- src/gigs-board/entity/community/header.jsx | 6 +- .../entity/view/github-configurator.jsx | 147 ++++++++--------- src/gigs-board/entity/view/github.jsx | 2 +- .../entity/view/kanban-configurator.jsx | 156 +++++++++--------- src/gigs-board/entity/view/kanban.jsx | 2 +- src/gigs-board/pages/community/board.jsx | 14 +- 7 files changed, 198 insertions(+), 203 deletions(-) diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index e909ad101..9eacda08c 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -152,44 +152,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + }; if ( !uninitialized && diff --git a/src/gigs-board/entity/community/header.jsx b/src/gigs-board/entity/community/header.jsx index e6ac4764a..ead8036cb 100644 --- a/src/gigs-board/entity/community/header.jsx +++ b/src/gigs-board/entity/community/header.jsx @@ -318,8 +318,8 @@ const CommunityHeader = ({ activeTabTitle, handle }) => { }} /> -
-
+
+
{
-
+
{widget("components.molecule.button", { classNames: { root: "btn-outline-light text-dark" }, href: href("community.configuration", { handle }), diff --git a/src/gigs-board/entity/view/github-configurator.jsx b/src/gigs-board/entity/view/github-configurator.jsx index c3a8511d1..ac95ad2b1 100644 --- a/src/gigs-board/entity/view/github-configurator.jsx +++ b/src/gigs-board/entity/view/github-configurator.jsx @@ -101,44 +101,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); + values: updatedValues, + }, + })); - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -339,11 +339,6 @@ const EditorSettings = { maxColumnsNumber: 20, }; -const CompactContainer = styled.div` - width: fit-content !important; - max-width: 100%; -`; - const GithubViewDefaults = { id: uuid(), kind: "github-view", @@ -439,10 +434,12 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onSubmit = () => DevHub.update_community_github({ @@ -459,49 +456,41 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { const formElement = Object.keys(form.values).length > 0 ? ( <> -
- {widget( - "components.molecule.text-input", - { - className: "w-100", - key: `${form.values.id}-title`, - label: "Title", - onChange: form.update({ path: ["title"] }), - placeholder: "NEAR Protocol NEPs", - value: form.values.title, - }, - `${form.values.id}-title` - )} - +
{widget("components.molecule.text-input", { className: "w-100", key: `${form.values.id}-repoURL`, - label: "GitHub repository URL", + label: "Repository URL", onChange: form.update({ path: ["repoURL"] }), placeholder: "https://github.com/example-org/example-repo", value: form.values.repoURL, })} + {widget("components.molecule.text-input", { + className: "w-100", + key: `${form.values.id}-title`, + label: "Title", + onChange: form.update({ path: ["title"] }), + placeholder: "NEAR Protocol NEPs", + value: form.values.title, + })} + {widget("components.molecule.text-input", { className: "w-100", key: `${form.values.id}-column-${id}-description`, label: "Description", - - onChange: form.update({ - path: ["columns", id, "description"], - }), - + onChange: form.update({ path: ["columns", id, "description"] }), placeholder: "NEPs that need a review by Subject Matter Experts.", - value: description, })}
-
+
{widget("components.organism.configurator", { heading: "Ticket types", - classNames: { root: "col-12 col-md-7 col-lg-8" }, + classNames: { root: "col-12 col-md-4 h-auto" }, externalState: form.values.dataTypesIncluded, + fieldGap: 3, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, @@ -509,7 +498,12 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { schema: TicketTypesSchema, })} - +
{ { label: "Open", value: "open" }, { label: "Closed", value: "closed" }, ], - - title: "Editing mode selection", })} - +
{widget("components.organism.configurator", { heading: "Ticket features", - classNames: { root: "col-12 col-md-4 col-lg-3" }, + classNames: { root: "col-12 col-md-4 h-auto" }, externalState: form.values.config.ticket?.features ?? @@ -557,12 +549,12 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => {
-
+
{Object.values(form.values.columns ?? {}).map( ({ id, description, labelSearchTerms, title }) => (
{widget("components.molecule.text-input", { @@ -634,10 +626,13 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { `Community with handle ${communityHandle} not found.`)}
) : ( -
+
{state.isActive && Object.keys(form.values).length > 0 ? ( -
-
+
+
GitHub board configuration diff --git a/src/gigs-board/entity/view/github.jsx b/src/gigs-board/entity/view/github.jsx index 0dbc0b25e..69b2a84e0 100644 --- a/src/gigs-board/entity/view/github.jsx +++ b/src/gigs-board/entity/view/github.jsx @@ -283,7 +283,7 @@ const GithubView = ({
{Object.keys(columns).length > 0 ? ( Object.values(columns).map((column) => ( -
+
{ hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); } - ); - - console.log(fieldInput); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + }; if ( !uninitialized && @@ -452,10 +450,12 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); @@ -473,43 +473,30 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { const formElement = isViewInitialized ? ( <> -
+
{widget("components.molecule.text-input", { - className: "flex-shrink-0", + label: "Title", + className: "w-100", key: "kanban-view-title", - label: "Board title", onChange: form.update({ path: ["metadata", "title"] }), placeholder: "Enter board title.", value: form.values.metadata.title, })} -
- {widget("components.molecule.text-input", { - className: "w-100", - inputProps: { className: "h-75" }, - key: "kanban-view-description", - label: "Board description", - multiline: true, - onChange: form.update({ path: ["metadata", "description"] }), - placeholder: "Enter board description.", - value: form.values.metadata.description, - })} - -
- {widget("components.organism.configurator", { - heading: "Tags", - classNames: { root: "col-12 col-md-7 col-lg-8" }, - externalState: form.values.config.tags, - isActive: true, - isEmbedded: true, - isUnlocked: permissions.can_configure, - onChange: form.update({ path: ["config", "tags"] }), - schema: TagsSchema, + {widget("components.molecule.text-input", { + label: "Description", + className: "w-100", + key: "kanban-view-description", + onChange: form.update({ path: ["metadata", "description"] }), + placeholder: "Enter board description.", + value: form.values.metadata.description, })} +
+
{widget("components.organism.configurator", { heading: "Ticket features", - classNames: { root: "col-12 col-md-4 col-lg-3" }, + classNames: { root: "col-12 col-lg-3" }, externalState: form.values.config.ticket?.features ?? @@ -522,9 +509,20 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { onChange: form.update({ path: ["config", "ticket", "features"] }), schema: TicketFeaturesSchema, })} + + {widget("components.organism.configurator", { + heading: "Tags", + classNames: { root: "col-12 col-lg-8 h-auto" }, + externalState: form.values.config.tags, + isActive: true, + isEmbedded: true, + isUnlocked: permissions.can_configure, + onChange: form.update({ path: ["config", "tags"] }), + schema: TagsSchema, + })}
-
+
@@ -534,12 +532,12 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
-
+
{Object.values(form.values.config.columns ?? {}).map( ({ id, description, tag, title }) => (
{widget("components.molecule.text-input", { @@ -606,10 +604,13 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { return isViewInitialized && community.isLoading ? (
Loading...
) : ( -
+
{isViewInitialized && state.isActive ? ( -
-
+
+
Kanban board configuration @@ -685,7 +686,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { widget( [ "entity.view", - form.values.metadata.type ?? form.values.metadata.kind, + + typeof form.values.metadata.type === "string" + ? form.values.metadata.type.split("-")[0] + : "kanban", ].join("."), { ...form.values, diff --git a/src/gigs-board/entity/view/kanban.jsx b/src/gigs-board/entity/view/kanban.jsx index 63a630009..020ee50ff 100644 --- a/src/gigs-board/entity/view/kanban.jsx +++ b/src/gigs-board/entity/view/kanban.jsx @@ -304,7 +304,7 @@ const KanbanView = ({
{Object.keys(columns).length > 0 ? ( Object.values(columns).map((column) => ( -
+
{ handle, title: "Board", - children: ( -
- {widget("entity.view.kanban-configurator", { - communityHandle: handle, - link: "https://near.org" + href("community.board", { handle }), - permissions, - })} -
- ), + children: widget("entity.view.kanban-configurator", { + communityHandle: handle, + link: "https://near.org" + href("community.board", { handle }), + permissions, + }), }); }; From 67c738656cd27a75578f486362f0aff5f4558bd0 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Sun, 10 Sep 2023 12:31:57 +0400 Subject: [PATCH 10/81] wip: Make it work --- src/gigs-board/components/atom/toggle.jsx | 4 +- .../components/organism/configurator.jsx | 74 ++++++------ .../entity/ticket/kanban-github.jsx | 12 +- src/gigs-board/entity/ticket/kanban-post.jsx | 16 +-- .../entity/view/github-configurator.jsx | 111 +++++++++--------- .../entity/view/kanban-configurator.jsx | 105 +++++++---------- 6 files changed, 153 insertions(+), 169 deletions(-) diff --git a/src/gigs-board/components/atom/toggle.jsx b/src/gigs-board/components/atom/toggle.jsx index 951a02d79..3094e7173 100644 --- a/src/gigs-board/components/atom/toggle.jsx +++ b/src/gigs-board/components/atom/toggle.jsx @@ -48,7 +48,7 @@ const Toggle = ({ disabled, key, label, - onSwitch, + onChange, value: checked, ...rest }) => ( @@ -65,7 +65,7 @@ const Toggle = ({ { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, } - }; + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && diff --git a/src/gigs-board/entity/ticket/kanban-github.jsx b/src/gigs-board/entity/ticket/kanban-github.jsx index ab27bf980..6bdb0fbef 100644 --- a/src/gigs-board/entity/ticket/kanban-github.jsx +++ b/src/gigs-board/entity/ticket/kanban-github.jsx @@ -53,7 +53,7 @@ const GithubTicket = ({ const header = (
); const labelList = - config.propVisibility?.labels ?? true ? ( + config.features?.labels ?? true ? (
{labels.map((label) => ( diff --git a/src/gigs-board/entity/ticket/kanban-post.jsx b/src/gigs-board/entity/ticket/kanban-post.jsx index bc0a57e2b..285ab0167 100644 --- a/src/gigs-board/entity/ticket/kanban-post.jsx +++ b/src/gigs-board/entity/ticket/kanban-post.jsx @@ -118,7 +118,7 @@ const KanbanPostTicket = ({ id, config, post }) => { const header = (
- {config.propVisibility?.author ?? true ? ( + {config.features?.author ?? true ? ( { ); const title = [ - config.propVisibility?.type ?? true + config.features?.type ?? true ? data.snapshot.post_type === "Submission" ? "Solution" : data.snapshot.post_type : null, - config.propVisibility?.title ?? true ? data.snapshot.name : null, + config.features?.title ?? true ? data.snapshot.name : null, ] .filter((prop) => typeof prop === "string") .join(": "); @@ -156,21 +156,23 @@ const KanbanPostTicket = ({ id, config, post }) => { const titleArea = data.snapshot.post_type !== "Comment" && title.length > 0 ? ( - + {config.features?.type ?? true ? ( + + ) : null} + {title} ) : null; const descriptionArea = - data.snapshot.post_type === "Comment" && - (config.propVisibility?.type ?? true) ? ( + data.snapshot.post_type === "Comment" && (config.features?.type ?? true) ? (
) : null; const tagList = - data.snapshot.labels && (config.propVisibility?.tags ?? true) ? ( + data.snapshot.labels && (config.features?.tags ?? true) ? (
{data.snapshot.labels.map((label) => ( diff --git a/src/gigs-board/entity/view/github-configurator.jsx b/src/gigs-board/entity/view/github-configurator.jsx index ac95ad2b1..b5932f70f 100644 --- a/src/gigs-board/entity/view/github-configurator.jsx +++ b/src/gigs-board/entity/view/github-configurator.jsx @@ -101,44 +101,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); + values: updatedValues, + }, + })); - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -335,10 +335,22 @@ const DevHub = { }; /* END_INCLUDE: "core/adapter/dev-hub" */ -const EditorSettings = { +const settings = { maxColumnsNumber: 20, }; +const TicketFeaturesSchema = { + author: { label: "Author" }, + labels: { label: "Labels" }, + title: { label: "Title" }, + type: { label: "Type" }, +}; + +const TicketTypesSchema = { + Issue: { label: "Issue" }, + PullRequest: { label: "Pull Request" }, +}; + const GithubViewDefaults = { id: uuid(), kind: "github-view", @@ -353,6 +365,7 @@ const GithubViewDefaults = { ticket: { type: "kanban-ticket", kind: "github", + features: { author: true, labels: true, @@ -363,18 +376,6 @@ const GithubViewDefaults = { }, }; -const TicketFeaturesSchema = { - author: { label: "Author" }, - labels: { label: "Labels" }, - title: { label: "Title" }, - type: { label: "Type" }, -}; - -const TicketTypesSchema = { - Issue: { label: "Issue" }, - PullRequest: { label: "Pull Request" }, -}; - const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { State.init({ editingMode: "form", @@ -422,7 +423,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { })); const columnsCreateNew = ({ lastKnownValue }) => - Object.keys(lastKnownValue).length < EditorSettings.maxColumnsNumber + Object.keys(lastKnownValue).length < settings.maxColumnsNumber ? { ...(lastKnownValue ?? {}), @@ -434,12 +435,10 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onSubmit = () => DevHub.update_community_github({ @@ -545,7 +544,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => {
- Columns ( max. {EditorSettings.maxColumnsNumber} ) + Columns ( max. {settings.maxColumnsNumber} )
@@ -672,7 +671,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { className="btn shadow btn-outline-secondary d-inline-flex gap-2 me-auto" disabled={ Object.keys(form.values.columns).length >= - EditorSettings.maxColumnsNumber + settings.maxColumnsNumber } onClick={form.update({ path: ["columns"], diff --git a/src/gigs-board/entity/view/kanban-configurator.jsx b/src/gigs-board/entity/view/kanban-configurator.jsx index f273ce996..ff28c5c9a 100644 --- a/src/gigs-board/entity/view/kanban-configurator.jsx +++ b/src/gigs-board/entity/view/kanban-configurator.jsx @@ -152,44 +152,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, } - }; + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -335,12 +335,7 @@ const DevHub = { }; /* END_INCLUDE: "core/adapter/dev-hub" */ -const CompactContainer = styled.div` - width: fit-content !important; - max-width: 100%; -`; - -const KanbanViewConfiguratorSettings = { +const settings = { maxColumnsNumber: 10, }; @@ -413,8 +408,6 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { uninitialized: (view.metadata ?? null) === null, }); - console.log(form.values.config); - const isViewInitialized = (form.values.metadata ?? null) !== null; const formToggle = (forcedState) => @@ -442,20 +435,17 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { })); const columnsCreateNew = ({ lastKnownValue }) => - Object.keys(lastKnownValue).length < - KanbanViewConfiguratorSettings.maxColumnsNumber + Object.keys(lastKnownValue).length < settings.maxColumnsNumber ? { ...(lastKnownValue ?? {}), ...withUUIDIndex({ tag: "", title: "New column", description: "" }), } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); @@ -526,9 +516,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { - - {`Columns ( max. ${KanbanViewConfiguratorSettings.maxColumnsNumber} )`} - + {`Columns ( max. ${settings.maxColumnsNumber} )`}
@@ -648,10 +636,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
-
+ +
- ) - )} -
- - ) : null; +
+ ) + )} +
+ + ) : null; return community.data === null ? ( -
- {(community.isLoading && "Loading...") || - (errors.noCommunity && - `Community with handle ${communityHandle} not found.`)} + ) : (
- {state.isActive && Object.keys(form.values).length > 0 ? ( -
+ {isViewInitialized ? ( +
@@ -704,13 +707,22 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { ) : null} {Object.keys(form.values).length > 0 ? ( - widget("entity.view.github", { - ...form.values, - isUnderConfiguration: state.isActive, - link, - onConfigureClick: () => formToggle(true), - permissions, - }) + widget( + [ + "entity.workspace.view", + + typeof form.values.metadata?.type === "string" + ? form.values.metadata.type + : "github.kanban-board", + ].join("."), + { + ...form.values, + isConfiguratorActive: state.isActive, + link, + onConfigureClick: () => formToggle(true), + permissions, + } + ) ) : (
const withType = (type) => (data) => ({ ...data, type }); -const GithubView = ({ +const GithubKanbanBoard = ({ columns, - config, dataTypesIncluded, description, - isUnderConfiguration, + isConfiguratorActive, link, + metadata, onConfigureClick, permissions, repoURL, @@ -159,11 +159,11 @@ const GithubView = ({ title, }) => { const ticketViewId = [ - "entity.ticket", + "entity.workspace.view.github", - typeof config?.ticket?.type === "string" - ? [config.ticket.type.split("-")[0], config.ticket.kind].join("-") - : "kanban-github", + typeof metadata?.ticket?.type === "string" + ? metadata.ticket.type + : "kanban-ticket", ].join("."); const ticketStateFilter = @@ -216,107 +216,17 @@ const GithubView = ({ })); } - return ( -
-
- {typeof link === "string" && link.length > 0 ? ( - <> - {widget("components.molecule.button", { - classNames: { - root: "btn-sm btn-outline-secondary me-auto text-white", - }, - - icon: { kind: "bootstrap-icon", variant: "bi-clipboard-fill" }, - label: "Copy link", - onClick: () => clipboard.writeText(link), - })} - - ) : null} - - {permissions.can_configure && ( - <> - {widget("components.molecule.button", { - classNames: { root: "btn-sm btn-primary" }, - - icon: { - kind: "bootstrap-icon", - variant: "bi-gear-wide-connected", - }, - - isHidden: - typeof onConfigureClick !== "function" || isUnderConfiguration, - - label: "Configure", - onClick: onConfigureClick, - })} - - {widget("components.molecule.button", { - classNames: { - root: "btn-sm btn-outline-danger shadow-none border-0", - }, - - icon: { kind: "bootstrap-icon", variant: "bi-recycle" }, - isHidden: "Disabled for MVP", // typeof onDeleteClick !== "function", - label: "Delete", - onClick: onDeleteClick, - })} - - )} -
- -
-
- - {(title?.length ?? 0) > 0 ? title : "Untitled board"} -
- -

- {(description?.length ?? 0) > 0 - ? description - : "No description provided"} -

-
- -
- {Object.keys(columns).length > 0 ? ( - Object.values(columns).map((column) => ( -
-
-
- -
- {column.title} - - - {(state.ticketsByColumn[column.id] ?? []).length} - -
- -

{column.description}

-
- -
- {(state.ticketsByColumn[column.id] ?? []).map((data) => - widget( - ticketViewId, - { config: config?.ticket ?? {}, data }, - data.id - ) - )} -
-
-
-
- )) - ) : ( + return widget("entity.workspace.view.layout", { + isConfiguratorActive, + link, + metadata: { title, description }, + onConfigureClick, + onDeleteClick, + permissions, + + children: ( + <> + {Object.keys(columns).length === 0 ? (
No columns were created so far.
- )} -
-
- ); + ) : null} + + {Object.values(columns).map((column) => ( +
+
+
+ +
+ {column.title} + + + {(state.ticketsByColumn[column.id] ?? []).length} + +
+ +

{column.description}

+
+ +
+ {(state.ticketsByColumn[column.id] ?? []).map((data) => + widget( + ticketViewId, + { config: config?.ticket ?? {}, data }, + data.id + ) + )} +
+
+
+
+ ))} + + ), + }); }; -return GithubView(props); +return GithubKanbanBoard(props); diff --git a/src/gigs-board/entity/ticket/kanban-github.jsx b/src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx similarity index 94% rename from src/gigs-board/entity/ticket/kanban-github.jsx rename to src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx index 6bdb0fbef..00e440188 100644 --- a/src/gigs-board/entity/ticket/kanban-github.jsx +++ b/src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx @@ -52,7 +52,12 @@ const GithubTicket = ({ }) => { const header = (
-
+
+ + {config.features?.author ?? true ? ( - - {config.features?.type ?? true ? ( ) : null} @@ -100,7 +100,9 @@ const GithubTicket = ({ {`${ config.features?.type ?? true ? ticketTypes[type].displayName : "" - } #${number}`.trim()} + } ${ + config.features?.number ?? true ? `#${number.toString()}` : "" + }`.trim()} diff --git a/src/gigs-board/entity/view/kanban-configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx similarity index 94% rename from src/gigs-board/entity/view/kanban-configurator.jsx rename to src/gigs-board/entity/workspace/view/kanban/configurator.jsx index ff28c5c9a..754a132a7 100644 --- a/src/gigs-board/entity/view/kanban-configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -339,7 +339,7 @@ const settings = { maxColumnsNumber: 10, }; -const TagsSchema = { +const KanbanPostBoardTagsSchema = { required: { label: "Enter tags you want to include. Posts with these tags will display.", @@ -355,7 +355,7 @@ const TagsSchema = { }, }; -const TicketFeaturesSchema = { +const KanbanPostBoardTicketFeaturesSchema = { author: { label: "Author" }, replyCount: { label: "Reply count" }, tags: { label: "Tags" }, @@ -363,20 +363,14 @@ const TicketFeaturesSchema = { type: { label: "Post type" }, }; -const KanbanViewDefaults = { +const KanbanPostBoardDefaults = { metadata: { - type: "kanban-view", + type: "kanban.post-board", title: "", description: "", - }, - - config: { - columns: {}, - tags: { excluded: [], required: [] }, ticket: { - type: "kanban-ticket", - kind: "post", + type: "kanban.post-ticket", features: { author: true, @@ -387,6 +381,11 @@ const KanbanViewDefaults = { }, }, }, + + config: { + columns: {}, + tags: { excluded: [], required: [] }, + }, }; const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { @@ -428,7 +427,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { [form.stateKey]: { hasUnsubmittedChanges: false, - values: KanbanViewDefaults, + values: KanbanPostBoardDefaults, }, isActive: true, @@ -489,15 +488,15 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { classNames: { root: "col-12 col-lg-3" }, externalState: - form.values.config.ticket?.features ?? - KanbanViewDefaults.config.ticket.features, + form.values.metadata.ticket?.features ?? + KanbanPostBoardDefaults.metadata.ticket.features, fieldGap: 3, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, onChange: form.update({ path: ["config", "ticket", "features"] }), - schema: TicketFeaturesSchema, + schema: KanbanPostBoardTicketFeaturesSchema, })} {widget("components.organism.configurator", { @@ -508,7 +507,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { isEmbedded: true, isUnlocked: permissions.can_configure, onChange: form.update({ path: ["config", "tags"] }), - schema: TagsSchema, + schema: KanbanPostBoardTagsSchema, })}
@@ -589,15 +588,24 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { ) : null; - return isViewInitialized && community.isLoading ? ( -
Loading...
+ return !isViewInitialized && community.data === null ? ( + ) : (
- {isViewInitialized && state.isActive ? ( -
+ {isViewInitialized ? ( +
@@ -670,15 +678,15 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { {isViewInitialized ? ( widget( [ - "entity.view", + "entity.workspace.view", - typeof form.values.metadata.type === "string" - ? form.values.metadata.type.split("-")[0] - : "kanban", + typeof form.values.metadata?.type === "string" + ? form.values.metadata.type + : "kanban.post-board", ].join("."), { ...form.values, - isUnderConfiguration: state.isActive, + isConfiguratorActive: state.isActive, onConfigureClick: () => formToggle(true), onDeleteClick: isViewInitialized ? viewDelete : null, link, diff --git a/src/gigs-board/entity/view/kanban.jsx b/src/gigs-board/entity/workspace/view/kanban/post-board.jsx similarity index 60% rename from src/gigs-board/entity/view/kanban.jsx rename to src/gigs-board/entity/workspace/view/kanban/post-board.jsx index 020ee50ff..fcb8f49e6 100644 --- a/src/gigs-board/entity/view/kanban.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post-board.jsx @@ -201,143 +201,36 @@ const configToColumns = ({ columns, tags }) => }; }, {}); -const KanbanView = ({ +const KanbanPostBoard = ({ config, metadata, - isUnderConfiguration, + isConfiguratorActive, link, onConfigureClick, onDeleteClick, permissions, }) => { const ticketViewId = [ - "entity.ticket", + "entity.workspace.view.kanban", - typeof config.ticket?.type === "string" - ? [config.ticket.type.split("-")[0], config.ticket.kind].join("-") - : "kanban-post", + typeof metadata?.ticket?.type === "string" + ? metadata.ticket.type + : "post-ticket", ].join("."); const columns = configToColumns(config); - return ( -
-
- {typeof link === "string" && link.length > 0 ? ( - <> - {false && // Disabled until workspaces are introduced - widget("components.molecule.button", { - classNames: { root: "btn-sm btn-outline-secondary" }, - href: link, - icon: { kind: "bootstrap-icon", variant: "box-arrow-up-right" }, - label: "Open in new tab", - rel: "noreferrer", - role: "button", - target: "_blank", - type: "link", - })} - - {widget("components.molecule.button", { - classNames: { - root: "btn-sm btn-outline-secondary me-auto text-white", - }, - - icon: { kind: "bootstrap-icon", variant: "bi-clipboard-fill" }, - label: "Copy link", - onClick: () => clipboard.writeText(link), - })} - - ) : null} - - {permissions.can_configure && ( - <> - {widget("components.molecule.button", { - classNames: { root: "btn-sm btn-primary" }, - - icon: { - kind: "bootstrap-icon", - variant: "bi-gear-wide-connected", - }, - - isHidden: - typeof onConfigureClick !== "function" || isUnderConfiguration, - - label: "Configure", - onClick: onConfigureClick, - })} - - {widget("components.molecule.button", { - classNames: { - root: "btn-sm btn-outline-danger shadow-none border-0", - }, - - icon: { kind: "bootstrap-icon", variant: "bi-recycle" }, - isHidden: "Disabled for MVP", // typeof onDeleteClick !== "function", - label: "Delete", - onClick: onDeleteClick, - })} - - )} -
- -
-
- - - - {(metadata.title?.length ?? 0) > 0 - ? metadata.title - : "Untitled view"} - -
- -

- {(metadata.description?.length ?? 0) > 0 - ? metadata.description - : "No description provided"} -

-
- -
- {Object.keys(columns).length > 0 ? ( - Object.values(columns).map((column) => ( -
-
-
- -
- {column.title} - - - {column.postIds.length} - -
- -

{column.description}

-
- -
- {column.postIds.map((postId) => - widget( - ticketViewId, - { id: postId, config: config.ticket ?? {} }, - postId - ) - )} -
-
-
-
- )) - ) : ( + return widget("entity.workspace.view.layout", { + isConfiguratorActive, + link, + metadata, + onConfigureClick, + onDeleteClick, + permissions, + + children: ( + <> + {Object.keys(columns).length === 0 ? (
No columns were created so far.
- )} -
-
- ); + ) : null} + + {Object.values(columns).map((column) => ( +
+
+
+ +
+ {column.title} + + + {column.postIds.length} + +
+ +

{column.description}

+
+ +
+ {column.postIds.map((postId) => + widget( + ticketViewId, + { id: postId, config: config.ticket ?? {} }, + postId + ) + )} +
+
+
+
+ ))} + + ), + }); }; -return KanbanView(props); +return KanbanPostBoard(props); diff --git a/src/gigs-board/entity/ticket/kanban-post.jsx b/src/gigs-board/entity/workspace/view/kanban/post-ticket.jsx similarity index 100% rename from src/gigs-board/entity/ticket/kanban-post.jsx rename to src/gigs-board/entity/workspace/view/kanban/post-ticket.jsx diff --git a/src/gigs-board/entity/workspace/view/layout.jsx b/src/gigs-board/entity/workspace/view/layout.jsx new file mode 100644 index 000000000..90ffbc6c3 --- /dev/null +++ b/src/gigs-board/entity/workspace/view/layout.jsx @@ -0,0 +1,147 @@ +/* INCLUDE: "common.jsx" */ +const nearDevGovGigsContractAccountId = + props.nearDevGovGigsContractAccountId || + (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; + +const nearDevGovGigsWidgetsAccountId = + props.nearDevGovGigsWidgetsAccountId || + (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; + +function widget(widgetName, widgetProps, key) { + widgetProps = { + ...widgetProps, + nearDevGovGigsContractAccountId: props.nearDevGovGigsContractAccountId, + nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId, + referral: props.referral, + }; + + return ( + + ); +} + +function href(widgetName, linkProps) { + linkProps = { ...linkProps }; + + if (props.nearDevGovGigsContractAccountId) { + linkProps.nearDevGovGigsContractAccountId = + props.nearDevGovGigsContractAccountId; + } + + if (props.nearDevGovGigsWidgetsAccountId) { + linkProps.nearDevGovGigsWidgetsAccountId = + props.nearDevGovGigsWidgetsAccountId; + } + + if (props.referral) { + linkProps.referral = props.referral; + } + + const linkPropsQuery = Object.entries(linkProps) + .filter(([_key, nullable]) => (nullable ?? null) !== null) + .map(([key, value]) => `${key}=${value}`) + .join("&"); + + return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${ + linkPropsQuery ? "?" : "" + }${linkPropsQuery}`; +} +/* END_INCLUDE: "common.jsx" */ + +const WorkspaceViewLayout = ({ + children, + link, + metadata, + isConfiguratorActive, + onConfigureClick, + onDeleteClick, + permissions, +}) => ( +
+
+
+ {widget("components.atom.icon", { + kind: "bootstrap-icon", + variant: "bi-kanban-fill", + })} + + + {(metadata.title?.length ?? 0) > 0 ? metadata.title : "Untitled view"} + +
+ +

+ {(metadata.description?.length ?? 0) > 0 + ? metadata.description + : "No description provided"} +

+
+ +
+ {children} +
+ +
+ {typeof link === "string" && link.length > 0 ? ( + <> + {widget("components.molecule.button", { + classNames: { root: "btn-sm btn-outline-secondary" }, + href: link, + icon: { kind: "bootstrap-icon", variant: "box-arrow-up-right" }, + isHidden: "Disabled for MVP", + label: "Open in new tab", + rel: "noreferrer", + role: "button", + target: "_blank", + type: "link", + })} + + {widget("components.molecule.button", { + classNames: { root: "btn-sm btn-outline-secondary text-white" }, + icon: { kind: "bootstrap-icon", variant: "bi-clipboard-fill" }, + label: "Copy link", + onClick: () => clipboard.writeText(link), + })} + + ) : null} + + {permissions.can_configure && ( + <> + {widget("components.molecule.button", { + classNames: { root: "btn-sm btn-primary" }, + icon: { kind: "bootstrap-icon", variant: "bi-gear-wide-connected" }, + + isHidden: + typeof onConfigureClick !== "function" || isConfiguratorActive, + + label: "Configure", + onClick: onConfigureClick, + })} + + {widget("components.molecule.button", { + classNames: { + root: "btn-sm btn-outline-danger shadow-none border-0", + }, + + icon: { kind: "bootstrap-icon", variant: "bi-recycle" }, + isHidden: "Disabled for MVP", // typeof onDeleteClick !== "function", + label: "Delete", + onClick: onDeleteClick, + })} + + )} +
+
+); + +return WorkspaceViewLayout(props); diff --git a/src/gigs-board/pages/community/board.jsx b/src/gigs-board/pages/community/board.jsx index 0ef7269fe..a9879b850 100644 --- a/src/gigs-board/pages/community/board.jsx +++ b/src/gigs-board/pages/community/board.jsx @@ -159,7 +159,7 @@ const CommunityBoardPage = ({ handle }) => { handle, title: "Board", - children: widget("entity.view.kanban-configurator", { + children: widget("entity.workspace.view.kanban.configurator", { communityHandle: handle, link: "https://near.org" + href("community.board", { handle }), permissions, diff --git a/src/gigs-board/pages/community/github.jsx b/src/gigs-board/pages/community/github.jsx index ac604aa95..236ca5a18 100644 --- a/src/gigs-board/pages/community/github.jsx +++ b/src/gigs-board/pages/community/github.jsx @@ -159,7 +159,7 @@ const CommunityGithubPage = ({ handle }) => { handle, title: "GitHub", - children: widget("entity.view.github-configurator", { + children: widget("entity.workspace.view.github.configurator", { communityHandle: handle, link: "near.org" + href("community.github", { handle }), permissions, From 3b51ed60019276c70e79ec5a8fc5c52917c6c136 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Mon, 11 Sep 2023 00:02:02 +0400 Subject: [PATCH 12/81] wip --- .../components/organism/configurator.jsx | 74 ++++++++-------- .../workspace/view/github/configurator.jsx | 78 ++++++++--------- .../workspace/view/kanban/configurator.jsx | 84 ++++++++++--------- 3 files changed, 120 insertions(+), 116 deletions(-) diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index e909ad101..9eacda08c 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -152,44 +152,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + }; if ( !uninitialized && diff --git a/src/gigs-board/entity/workspace/view/github/configurator.jsx b/src/gigs-board/entity/workspace/view/github/configurator.jsx index 4106d5e1e..e1c50ef0b 100644 --- a/src/gigs-board/entity/workspace/view/github/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/github/configurator.jsx @@ -101,44 +101,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), - values: updatedValues, - }, - })); + values: updatedValues, + }, + })); - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -434,10 +434,12 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onSubmit = () => DevHub.update_community_github({ diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 754a132a7..0dadd0b02 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -152,44 +152,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + }; if ( !uninitialized && @@ -441,10 +441,12 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); From b704b2450b5f40cd7e9808840cd6fe7d522b3222 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Mon, 11 Sep 2023 04:26:16 +0400 Subject: [PATCH 13/81] wip --- .../components/organism/configurator.jsx | 15 ++- .../workspace/view/github/configurator.jsx | 52 ++++------ .../workspace/view/github/kanban-board.jsx | 13 ++- .../workspace/view/kanban/configurator.jsx | 36 +++---- .../workspace/view/kanban/post-board.jsx | 14 ++- .../entity/workspace/view/layout.jsx | 95 ++++++++++++------- 6 files changed, 119 insertions(+), 106 deletions(-) diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index 9eacda08c..a3b1d07bd 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -320,7 +320,6 @@ const Configurator = ({ formatter: toFormatted, fullWidth, heading, - isActive, isEmbedded, isHidden, isUnlocked, @@ -341,9 +340,11 @@ const Configurator = ({ : defaultFieldsRender; State.init({ - isActive: isActive ?? false, + isActive: otherProps.isActive ?? false, }); + const isActive = otherProps.isActive ?? state.isActive; + const initialValues = Struct.typeMatch(schema) ? Struct.pick(externalState ?? {}, Object.keys(schema)) : {}; @@ -387,7 +388,7 @@ const Configurator = ({ ...otherProps, headerSlotRight: - isUnlocked && !state.isActive + isUnlocked && !isActive ? widget("components.molecule.button", { classNames: { root: "btn-sm btn-secondary" }, icon: { kind: "bootstrap-icon", variant: "bi-pen-fill" }, @@ -399,13 +400,11 @@ const Configurator = ({ children: (
{fieldsRender({ form, - isEditable: isUnlocked && state.isActive, + isEditable: isUnlocked && isActive, isUnlocked, schema, })} @@ -415,7 +414,7 @@ const Configurator = ({
{ uninitialized: Object.keys(boards).length === 0, }); - const isViewInitialized = (form.values.metadata ?? null) !== null; + const isViewInitialized = + (form.values.metadata?.id ?? form.values.id ?? null) !== null; const formToggle = (forcedState) => State.update((lastKnownState) => ({ @@ -417,7 +418,10 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { const newViewInit = () => State.update((lastKnownState) => ({ ...lastKnownState, - board: { hasUnsubmittedChanges: false, values: GithubViewDefaults }, + board: { + hasUnsubmittedChanges: false, + values: GithubKanbanBoardDefaults, + }, isActive: true, })); @@ -494,7 +498,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { isEmbedded: true, isUnlocked: permissions.can_configure, onChange: form.update({ path: ["dataTypesIncluded"] }), - schema: TicketTypesSchema, + schema: GithubKanbanBoardTicketTypesSchema, })}
{ classNames: { root: "col-12 col-md-4 h-auto" }, externalState: - form.values.config.ticket?.features ?? - GithubViewDefaults.config.ticket.features, + form.values.metadata?.ticket?.features ?? + GithubKanbanBoardDefaults.metadata.ticket.features, fieldGap: 3, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, - onChange: form.update({ path: ["config", "ticket", "features"] }), - schema: TicketFeaturesSchema, + onChange: form.update({ path: ["metadata", "ticket", "features"] }), + schema: GithubKanbanBoardTicketFeaturesSchema, })}
@@ -671,9 +675,9 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => {
)} -
+
- - - -
) : null} @@ -721,7 +707,9 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { ...form.values, isConfiguratorActive: state.isActive, link, - onConfigureClick: () => formToggle(true), + onCancel: () => formToggle(false), + onConfigure: () => formToggle(true), + onSave: onSubmit, permissions, } ) diff --git a/src/gigs-board/entity/workspace/view/github/kanban-board.jsx b/src/gigs-board/entity/workspace/view/github/kanban-board.jsx index f5235fc43..075f74f65 100644 --- a/src/gigs-board/entity/workspace/view/github/kanban-board.jsx +++ b/src/gigs-board/entity/workspace/view/github/kanban-board.jsx @@ -152,7 +152,10 @@ const GithubKanbanBoard = ({ isConfiguratorActive, link, metadata, - onConfigureClick, + onCancel, + onDelete, + onConfigure, + onSave, permissions, repoURL, ticketState, @@ -220,8 +223,10 @@ const GithubKanbanBoard = ({ isConfiguratorActive, link, metadata: { title, description }, - onConfigureClick, - onDeleteClick, + onCancel, + onConfigure, + onDelete, + onSave, permissions, children: ( @@ -263,7 +268,7 @@ const GithubKanbanBoard = ({ {(state.ticketsByColumn[column.id] ?? []).map((data) => widget( ticketViewId, - { config: config?.ticket ?? {}, data }, + { config: metadata?.ticket ?? {}, data }, data.id ) )} diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 0dadd0b02..e114b2a91 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -366,6 +366,7 @@ const KanbanPostBoardTicketFeaturesSchema = { const KanbanPostBoardDefaults = { metadata: { type: "kanban.post-board", + id: uuid(), title: "", description: "", @@ -497,7 +498,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, - onChange: form.update({ path: ["config", "ticket", "features"] }), + onChange: form.update({ path: ["metadata", "ticket", "features"] }), schema: KanbanPostBoardTicketFeaturesSchema, })} @@ -643,10 +644,13 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
)} -
+
- - - -
) : null} @@ -689,8 +675,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { { ...form.values, isConfiguratorActive: state.isActive, - onConfigureClick: () => formToggle(true), - onDeleteClick: isViewInitialized ? viewDelete : null, + onCancel: () => formToggle(false), + onConfigure: () => formToggle(true), + onDelete: isViewInitialized ? viewDelete : null, + onSave: onSubmit, link, permissions, } diff --git a/src/gigs-board/entity/workspace/view/kanban/post-board.jsx b/src/gigs-board/entity/workspace/view/kanban/post-board.jsx index fcb8f49e6..200debf6a 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post-board.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post-board.jsx @@ -206,8 +206,10 @@ const KanbanPostBoard = ({ metadata, isConfiguratorActive, link, - onConfigureClick, - onDeleteClick, + onCancel, + onConfigure, + onDelete, + onSave, permissions, }) => { const ticketViewId = [ @@ -224,8 +226,10 @@ const KanbanPostBoard = ({ isConfiguratorActive, link, metadata, - onConfigureClick, - onDeleteClick, + onCancel, + onConfigure, + onDelete, + onSave, permissions, children: ( @@ -267,7 +271,7 @@ const KanbanPostBoard = ({ {column.postIds.map((postId) => widget( ticketViewId, - { id: postId, config: config.ticket ?? {} }, + { id: postId, config: metadata.ticket ?? {} }, postId ) )} diff --git a/src/gigs-board/entity/workspace/view/layout.jsx b/src/gigs-board/entity/workspace/view/layout.jsx index 90ffbc6c3..a7e89bba4 100644 --- a/src/gigs-board/entity/workspace/view/layout.jsx +++ b/src/gigs-board/entity/workspace/view/layout.jsx @@ -57,40 +57,19 @@ const WorkspaceViewLayout = ({ link, metadata, isConfiguratorActive, - onConfigureClick, - onDeleteClick, + onCancel, + onConfigure, + onDelete, + onSave, permissions, }) => (
-
-
- {widget("components.atom.icon", { - kind: "bootstrap-icon", - variant: "bi-kanban-fill", - })} - - - {(metadata.title?.length ?? 0) > 0 ? metadata.title : "Untitled view"} - -
- -

- {(metadata.description?.length ?? 0) > 0 - ? metadata.description - : "No description provided"} -

-
- -
- {children} -
-
{typeof link === "string" && link.length > 0 ? ( <> @@ -120,12 +99,35 @@ const WorkspaceViewLayout = ({ {widget("components.molecule.button", { classNames: { root: "btn-sm btn-primary" }, icon: { kind: "bootstrap-icon", variant: "bi-gear-wide-connected" }, + isHidden: typeof onConfigure !== "function" || isConfiguratorActive, + label: "Configure", + onClick: onConfigure, + })} - isHidden: - typeof onConfigureClick !== "function" || isConfiguratorActive, + {widget("components.molecule.button", { + classNames: { + root: "btn-sm btn-outline-warning shadow-none border-0", + }, - label: "Configure", - onClick: onConfigureClick, + icon: { kind: "bootstrap-icon", variant: "bi-arrow-90deg-left" }, + isHidden: typeof onSave !== "function" || !isConfiguratorActive, + label: "Cancel", + onClick: onCancel, + })} + + {widget("components.molecule.button", { + classNames: { root: "btn-sm btn-success" }, + + icon: { + kind: "svg", + variant: "floppy-drive", + width: 14, + height: 14, + }, + + isHidden: typeof onSave !== "function" || !isConfiguratorActive, + label: "Save", + onClick: onSave, })} {widget("components.molecule.button", { @@ -134,13 +136,40 @@ const WorkspaceViewLayout = ({ }, icon: { kind: "bootstrap-icon", variant: "bi-recycle" }, - isHidden: "Disabled for MVP", // typeof onDeleteClick !== "function", + + isHidden: + "Disabled for MVP" ?? + (typeof onDelete !== "function" || isConfiguratorActive), + label: "Delete", - onClick: onDeleteClick, + onClick: onDelete, })} )}
+ +
+
+ {widget("components.atom.icon", { + kind: "bootstrap-icon", + variant: "bi-kanban-fill", + })} + + + {(metadata.title?.length ?? 0) > 0 ? metadata.title : "Untitled view"} + +
+ +

+ {(metadata.description?.length ?? 0) > 0 + ? metadata.description + : "No description provided"} +

+
+ +
+ {children} +
); From 11fa55d0c0c879a65b4ccb4d234ac35da28d6d41 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 12 Sep 2023 04:02:50 +0400 Subject: [PATCH 14/81] fix: Determine if view is initialized properly --- src/gigs-board/entity/workspace/view/kanban/configurator.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index e114b2a91..139a4638f 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -408,7 +408,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { uninitialized: (view.metadata ?? null) === null, }); - const isViewInitialized = (form.values.metadata ?? null) !== null; + const isViewInitialized = Object.keys(form.values.metadata ?? {}).length > 0; const formToggle = (forcedState) => State.update((lastKnownState) => ({ @@ -648,7 +648,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
{widget("components.molecule.button", { - icon: { kind: "bootstrap-icon", variant: "bi-github" }, + icon: { type: "bootstrap_icon", variant: "bi-github" }, isHidden: !permissions.can_configure, label: "Create GitHub board", onClick: newViewInit, diff --git a/src/gigs-board/entity/workspace/view/github/kanban-board.jsx b/src/gigs-board/entity/workspace/view/github/kanban-board.jsx index 075f74f65..c6b2ac211 100644 --- a/src/gigs-board/entity/workspace/view/github/kanban-board.jsx +++ b/src/gigs-board/entity/workspace/view/github/kanban-board.jsx @@ -162,11 +162,11 @@ const GithubKanbanBoard = ({ title, }) => { const ticketViewId = [ - "entity.workspace.view.github", + "entity.workspace.view", typeof metadata?.ticket?.type === "string" ? metadata.ticket.type - : "kanban-ticket", + : "github.kanban-ticket", ].join("."); const ticketStateFilter = diff --git a/src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx b/src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx index 00e440188..c404c7578 100644 --- a/src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx +++ b/src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx @@ -91,23 +91,28 @@ const GithubTicket = ({ ); const titleArea = ( -
- - {config.features?.type ?? true ? ( - - ) : null} - - - {`${ + + {config.features?.type ?? true ? ( + + ) : null} + + + {[ + `${ config.features?.type ?? true ? ticketTypes[type].displayName : "" } ${ - config.features?.number ?? true ? `#${number.toString()}` : "" - }`.trim()} - + config.features?.id ?? true ? `#${number.toString()}` : "" + }`.trim(), + + title, + ] + .filter( + (maybeString) => + typeof maybeString === "string" && maybeString.length > 0 + ) + .join(": ")} - - {config.features?.title ?? true ? {title} : null} -
+ ); const labelList = diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 139a4638f..1201a8fbe 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -356,10 +356,10 @@ const KanbanPostBoardTagsSchema = { }; const KanbanPostBoardTicketFeaturesSchema = { - author: { label: "Author" }, - replyCount: { label: "Reply count" }, + author_avatar: { label: "Author's avatar" }, + likes_amount: { label: "Amount of likes" }, + replies_amount: { label: "Amount of replies" }, tags: { label: "Tags" }, - title: { label: "Post title" }, type: { label: "Post type" }, }; @@ -374,10 +374,10 @@ const KanbanPostBoardDefaults = { type: "kanban.post-ticket", features: { - author: true, - replyCount: true, + author_avatar: true, + likes_amount: true, + replies_amount: false, tags: true, - title: true, type: true, }, }, @@ -457,7 +457,15 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { const onSubmit = () => DevHub.update_community_board({ handle: communityHandle, - board: JSON.stringify(form.values), + + board: JSON.stringify({ + ...form.values, + + metadata: { + ...KanbanPostBoardDefaults.metadata, + ...form.values.metadata, + }, + }), }); const viewDelete = () => @@ -675,7 +683,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { { ...form.values, isConfiguratorActive: state.isActive, - onCancel: () => formToggle(false), + onCancel, onConfigure: () => formToggle(true), onDelete: isViewInitialized ? viewDelete : null, onSave: onSubmit, @@ -693,7 +701,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
{widget("components.molecule.button", { - icon: { kind: "bootstrap-icon", variant: "bi-kanban-fill" }, + icon: { type: "bootstrap_icon", variant: "bi-kanban-fill" }, isHidden: !permissions.can_configure, label: "Create kanban board", onClick: newViewInit, diff --git a/src/gigs-board/entity/workspace/view/kanban/post-board.jsx b/src/gigs-board/entity/workspace/view/kanban/post-board.jsx index 200debf6a..b46d6ab04 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post-board.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post-board.jsx @@ -213,11 +213,11 @@ const KanbanPostBoard = ({ permissions, }) => { const ticketViewId = [ - "entity.workspace.view.kanban", + "entity.workspace.view", typeof metadata?.ticket?.type === "string" ? metadata.ticket.type - : "post-ticket", + : "kanban.post-ticket", ].join("."); const columns = configToColumns(config); diff --git a/src/gigs-board/entity/workspace/view/kanban/post-ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post-ticket.jsx index 285ab0167..acdb99ea3 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post-ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post-ticket.jsx @@ -99,73 +99,95 @@ const KanbanPostTicket = ({ id, config, post }) => { return
Loading ...
; } - const authorAvatar = ( - - ); + console.log(data); const header = ( -
- ); - const title = [ - config.features?.type ?? true - ? data.snapshot.post_type === "Submission" - ? "Solution" - : data.snapshot.post_type - : null, - - config.features?.title ?? true ? data.snapshot.name : null, - ] - .filter((prop) => typeof prop === "string") - .join(": "); - - const titleArea = - data.snapshot.post_type !== "Comment" && title.length > 0 ? ( - - {config.features?.type ?? true ? ( - + const footer = + config.features?.likes_amount ?? config.features?.replies_amount ?? true ? ( +
+ {config.features?.likes_amount ?? true ? ( + + {widget("components.atom.icon", { + type: "bootstrap_icon", + variant: "bi-heart-fill", + })} + + {data.likes.length} + ) : null} - {title} - + {config.features?.replies_amount ?? true ? ( + + {widget("components.atom.icon", { + type: "bootstrap_icon", + variant: "bi-comment", + })} + + {data.comments.length} + + ) : null} +
) : null; + const titleArea = ( + + {config.features?.type ?? true ? ( + + ) : null} + + + {[ + config.features?.type ?? true + ? data.snapshot.post_type === "Submission" + ? "Solution" + : data.snapshot.post_type + : null, + + data.snapshot.name, + ] + .filter( + (maybeString) => + typeof maybeString === "string" && maybeString.length > 0 + ) + .join(": ")} + + + ); + const descriptionArea = - data.snapshot.post_type === "Comment" && (config.features?.type ?? true) ? ( + data.snapshot.post_type === "Comment" ? (
@@ -191,6 +213,8 @@ const KanbanPostTicket = ({ id, config, post }) => { {descriptionArea} {tagList}
+ + {footer} ); }; diff --git a/src/gigs-board/entity/workspace/view/layout.jsx b/src/gigs-board/entity/workspace/view/layout.jsx index a7e89bba4..1e401bac8 100644 --- a/src/gigs-board/entity/workspace/view/layout.jsx +++ b/src/gigs-board/entity/workspace/view/layout.jsx @@ -76,7 +76,7 @@ const WorkspaceViewLayout = ({ {widget("components.molecule.button", { classNames: { root: "btn-sm btn-outline-secondary" }, href: link, - icon: { kind: "bootstrap-icon", variant: "box-arrow-up-right" }, + icon: { type: "bootstrap_icon", variant: "box-arrow-up-right" }, isHidden: "Disabled for MVP", label: "Open in new tab", rel: "noreferrer", @@ -87,7 +87,7 @@ const WorkspaceViewLayout = ({ {widget("components.molecule.button", { classNames: { root: "btn-sm btn-outline-secondary text-white" }, - icon: { kind: "bootstrap-icon", variant: "bi-clipboard-fill" }, + icon: { type: "bootstrap_icon", variant: "bi-clipboard-fill" }, label: "Copy link", onClick: () => clipboard.writeText(link), })} @@ -98,7 +98,7 @@ const WorkspaceViewLayout = ({ <> {widget("components.molecule.button", { classNames: { root: "btn-sm btn-primary" }, - icon: { kind: "bootstrap-icon", variant: "bi-gear-wide-connected" }, + icon: { type: "bootstrap_icon", variant: "bi-gear-wide-connected" }, isHidden: typeof onConfigure !== "function" || isConfiguratorActive, label: "Configure", onClick: onConfigure, @@ -109,7 +109,7 @@ const WorkspaceViewLayout = ({ root: "btn-sm btn-outline-warning shadow-none border-0", }, - icon: { kind: "bootstrap-icon", variant: "bi-arrow-90deg-left" }, + icon: { type: "bootstrap_icon", variant: "bi-arrow-90deg-left" }, isHidden: typeof onSave !== "function" || !isConfiguratorActive, label: "Cancel", onClick: onCancel, @@ -119,8 +119,8 @@ const WorkspaceViewLayout = ({ classNames: { root: "btn-sm btn-success" }, icon: { - kind: "svg", - variant: "floppy-drive", + type: "svg_icon", + variant: "floppy_drive", width: 14, height: 14, }, @@ -135,7 +135,7 @@ const WorkspaceViewLayout = ({ root: "btn-sm btn-outline-danger shadow-none border-0", }, - icon: { kind: "bootstrap-icon", variant: "bi-recycle" }, + icon: { type: "bootstrap_icon", variant: "bi-recycle" }, isHidden: "Disabled for MVP" ?? @@ -151,7 +151,7 @@ const WorkspaceViewLayout = ({
{widget("components.atom.icon", { - kind: "bootstrap-icon", + type: "bootstrap_icon", variant: "bi-kanban-fill", })} diff --git a/src/gigs-board/pages/communities.jsx b/src/gigs-board/pages/communities.jsx index c5e9a49a7..c78ead930 100644 --- a/src/gigs-board/pages/communities.jsx +++ b/src/gigs-board/pages/communities.jsx @@ -167,7 +167,7 @@ const CommunitiesPage = () => {
{widget("components.molecule.button", { - icon: { kind: "bootstrap-icon", variant: "bi-people-fill" }, + icon: { type: "bootstrap_icon", variant: "bi-people-fill" }, isHidden: !state.isSpawnerHidden, label: "Create community", onClick: () => spawnerToggle(true), From c66c7c1ef838ca8c99f7bce8e198b444396229e2 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Thu, 14 Sep 2023 07:47:37 +0400 Subject: [PATCH 16/81] wip --- src/gigs-board/components/atom/toggle.jsx | 6 +- .../components/organism/configurator.jsx | 25 ++++- .../workspace/view/github/configurator.jsx | 6 +- .../{kanban-board.jsx => kanban_board.jsx} | 2 +- .../{kanban-ticket.jsx => kanban_ticket.jsx} | 0 .../workspace/view/kanban/configurator.jsx | 95 +++++++++++----- .../kanban/{post-board.jsx => post_board.jsx} | 104 ++++++++---------- .../{post-ticket.jsx => post_ticket.jsx} | 26 ++--- 8 files changed, 156 insertions(+), 108 deletions(-) rename src/gigs-board/entity/workspace/view/github/{kanban-board.jsx => kanban_board.jsx} (99%) rename src/gigs-board/entity/workspace/view/github/{kanban-ticket.jsx => kanban_ticket.jsx} (100%) rename src/gigs-board/entity/workspace/view/kanban/{post-board.jsx => post_board.jsx} (78%) rename src/gigs-board/entity/workspace/view/kanban/{post-ticket.jsx => post_ticket.jsx} (89%) diff --git a/src/gigs-board/components/atom/toggle.jsx b/src/gigs-board/components/atom/toggle.jsx index 3094e7173..5569e1d72 100644 --- a/src/gigs-board/components/atom/toggle.jsx +++ b/src/gigs-board/components/atom/toggle.jsx @@ -46,6 +46,7 @@ const Toggle = ({ className, direction, disabled, + inputProps, key, label, onChange, @@ -66,10 +67,7 @@ const Toggle = ({ className="shadow-none" id={`toggle-${key}`} onCheckedChange={disabled ? null : onChange} - title={ - disabled ? `Permanently ${checked ? "enabled" : "disabled"}` : null - } - {...{ checked, disabled }} + {...{ checked, disabled, ...inputProps }} > {!disabled && } diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index d2b5ce7be..c1eb65567 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -234,7 +234,18 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( <> {Object.entries(schema).map( ( - [key, { format, inputProps, label, order, style, ...fieldProps }], + [ + key, + { + format, + inputProps, + isUnderMaintenance, + label, + order, + style, + ...fieldProps + }, + ], idx ) => { const fieldKey = `${idx}-${key}`, @@ -244,6 +255,9 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( ? "array" : typeof (fieldValue ?? ""); + const isDisabled = + (isUnderMaintenance ?? inputProps.disabled ?? false) || !isUnlocked; + const viewClassName = [ (fieldValue?.length ?? 0) > 0 ? "" : "text-muted", "m-0", @@ -285,6 +299,7 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( isEditable ? "" : "d-none", ].join(" "), + disabled: isDisabled, format, key: `${fieldKey}--editable`, label, @@ -297,8 +312,14 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( : fieldValue, inputProps: { - disabled: !isUnlocked, ...(inputProps ?? {}), + disabled: isDisabled, + + title: + isUnderMaintenance ?? false + ? "Temporarily disabled due to technical reasons." + : inputProps.title, + ...(fieldParamsByType[fieldType].inputProps ?? {}), tabIndex: order, }, diff --git a/src/gigs-board/entity/workspace/view/github/configurator.jsx b/src/gigs-board/entity/workspace/view/github/configurator.jsx index 8a0c2193a..aaf452a1a 100644 --- a/src/gigs-board/entity/workspace/view/github/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/github/configurator.jsx @@ -360,11 +360,11 @@ const GithubKanbanBoardDefaults = { title: "", metadata: { - type: "github.kanban-board", + type: "github.kanban_board", id: uuid(), ticket: { - type: "github.kanban-ticket", + type: "github.kanban_ticket", features: { id: true, @@ -712,7 +712,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { typeof form.values.metadata?.type === "string" ? form.values.metadata.type - : "github.kanban-board", + : "github.kanban_board", ].join("."), { ...form.values, diff --git a/src/gigs-board/entity/workspace/view/github/kanban-board.jsx b/src/gigs-board/entity/workspace/view/github/kanban_board.jsx similarity index 99% rename from src/gigs-board/entity/workspace/view/github/kanban-board.jsx rename to src/gigs-board/entity/workspace/view/github/kanban_board.jsx index c6b2ac211..633265d98 100644 --- a/src/gigs-board/entity/workspace/view/github/kanban-board.jsx +++ b/src/gigs-board/entity/workspace/view/github/kanban_board.jsx @@ -166,7 +166,7 @@ const GithubKanbanBoard = ({ typeof metadata?.ticket?.type === "string" ? metadata.ticket.type - : "github.kanban-ticket", + : "github.kanban_ticket", ].join("."); const ticketStateFilter = diff --git a/src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx b/src/gigs-board/entity/workspace/view/github/kanban_ticket.jsx similarity index 100% rename from src/gigs-board/entity/workspace/view/github/kanban-ticket.jsx rename to src/gigs-board/entity/workspace/view/github/kanban_ticket.jsx diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 1201a8fbe..c9425f269 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -357,38 +357,85 @@ const KanbanPostBoardTagsSchema = { const KanbanPostBoardTicketFeaturesSchema = { author_avatar: { label: "Author's avatar" }, + + funding_marker: { + label: "Indicate if funding is requested", + isUnderMaintenance: true, + }, + + funding_supervisor: { label: "Funding supervisor" }, + funds_amount: { label: "Amount of granted funds" }, likes_amount: { label: "Amount of likes" }, - replies_amount: { label: "Amount of replies" }, + replies_amount: { label: "Amount of replies", isUnderMaintenance: true }, + + requested_funding_sponsor: { + label: "Requested funding sponsor", + isUnderMaintenance: true, + }, + + requested_funds_amount: { + label: "Amount of requested funds", + isUnderMaintenance: true, + }, + tags: { label: "Tags" }, type: { label: "Post type" }, }; const KanbanPostBoardDefaults = { metadata: { - type: "kanban.post-board", id: uuid(), + type: "kanban.post_board", title: "", description: "", ticket: { - type: "kanban.post-ticket", + type: "kanban.post_ticket", features: { author_avatar: true, + funding_marker: false, + funding_supervisor: true, + funds_amount: true, likes_amount: true, replies_amount: false, + requested_funding_sponsor: false, + requested_funds_amount: false, tags: true, type: true, }, }, }, - config: { + payload: { columns: {}, tags: { excluded: [], required: [] }, }, }; +const toMigrated = ({ config, metadata, payload }) => ({ + metadata: { + ...KanbanPostBoardDefaults.metadata, + ...metadata, + + ticket: { + ...KanbanPostBoardDefaults.metadata.ticket, + ...metadata.ticket, + + features: { + ...KanbanPostBoardDefaults.metadata.ticket.features, + ...metadata.ticket.features, + }, + }, + }, + + payload: { + ...KanbanPostBoardDefaults.payload, + ...payload, + ...config, + }, +}); + const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { State.init({ editingMode: "form", @@ -397,15 +444,15 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { const community = DevHub.useQuery("community", { handle: communityHandle }); - const view = + const data = (community.data?.board ?? null) === null ? {} : JSON.parse(community.data.board); const form = useForm({ - initialValues: Struct.pick(view, ["config", "metadata"]), + initialValues: Struct.pick(toMigrated(data), ["metadata", "payload"]), stateKey: "view", - uninitialized: (view.metadata ?? null) === null, + uninitialized: (data.metadata ?? null) === null, }); const isViewInitialized = Object.keys(form.values.metadata ?? {}).length > 0; @@ -457,15 +504,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { const onSubmit = () => DevHub.update_community_board({ handle: communityHandle, - - board: JSON.stringify({ - ...form.values, - - metadata: { - ...KanbanPostBoardDefaults.metadata, - ...form.values.metadata, - }, - }), + board: JSON.stringify(form.values), }); const viewDelete = () => @@ -496,7 +535,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
{widget("components.organism.configurator", { heading: "Ticket features", - classNames: { root: "col-12 col-lg-3" }, + classNames: { root: "col-12 col-lg-4" }, externalState: form.values.metadata.ticket?.features ?? @@ -512,12 +551,12 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { {widget("components.organism.configurator", { heading: "Tags", - classNames: { root: "col-12 col-lg-8 h-auto" }, - externalState: form.values.config.tags, + classNames: { root: "col-12 col-lg-7 h-auto" }, + externalState: form.values.payload.tags, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, - onChange: form.update({ path: ["config", "tags"] }), + onChange: form.update({ path: ["payload", "tags"] }), schema: KanbanPostBoardTagsSchema, })}
@@ -531,7 +570,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
- {Object.values(form.values.config.columns ?? {}).map( + {Object.values(form.values.payload.columns ?? {}).map( ({ id, description, tag, title }) => (
{ label: "Column title", onChange: form.update({ - path: ["config", "columns", id, "title"], + path: ["payload", "columns", id, "title"], }), placeholder: "Enter column title.", @@ -557,7 +596,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { label: "Description", onChange: form.update({ - path: ["config", "columns", id, "description"], + path: ["payload", "columns", id, "description"], }), placeholder: "Enter a brief description of the column.", @@ -569,7 +608,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { label: "Enter a single tag to show posts in this column", onChange: form.update({ - path: ["config", "columns", id, "tag"], + path: ["payload", "columns", id, "tag"], }), placeholder: "Tag-Name", @@ -584,7 +623,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
-
+ ) )}
diff --git a/src/gigs-board/entity/workspace/view/layout.jsx b/src/gigs-board/entity/workspace/view/layout.jsx index 12f47949d..566cd02b3 100644 --- a/src/gigs-board/entity/workspace/view/layout.jsx +++ b/src/gigs-board/entity/workspace/view/layout.jsx @@ -69,10 +69,12 @@ const WorkspaceViewLayout = ({ style={{ paddingBottom: 72 }} >
diff --git a/src/gigs-board/pages/Create.jsx b/src/gigs-board/pages/Create.jsx index 7cecfd7ed..563fa4fda 100644 --- a/src/gigs-board/pages/Create.jsx +++ b/src/gigs-board/pages/Create.jsx @@ -64,17 +64,13 @@ const AutoComplete = styled.div` function textareaInputHandler(value) { const showAccountAutocomplete = /@[\w][^\s]*$/.test(value); - State.update({ text: value, showAccountAutocomplete, description: value }); + State.update({ text: value, showAccountAutocomplete }); } function autoCompleteAccountId(id) { let description = state.description.replace(/[\s]{0,1}@[^\s]*$/, ""); description = `${description} @${id}`.trim() + " "; - State.update({ - description, - handler: "autocompleteSelected", - showAccountAutocomplete: false, - }); + State.update({ description, showAccountAutocomplete: false }); } /* END_INCLUDE: "core/lib/autocomplete" */ diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index 06bca4914..be5cc4f51 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -108,13 +108,7 @@ const DevHub = { label, }) ?? null, - get_root_members: () => - Near.view(devHubAccountId, "get_root_members") ?? null, - - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - - useQuery: ({ name, params }) => { + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; const cacheState = useCache( From b6f74d9a3f3dd47cdce322c5126788d589ad009f Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Thu, 14 Sep 2023 19:28:27 +0400 Subject: [PATCH 20/81] wip --- .../workspace/view/github/configurator.jsx | 87 ++++++++++--------- .../workspace/view/github/kanban_board.jsx | 16 ++-- .../workspace/view/kanban/configurator.jsx | 48 +++++----- .../workspace/view/kanban/post_board.jsx | 2 + .../workspace/view/kanban/post_ticket.jsx | 42 +++++++-- .../entity/workspace/view/layout.jsx | 19 +++- 6 files changed, 133 insertions(+), 81 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/github/configurator.jsx b/src/gigs-board/entity/workspace/view/github/configurator.jsx index c0debf66a..28091a272 100644 --- a/src/gigs-board/entity/workspace/view/github/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/github/configurator.jsx @@ -468,32 +468,34 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { const formElement = isViewInitialized ? ( <> -
- {widget("components.molecule.text-input", { - className: "w-100", - key: `${form.values.metadata.id}-repoURL`, - label: "Repository URL", - onChange: form.update({ path: ["repoURL"] }), - placeholder: "https://github.com/example-org/example-repo", - value: form.values.repoURL, - })} +
+
+ {widget("components.molecule.text-input", { + className: "w-100", + key: `${form.values.metadata.id}-repoURL`, + label: "Repository URL", + onChange: form.update({ path: ["repoURL"] }), + placeholder: "https://github.com/example-org/example-repo", + value: form.values.repoURL, + })} - {widget("components.molecule.text-input", { - className: "w-100", - key: `${form.values.metadata.id}-title`, - label: "Title", - onChange: form.update({ path: ["title"] }), - placeholder: "NEAR Protocol NEPs", - value: form.values.title, - })} + {widget("components.molecule.text-input", { + className: "w-100", + key: `${form.values.metadata.id}-title`, + label: "Title", + onChange: form.update({ path: ["title"] }), + placeholder: "NEAR Protocol NEPs", + value: form.values.title, + })} +
{widget("components.molecule.text-input", { className: "w-100", - key: `${form.values.metadata.id}-column-${id}-description`, + key: `${form.values.metadata.id}-description`, label: "Description", - onChange: form.update({ path: ["columns", id, "description"] }), - placeholder: "NEPs that need a review by Subject Matter Experts.", - value: description, + onChange: form.update({ path: ["description"] }), + placeholder: "Latest NEAR Enhancement Proposals by status.", + value: form.values.description, })}
@@ -558,8 +560,8 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => {
{Object.values(form.values.columns ?? {}).map( ({ id, description, labelSearchTerms, title }) => ( -
@@ -608,7 +610,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { style={{ marginTop: -16, marginBottom: -16 }} >
-
+ ) )}
@@ -677,29 +679,30 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { />
)} - -
- -
) : null} {Object.keys(form.values).length > 0 ? ( widget(`entity.workspace.view.${form.values.metadata.type}`, { ...form.values, + + configurationControls: [ + { + label: "New column", + + disabled: + Object.keys(form.values.columns).length >= + settings.maxColumnsNumber, + + icon: { type: "bootstrap_icon", variant: "bi-plus-lg" }, + + onClick: form.update({ + path: ["columns"], + via: columnsCreateNew, + }), + }, + ], + isConfiguratorActive: state.isActive, isSynced: form.isSynced, link, diff --git a/src/gigs-board/entity/workspace/view/github/kanban_board.jsx b/src/gigs-board/entity/workspace/view/github/kanban_board.jsx index 883c678f7..25ccfa02e 100644 --- a/src/gigs-board/entity/workspace/view/github/kanban_board.jsx +++ b/src/gigs-board/entity/workspace/view/github/kanban_board.jsx @@ -147,19 +147,21 @@ const withType = (type) => (data) => ({ ...data, type }); const GithubKanbanBoard = ({ columns, - dataTypesIncluded, + metadata, + title, description, + repoURL, + ticketState, + dataTypesIncluded, + configurationControls, isConfiguratorActive, + isSynced, link, - metadata, onCancel, onDelete, onConfigure, onSave, permissions, - repoURL, - ticketState, - title, }) => { const ticketStateFilter = ticketState === "open" || ticketState === "closed" || ticketState === "all" @@ -212,9 +214,11 @@ const GithubKanbanBoard = ({ } return widget("entity.workspace.view.layout", { + metadata: { title, description }, + configurationControls, isConfiguratorActive, + isSynced, link, - metadata: { title, description }, onCancel, onConfigure, onDelete, diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 169112de6..7b096b3c9 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -381,7 +381,7 @@ const KanbanPostBoardTicketFeaturesSchema = { }, funding_supervisor: { label: "Funding supervisor" }, - funds_amount: { label: "Amount of granted funds" }, + granted_funds_amount: { label: "Amount of granted funds" }, likes_amount: { label: "Amount of likes" }, replies_amount: { label: "Amount of replies", isUnderMaintenance: true }, @@ -413,7 +413,7 @@ const KanbanPostBoardDefaults = { author_avatar: true, funding_marker: false, funding_supervisor: true, - funds_amount: true, + granted_funds_amount: true, likes_amount: true, replies_amount: false, requested_funding_sponsor: false, @@ -529,8 +529,8 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { const formElement = isViewInitialized ? ( <> -
-
+
+
{widget("components.organism.configurator", { heading: "Basic information", externalState: form.values.metadata, @@ -554,13 +554,14 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { {widget("components.organism.configurator", { heading: "Ticket features", - classNames: { root: "col-12 col-lg-4 h-auto" }, + classNames: { root: "w-auto h-auto" }, externalState: form.values.metadata.ticket.features, isActive: true, isEmbedded: true, isUnlocked: permissions.can_configure, onChange: form.update({ path: ["metadata", "ticket", "features"] }), schema: KanbanPostBoardTicketFeaturesSchema, + style: { minWidth: "36%" }, })}
@@ -623,7 +624,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { style={{ marginTop: -16, marginBottom: -16 }} >
)} - -
- -
) : null} {isViewInitialized ? ( widget(`entity.workspace.view.${form.values.metadata.type}`, { ...form.values, + + configurationControls: [ + { + label: "New column", + + disabled: + Object.keys(form.values.payload.columns).length >= + settings.maxColumnsNumber, + + icon: { type: "bootstrap_icon", variant: "bi-plus-lg" }, + + onClick: form.update({ + path: ["payload", "columns"], + via: columnsCreateNew, + }), + }, + ], + isConfiguratorActive: state.isActive, isSynced: form.isSynced, link, diff --git a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx index 3e4224f88..969c6b809 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx @@ -204,6 +204,7 @@ const configToColumnData = ({ columns, tags }) => const KanbanPostBoard = ({ metadata, payload, + configurationControls, isConfiguratorActive, isSynced, link, @@ -251,6 +252,7 @@ const KanbanPostBoard = ({ ); return widget("entity.workspace.view.layout", { + configurationControls, isConfiguratorActive, isSynced, link, diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index 0f385acd0..287cedf4e 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -97,6 +97,11 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { return
Loading ...
; } + const postType = + data.snapshot.post_type === "Submission" + ? "Solution" + : data.snapshot.post_type; + console.log(data); const header = ( @@ -166,15 +171,7 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { ) : null} - {[ - features.type - ? data.snapshot.post_type === "Submission" - ? "Solution" - : data.snapshot.post_type - : null, - - data.snapshot.name, - ] + {[features.type ? postType : null, data.snapshot.name] .filter( (maybeString) => typeof maybeString === "string" && maybeString.length > 0 @@ -209,6 +206,33 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => {
{titleArea} {descriptionArea} + + {postType === "Sponsorship" ? ( + <> + {features.granted_funds_amount ? ( + + Maximum amount: + + + {data.snapshot.amount} + {data.snapshot.sponsorship_token} + + + ) : null} + + {features.funding_supervisor ? ( +
+ Supervisor: + + +
+ ) : null} + + ) : null} + {tagList}
diff --git a/src/gigs-board/entity/workspace/view/layout.jsx b/src/gigs-board/entity/workspace/view/layout.jsx index 566cd02b3..c8ce85f33 100644 --- a/src/gigs-board/entity/workspace/view/layout.jsx +++ b/src/gigs-board/entity/workspace/view/layout.jsx @@ -53,6 +53,7 @@ function href(widgetName, linkProps) { /* END_INCLUDE: "common.jsx" */ const WorkspaceViewLayout = ({ + configurationControls, children, link, metadata, @@ -69,7 +70,10 @@ const WorkspaceViewLayout = ({ style={{ paddingBottom: 72 }} >
clipboard.writeText(link), })} @@ -121,6 +126,18 @@ const WorkspaceViewLayout = ({ onClick: onCancel, })} + {(configurationControls ?? []).map((controlProps) => + widget( + "components.molecule.button", + { + classNames: { root: "btn-sm btn-outline-secondary" }, + ...controlProps, + isHidden: !isConfiguratorActive, + }, + controlProps.label + ) + )} + {widget("components.molecule.button", { classNames: { root: "btn-sm btn-success" }, disabled: isSynced, From 968253fb3d72b47bc6ab742cac59038eac2ed6c4 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Thu, 14 Sep 2023 19:52:14 +0400 Subject: [PATCH 21/81] fix: Disable border --- src/gigs-board/entity/workspace/view/layout.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gigs-board/entity/workspace/view/layout.jsx b/src/gigs-board/entity/workspace/view/layout.jsx index c8ce85f33..996b87784 100644 --- a/src/gigs-board/entity/workspace/view/layout.jsx +++ b/src/gigs-board/entity/workspace/view/layout.jsx @@ -77,6 +77,7 @@ const WorkspaceViewLayout = ({ style={{ backdropFilter: "blur(10px)", backgroundColor: "rgba(24, 24, 24, 0.1)", + borderBottom: "none !important", borderTopLeftRadius: "1rem", borderTopRightRadius: "1rem", zIndex: 100, From 64f4445940cea62a47e11e4fa9353a644f24333c Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 07:57:28 +0400 Subject: [PATCH 22/81] wip --- module/core/adapter/dev-hub.js | 3 +++ src/gigs-board/entity/community/configurator.jsx | 3 +++ src/gigs-board/entity/community/header.jsx | 3 +++ src/gigs-board/entity/community/sidebar.jsx | 3 +++ src/gigs-board/entity/community/spawner.jsx | 3 +++ src/gigs-board/entity/team/LabelsPermissions.jsx | 3 +++ .../entity/workspace/view/github/configurator.jsx | 3 +++ .../entity/workspace/view/kanban/configurator.jsx | 7 +++++-- src/gigs-board/entity/workspace/view/kanban/post_board.jsx | 3 +++ .../entity/workspace/view/kanban/post_ticket.jsx | 2 +- src/gigs-board/feature/post-search/by-author.jsx | 3 +++ src/gigs-board/feature/post-search/by-tag.jsx | 3 +++ src/gigs-board/pages/Feed.jsx | 3 +++ src/gigs-board/pages/Teams.jsx | 3 +++ src/gigs-board/pages/communities.jsx | 3 +++ src/gigs-board/pages/community/activity.jsx | 3 +++ src/gigs-board/pages/community/board.jsx | 3 +++ src/gigs-board/pages/community/github.jsx | 3 +++ src/gigs-board/pages/community/teams.jsx | 3 +++ src/gigs-board/pages/community/telegram.jsx | 3 +++ src/gigs-board/pages/community/wiki.jsx | 3 +++ 21 files changed, 63 insertions(+), 3 deletions(-) diff --git a/module/core/adapter/dev-hub.js b/module/core/adapter/dev-hub.js index 2415175a2..4e2fc30da 100644 --- a/module/core/adapter/dev-hub.js +++ b/module/core/adapter/dev-hub.js @@ -38,6 +38,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/community/configurator.jsx b/src/gigs-board/entity/community/configurator.jsx index 18ba9b903..e57eac84c 100644 --- a/src/gigs-board/entity/community/configurator.jsx +++ b/src/gigs-board/entity/community/configurator.jsx @@ -143,6 +143,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/community/header.jsx b/src/gigs-board/entity/community/header.jsx index e6c5c6e20..82e3721cf 100644 --- a/src/gigs-board/entity/community/header.jsx +++ b/src/gigs-board/entity/community/header.jsx @@ -159,6 +159,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/community/sidebar.jsx b/src/gigs-board/entity/community/sidebar.jsx index 8519ac6b4..c07e6014d 100644 --- a/src/gigs-board/entity/community/sidebar.jsx +++ b/src/gigs-board/entity/community/sidebar.jsx @@ -93,6 +93,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/community/spawner.jsx b/src/gigs-board/entity/community/spawner.jsx index e71b7618d..441e0ad77 100644 --- a/src/gigs-board/entity/community/spawner.jsx +++ b/src/gigs-board/entity/community/spawner.jsx @@ -143,6 +143,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/team/LabelsPermissions.jsx b/src/gigs-board/entity/team/LabelsPermissions.jsx index c580b546e..f3bcde148 100644 --- a/src/gigs-board/entity/team/LabelsPermissions.jsx +++ b/src/gigs-board/entity/team/LabelsPermissions.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/workspace/view/github/configurator.jsx b/src/gigs-board/entity/workspace/view/github/configurator.jsx index 28091a272..5e66664de 100644 --- a/src/gigs-board/entity/workspace/view/github/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/github/configurator.jsx @@ -298,6 +298,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 7b096b3c9..a44ba4ac7 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -298,6 +298,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -385,7 +388,7 @@ const KanbanPostBoardTicketFeaturesSchema = { likes_amount: { label: "Amount of likes" }, replies_amount: { label: "Amount of replies", isUnderMaintenance: true }, - requested_funding_sponsor: { + requested_sponsor: { label: "Requested funding sponsor", isUnderMaintenance: true, }, @@ -416,7 +419,7 @@ const KanbanPostBoardDefaults = { granted_funds_amount: true, likes_amount: true, replies_amount: false, - requested_funding_sponsor: false, + requested_sponsor: false, requested_funds_amount: false, tags: true, type: true, diff --git a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx index 969c6b809..47f791855 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx @@ -120,6 +120,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index 287cedf4e..6bd0520d0 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -207,7 +207,7 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { {titleArea} {descriptionArea} - {postType === "Sponsorship" ? ( + {postType === "Sponsorship" || postType === "Solution" ? ( <> {features.granted_funds_amount ? ( diff --git a/src/gigs-board/feature/post-search/by-author.jsx b/src/gigs-board/feature/post-search/by-author.jsx index 31d7c36c2..9425da293 100644 --- a/src/gigs-board/feature/post-search/by-author.jsx +++ b/src/gigs-board/feature/post-search/by-author.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/feature/post-search/by-tag.jsx b/src/gigs-board/feature/post-search/by-tag.jsx index da135d1b1..44f1c7f66 100644 --- a/src/gigs-board/feature/post-search/by-tag.jsx +++ b/src/gigs-board/feature/post-search/by-tag.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index be5cc4f51..6cfd9162d 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/Teams.jsx b/src/gigs-board/pages/Teams.jsx index 8dba9161d..f65b34b73 100644 --- a/src/gigs-board/pages/Teams.jsx +++ b/src/gigs-board/pages/Teams.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/communities.jsx b/src/gigs-board/pages/communities.jsx index c78ead930..8a44d9bab 100644 --- a/src/gigs-board/pages/communities.jsx +++ b/src/gigs-board/pages/communities.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index d789ff39b..6a7f68510 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/community/board.jsx b/src/gigs-board/pages/community/board.jsx index a9879b850..b94953dd5 100644 --- a/src/gigs-board/pages/community/board.jsx +++ b/src/gigs-board/pages/community/board.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/community/github.jsx b/src/gigs-board/pages/community/github.jsx index 236ca5a18..f4918b3d8 100644 --- a/src/gigs-board/pages/community/github.jsx +++ b/src/gigs-board/pages/community/github.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/community/teams.jsx b/src/gigs-board/pages/community/teams.jsx index e43f1d6de..cb429f373 100644 --- a/src/gigs-board/pages/community/teams.jsx +++ b/src/gigs-board/pages/community/teams.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/community/telegram.jsx b/src/gigs-board/pages/community/telegram.jsx index 2bba267e4..f63985bc9 100644 --- a/src/gigs-board/pages/community/telegram.jsx +++ b/src/gigs-board/pages/community/telegram.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, diff --git a/src/gigs-board/pages/community/wiki.jsx b/src/gigs-board/pages/community/wiki.jsx index ea3ee8bd8..39a9098d1 100644 --- a/src/gigs-board/pages/community/wiki.jsx +++ b/src/gigs-board/pages/community/wiki.jsx @@ -92,6 +92,9 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, From ca31ce9c969d85e15d7ccba5eb768fd674d2aa5a Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 08:10:37 +0400 Subject: [PATCH 23/81] wip --- module/core/adapter/dev-hub.js | 6 +++--- src/gigs-board/entity/community/configurator.jsx | 6 +++--- src/gigs-board/entity/community/header.jsx | 6 +++--- src/gigs-board/entity/community/sidebar.jsx | 6 +++--- src/gigs-board/entity/community/spawner.jsx | 6 +++--- src/gigs-board/entity/team/LabelsPermissions.jsx | 6 +++--- .../entity/workspace/view/github/configurator.jsx | 6 +++--- .../entity/workspace/view/kanban/configurator.jsx | 6 +++--- src/gigs-board/entity/workspace/view/kanban/post_board.jsx | 6 +++--- src/gigs-board/feature/post-search/by-author.jsx | 6 +++--- src/gigs-board/feature/post-search/by-tag.jsx | 6 +++--- src/gigs-board/pages/Feed.jsx | 6 +++--- src/gigs-board/pages/Teams.jsx | 6 +++--- src/gigs-board/pages/communities.jsx | 6 +++--- src/gigs-board/pages/community/activity.jsx | 6 +++--- src/gigs-board/pages/community/board.jsx | 6 +++--- src/gigs-board/pages/community/github.jsx | 6 +++--- src/gigs-board/pages/community/teams.jsx | 6 +++--- src/gigs-board/pages/community/telegram.jsx | 6 +++--- src/gigs-board/pages/community/wiki.jsx | 6 +++--- 20 files changed, 60 insertions(+), 60 deletions(-) diff --git a/module/core/adapter/dev-hub.js b/module/core/adapter/dev-hub.js index 4e2fc30da..651c6965d 100644 --- a/module/core/adapter/dev-hub.js +++ b/module/core/adapter/dev-hub.js @@ -38,9 +38,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -57,6 +54,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/configurator.jsx b/src/gigs-board/entity/community/configurator.jsx index e57eac84c..afe88a8b5 100644 --- a/src/gigs-board/entity/community/configurator.jsx +++ b/src/gigs-board/entity/community/configurator.jsx @@ -143,9 +143,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -162,6 +159,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/header.jsx b/src/gigs-board/entity/community/header.jsx index 82e3721cf..ecb208823 100644 --- a/src/gigs-board/entity/community/header.jsx +++ b/src/gigs-board/entity/community/header.jsx @@ -159,9 +159,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -178,6 +175,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/sidebar.jsx b/src/gigs-board/entity/community/sidebar.jsx index c07e6014d..4f859f187 100644 --- a/src/gigs-board/entity/community/sidebar.jsx +++ b/src/gigs-board/entity/community/sidebar.jsx @@ -93,9 +93,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -112,6 +109,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/spawner.jsx b/src/gigs-board/entity/community/spawner.jsx index 441e0ad77..7902ef26f 100644 --- a/src/gigs-board/entity/community/spawner.jsx +++ b/src/gigs-board/entity/community/spawner.jsx @@ -143,9 +143,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -162,6 +159,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/team/LabelsPermissions.jsx b/src/gigs-board/entity/team/LabelsPermissions.jsx index f3bcde148..4f0270c5c 100644 --- a/src/gigs-board/entity/team/LabelsPermissions.jsx +++ b/src/gigs-board/entity/team/LabelsPermissions.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/workspace/view/github/configurator.jsx b/src/gigs-board/entity/workspace/view/github/configurator.jsx index 5e66664de..50949c5b0 100644 --- a/src/gigs-board/entity/workspace/view/github/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/github/configurator.jsx @@ -298,9 +298,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -317,6 +314,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index a44ba4ac7..aa002ffbc 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -298,9 +298,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -317,6 +314,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx index 47f791855..ec5dd255f 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx @@ -120,9 +120,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -139,6 +136,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/feature/post-search/by-author.jsx b/src/gigs-board/feature/post-search/by-author.jsx index 9425da293..53948c39f 100644 --- a/src/gigs-board/feature/post-search/by-author.jsx +++ b/src/gigs-board/feature/post-search/by-author.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/feature/post-search/by-tag.jsx b/src/gigs-board/feature/post-search/by-tag.jsx index 44f1c7f66..378b218c5 100644 --- a/src/gigs-board/feature/post-search/by-tag.jsx +++ b/src/gigs-board/feature/post-search/by-tag.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index 6cfd9162d..69f074481 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/Teams.jsx b/src/gigs-board/pages/Teams.jsx index f65b34b73..a933990aa 100644 --- a/src/gigs-board/pages/Teams.jsx +++ b/src/gigs-board/pages/Teams.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/communities.jsx b/src/gigs-board/pages/communities.jsx index 8a44d9bab..83bd6aea9 100644 --- a/src/gigs-board/pages/communities.jsx +++ b/src/gigs-board/pages/communities.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 6a7f68510..09e8f9f76 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/board.jsx b/src/gigs-board/pages/community/board.jsx index b94953dd5..b74f39fd5 100644 --- a/src/gigs-board/pages/community/board.jsx +++ b/src/gigs-board/pages/community/board.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/github.jsx b/src/gigs-board/pages/community/github.jsx index f4918b3d8..f49f33bf8 100644 --- a/src/gigs-board/pages/community/github.jsx +++ b/src/gigs-board/pages/community/github.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/teams.jsx b/src/gigs-board/pages/community/teams.jsx index cb429f373..9d67d750c 100644 --- a/src/gigs-board/pages/community/teams.jsx +++ b/src/gigs-board/pages/community/teams.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/telegram.jsx b/src/gigs-board/pages/community/telegram.jsx index f63985bc9..2e9238081 100644 --- a/src/gigs-board/pages/community/telegram.jsx +++ b/src/gigs-board/pages/community/telegram.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/wiki.jsx b/src/gigs-board/pages/community/wiki.jsx index 39a9098d1..7d085c95e 100644 --- a/src/gigs-board/pages/community/wiki.jsx +++ b/src/gigs-board/pages/community/wiki.jsx @@ -92,9 +92,6 @@ const DevHub = { get_all_authors: () => Near.view(devHubAccountId, "get_all_authors") ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - get_all_communities_metadata: () => Near.view(devHubAccountId, "get_all_communities_metadata") ?? null, @@ -111,6 +108,9 @@ const DevHub = { label, }) ?? null, + get_featured_communities: () => + Near.view(devHubAccountId, "get_featured_communities") ?? null, + useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; From 6d4989cbb38cddf9fc5ba76c6b315561fcdb9a4b Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 08:12:45 +0400 Subject: [PATCH 24/81] wip --- module/core/adapter/dev-hub.js | 3 --- src/gigs-board/entity/community/configurator.jsx | 3 --- src/gigs-board/entity/community/header.jsx | 3 --- src/gigs-board/entity/community/sidebar.jsx | 3 --- src/gigs-board/entity/community/spawner.jsx | 3 --- src/gigs-board/entity/team/LabelsPermissions.jsx | 3 --- .../workspace/view/github/configurator.jsx | 3 --- .../workspace/view/kanban/configurator.jsx | 3 --- .../entity/workspace/view/kanban/post_board.jsx | 3 --- src/gigs-board/feature/post-search/by-author.jsx | 3 --- src/gigs-board/feature/post-search/by-tag.jsx | 3 --- src/gigs-board/pages/Feed.jsx | 16 +++++++--------- src/gigs-board/pages/Teams.jsx | 3 --- src/gigs-board/pages/communities.jsx | 3 --- src/gigs-board/pages/community/activity.jsx | 3 --- src/gigs-board/pages/community/board.jsx | 3 --- src/gigs-board/pages/community/github.jsx | 3 --- src/gigs-board/pages/community/teams.jsx | 3 --- src/gigs-board/pages/community/telegram.jsx | 3 --- src/gigs-board/pages/community/wiki.jsx | 3 --- 20 files changed, 7 insertions(+), 66 deletions(-) diff --git a/module/core/adapter/dev-hub.js b/module/core/adapter/dev-hub.js index 651c6965d..2415175a2 100644 --- a/module/core/adapter/dev-hub.js +++ b/module/core/adapter/dev-hub.js @@ -54,9 +54,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/configurator.jsx b/src/gigs-board/entity/community/configurator.jsx index afe88a8b5..18ba9b903 100644 --- a/src/gigs-board/entity/community/configurator.jsx +++ b/src/gigs-board/entity/community/configurator.jsx @@ -159,9 +159,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/header.jsx b/src/gigs-board/entity/community/header.jsx index ecb208823..e6c5c6e20 100644 --- a/src/gigs-board/entity/community/header.jsx +++ b/src/gigs-board/entity/community/header.jsx @@ -175,9 +175,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/sidebar.jsx b/src/gigs-board/entity/community/sidebar.jsx index 4f859f187..8519ac6b4 100644 --- a/src/gigs-board/entity/community/sidebar.jsx +++ b/src/gigs-board/entity/community/sidebar.jsx @@ -109,9 +109,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/community/spawner.jsx b/src/gigs-board/entity/community/spawner.jsx index 7902ef26f..e71b7618d 100644 --- a/src/gigs-board/entity/community/spawner.jsx +++ b/src/gigs-board/entity/community/spawner.jsx @@ -159,9 +159,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/team/LabelsPermissions.jsx b/src/gigs-board/entity/team/LabelsPermissions.jsx index 4f0270c5c..c580b546e 100644 --- a/src/gigs-board/entity/team/LabelsPermissions.jsx +++ b/src/gigs-board/entity/team/LabelsPermissions.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/workspace/view/github/configurator.jsx b/src/gigs-board/entity/workspace/view/github/configurator.jsx index 50949c5b0..28091a272 100644 --- a/src/gigs-board/entity/workspace/view/github/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/github/configurator.jsx @@ -314,9 +314,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index aa002ffbc..806729e9b 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -314,9 +314,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx index ec5dd255f..969c6b809 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_board.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_board.jsx @@ -136,9 +136,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/feature/post-search/by-author.jsx b/src/gigs-board/feature/post-search/by-author.jsx index 53948c39f..31d7c36c2 100644 --- a/src/gigs-board/feature/post-search/by-author.jsx +++ b/src/gigs-board/feature/post-search/by-author.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/feature/post-search/by-tag.jsx b/src/gigs-board/feature/post-search/by-tag.jsx index 378b218c5..da135d1b1 100644 --- a/src/gigs-board/feature/post-search/by-tag.jsx +++ b/src/gigs-board/feature/post-search/by-tag.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index 69f074481..2cbae9df1 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; @@ -195,12 +192,13 @@ const banner = (
Featured Communities
- {(DevHub.get_featured_communities() ?? []).map((community) => - widget( - "entity.community.card", - { metadata: community, format: "medium" }, - community.handle - ) + {(Near.view(devHubAccountId, "get_featured_communities") ?? []).map( + (community) => + widget( + "entity.community.card", + { metadata: community, format: "medium" }, + community.handle + ) )}
diff --git a/src/gigs-board/pages/Teams.jsx b/src/gigs-board/pages/Teams.jsx index a933990aa..8dba9161d 100644 --- a/src/gigs-board/pages/Teams.jsx +++ b/src/gigs-board/pages/Teams.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/communities.jsx b/src/gigs-board/pages/communities.jsx index 83bd6aea9..c78ead930 100644 --- a/src/gigs-board/pages/communities.jsx +++ b/src/gigs-board/pages/communities.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 09e8f9f76..d789ff39b 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/board.jsx b/src/gigs-board/pages/community/board.jsx index b74f39fd5..a9879b850 100644 --- a/src/gigs-board/pages/community/board.jsx +++ b/src/gigs-board/pages/community/board.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/github.jsx b/src/gigs-board/pages/community/github.jsx index f49f33bf8..236ca5a18 100644 --- a/src/gigs-board/pages/community/github.jsx +++ b/src/gigs-board/pages/community/github.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/teams.jsx b/src/gigs-board/pages/community/teams.jsx index 9d67d750c..e43f1d6de 100644 --- a/src/gigs-board/pages/community/teams.jsx +++ b/src/gigs-board/pages/community/teams.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/telegram.jsx b/src/gigs-board/pages/community/telegram.jsx index 2e9238081..2bba267e4 100644 --- a/src/gigs-board/pages/community/telegram.jsx +++ b/src/gigs-board/pages/community/telegram.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; diff --git a/src/gigs-board/pages/community/wiki.jsx b/src/gigs-board/pages/community/wiki.jsx index 7d085c95e..ea3ee8bd8 100644 --- a/src/gigs-board/pages/community/wiki.jsx +++ b/src/gigs-board/pages/community/wiki.jsx @@ -108,9 +108,6 @@ const DevHub = { label, }) ?? null, - get_featured_communities: () => - Near.view(devHubAccountId, "get_featured_communities") ?? null, - useQuery: (name, params) => { const initialState = { data: null, error: null, isLoading: true }; From 3d485170ddd3b916a1b0cacfa32273be9d7fdd81 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 08:30:14 +0400 Subject: [PATCH 25/81] wip --- src/gigs-board/entity/community/sidebar.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gigs-board/entity/community/sidebar.jsx b/src/gigs-board/entity/community/sidebar.jsx index 8519ac6b4..80db8b63b 100644 --- a/src/gigs-board/entity/community/sidebar.jsx +++ b/src/gigs-board/entity/community/sidebar.jsx @@ -184,7 +184,7 @@ const CommunitySummary = (community) => { ]; return ( -
-
+ ); }; @@ -235,6 +235,7 @@ const Sidebar = ({ handle }) => { ) : (
{widget("components.molecule.tile", { + fullWidth: true, minHeight: 0, children: CommunitySummary(community), noBorder: true, From 4eeffeb3724aed79fdc4e7c648dd35c9c63d4ffb Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 11:07:35 +0400 Subject: [PATCH 26/81] Adjust wording --- .../workspace/view/kanban/configurator.jsx | 24 +++--- .../workspace/view/kanban/post_ticket.jsx | 81 ++++++++++++------- 2 files changed, 66 insertions(+), 39 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 806729e9b..6b5889699 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -375,22 +375,22 @@ const KanbanPostBoardTagsSchema = { const KanbanPostBoardTicketFeaturesSchema = { author_avatar: { label: "Author's avatar" }, - funding_marker: { + sponsorship_request_marker: { label: "Indicate if funding is requested", isUnderMaintenance: true, }, - funding_supervisor: { label: "Funding supervisor" }, - granted_funds_amount: { label: "Amount of granted funds" }, - likes_amount: { label: "Amount of likes" }, - replies_amount: { label: "Amount of replies", isUnderMaintenance: true }, + sponsorship_supervisor: { label: "Funding supervisor" }, + grant_value: { label: "Amount of granted funds" }, + like_count: { label: "Amount of likes" }, + reply_count: { label: "Amount of replies", isUnderMaintenance: true }, requested_sponsor: { label: "Requested funding sponsor", isUnderMaintenance: true, }, - requested_funds_amount: { + requested_grant_value: { label: "Amount of requested funds", isUnderMaintenance: true, }, @@ -411,13 +411,13 @@ const KanbanPostBoardDefaults = { features: { author_avatar: true, - funding_marker: false, - funding_supervisor: true, - granted_funds_amount: true, - likes_amount: true, - replies_amount: false, + like_count: true, + reply_count: false, + grant_value: true, + sponsorship_request_marker: false, + sponsorship_supervisor: true, + requested_grant_value: false, requested_sponsor: false, - requested_funds_amount: false, tags: true, type: true, }, diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index 6bd0520d0..adcd42a1f 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -138,9 +138,9 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { ); const footer = - features.likes_amount || features.replies_amount ? ( + features.like_count || features.reply_count ? (
- {features.likes_amount ? ( + {features.like_count ? ( {widget("components.atom.icon", { type: "bootstrap_icon", @@ -151,7 +151,7 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { ) : null} - {features.replies_amount ? ( + {features.reply_count ? ( {widget("components.atom.icon", { type: "bootstrap_icon", @@ -199,6 +199,21 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => {
) : null; + const isFundingRequested = + postType === "Solution" && data.snapshot.is_funding_requested; + + const isRequestedFundsAmountFeatured = + isFundingRequested && features.requested_grant_value; + + const isGrantedFundsAmountFeatured = + postType === "Sponsorship" && features.grant_value; + + const isRequestedSponsorFeatured = + isFundingRequested && features.requested_sponsor; + + const isFundingSupervisorFeatured = + postType === "Sponsorship" && features.sponsorship_supervisor; + return ( {header} @@ -207,30 +222,42 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { {titleArea} {descriptionArea} - {postType === "Sponsorship" || postType === "Solution" ? ( - <> - {features.granted_funds_amount ? ( - - Maximum amount: - - - {data.snapshot.amount} - {data.snapshot.sponsorship_token} - - - ) : null} - - {features.funding_supervisor ? ( -
- Supervisor: - - -
- ) : null} - + {isFundingRequested && features.sponsorship_request_marker ? ( + + {widget("components.atom.icon", { + type: "bootstrap_icon", + variant: "bi-cash", + })} + + Funding requested + + ) : null} + + {isRequestedFundsAmountFeatured || isGrantedFundsAmountFeatured ? ( + + Amount: + + + {data.snapshot.amount} + {data.snapshot.sponsorship_token} + + + ) : null} + + {isRequestedSponsorFeatured || isFundingSupervisorFeatured ? ( +
+ Supervisor: + + +
) : null} {tagList} From 2f745bfe7fc554d28a6b2ecbf1a1ff2d2ca21cfc Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 11:20:56 +0400 Subject: [PATCH 27/81] Adjust wording --- .../components/organism/configurator.jsx | 17 +-- .../workspace/view/kanban/configurator.jsx | 113 ++++++++---------- .../workspace/view/kanban/post_ticket.jsx | 2 +- 3 files changed, 55 insertions(+), 77 deletions(-) diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index 53252cc2f..ec01aa96b 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -239,18 +239,7 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( <> {Object.entries(schema).map( ( - [ - key, - { - format, - inputProps, - isUnderMaintenance, - label, - order, - style, - ...fieldProps - }, - ], + [key, { format, inputProps, noop, label, order, style, ...fieldProps }], idx ) => { const fieldKey = `${idx}-${key}`, @@ -261,7 +250,7 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( : typeof (fieldValue ?? ""); const isDisabled = - (isUnderMaintenance ?? inputProps.disabled ?? false) || !isUnlocked; + (noop ?? inputProps.disabled ?? false) || !isUnlocked; const viewClassName = [ (fieldValue?.length ?? 0) > 0 ? "" : "text-muted", @@ -323,7 +312,7 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( disabled: isDisabled, title: - isUnderMaintenance ?? false + noop ?? false ? "Temporarily disabled due to technical reasons." : inputProps.title, diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 6b5889699..33e0950c8 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -157,44 +157,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, } - }; + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -374,27 +374,18 @@ const KanbanPostBoardTagsSchema = { const KanbanPostBoardTicketFeaturesSchema = { author_avatar: { label: "Author's avatar" }, - - sponsorship_request_marker: { - label: "Indicate if funding is requested", - isUnderMaintenance: true, - }, - - sponsorship_supervisor: { label: "Funding supervisor" }, - grant_value: { label: "Amount of granted funds" }, like_count: { label: "Amount of likes" }, - reply_count: { label: "Amount of replies", isUnderMaintenance: true }, - - requested_sponsor: { - label: "Requested funding sponsor", - isUnderMaintenance: true, - }, + reply_count: { label: "Amount of replies", noop: true }, + approved_grant_value: { label: "Amount of granted funds" }, + sponsorship_supervisor: { label: "Sponsorship supervisor" }, - requested_grant_value: { - label: "Amount of requested funds", - isUnderMaintenance: true, + sponsorship_request_marker: { + label: "Indicate sponsorship requests", + noop: true, }, + requested_grant_value: { label: "Amount of requested funds", noop: true }, + requested_sponsor: { label: "Requested sponsor", noop: true }, tags: { label: "Tags" }, type: { label: "Post type" }, }; @@ -413,9 +404,9 @@ const KanbanPostBoardDefaults = { author_avatar: true, like_count: true, reply_count: false, - grant_value: true, - sponsorship_request_marker: false, + approved_grant_value: true, sponsorship_supervisor: true, + sponsorship_request_marker: false, requested_grant_value: false, requested_sponsor: false, tags: true, @@ -506,12 +497,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index adcd42a1f..06a5fe775 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -206,7 +206,7 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { isFundingRequested && features.requested_grant_value; const isGrantedFundsAmountFeatured = - postType === "Sponsorship" && features.grant_value; + postType === "Sponsorship" && features.approved_grant_value; const isRequestedSponsorFeatured = isFundingRequested && features.requested_sponsor; From 6f6a822deadb65f8db29b46dc5398a253ba0328f Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 11:22:24 +0400 Subject: [PATCH 28/81] Adjust wording --- src/gigs-board/entity/workspace/view/kanban/configurator.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 33e0950c8..495604526 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -376,7 +376,7 @@ const KanbanPostBoardTicketFeaturesSchema = { author_avatar: { label: "Author's avatar" }, like_count: { label: "Amount of likes" }, reply_count: { label: "Amount of replies", noop: true }, - approved_grant_value: { label: "Amount of granted funds" }, + approved_grant_value: { label: "Approved grant value" }, sponsorship_supervisor: { label: "Sponsorship supervisor" }, sponsorship_request_marker: { @@ -384,7 +384,7 @@ const KanbanPostBoardTicketFeaturesSchema = { noop: true, }, - requested_grant_value: { label: "Amount of requested funds", noop: true }, + requested_grant_value: { label: "Requested grant value", noop: true }, requested_sponsor: { label: "Requested sponsor", noop: true }, tags: { label: "Tags" }, type: { label: "Post type" }, From aec9980a399aab0732c14bd0e10ced72ed78d05b Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 15 Sep 2023 12:46:32 +0400 Subject: [PATCH 29/81] Enable all features --- .../workspace/view/kanban/configurator.jsx | 98 ++++++++++--------- .../workspace/view/kanban/post_ticket.jsx | 62 +++++++----- 2 files changed, 90 insertions(+), 70 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 495604526..1e5f43da6 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -157,44 +157,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + }; if ( !uninitialized && @@ -376,16 +376,16 @@ const KanbanPostBoardTicketFeaturesSchema = { author_avatar: { label: "Author's avatar" }, like_count: { label: "Amount of likes" }, reply_count: { label: "Amount of replies", noop: true }, - approved_grant_value: { label: "Approved grant value" }, - sponsorship_supervisor: { label: "Sponsorship supervisor" }, - sponsorship_request_marker: { - label: "Indicate sponsorship requests", + sponsorship_request_indicator: { + label: "Sponsorship request indicator", noop: true, }, requested_grant_value: { label: "Requested grant value", noop: true }, requested_sponsor: { label: "Requested sponsor", noop: true }, + approved_grant_value: { label: "Approved grant value" }, + sponsorship_supervisor: { label: "Sponsorship supervisor" }, tags: { label: "Tags" }, type: { label: "Post type" }, }; @@ -404,11 +404,11 @@ const KanbanPostBoardDefaults = { author_avatar: true, like_count: true, reply_count: false, - approved_grant_value: true, - sponsorship_supervisor: true, - sponsorship_request_marker: false, + sponsorship_request_indicator: false, requested_grant_value: false, requested_sponsor: false, + approved_grant_value: true, + sponsorship_supervisor: true, tags: true, type: true, }, @@ -497,10 +497,12 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index 06a5fe775..b82a583d0 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -88,9 +88,9 @@ const iconsByPostType = { Sponsorship: "bi-cash-coin", }; -const KanbanPostTicket = ({ metadata: { id, features } }) => { +const KanbanPostTicket = ({ metadata }) => { const data = Near.view(nearDevGovGigsContractAccountId, "get_post", { - post_id: id ? parseInt(id) : 0, + post_id: metadata.id ? parseInt(metadata.id) : 0, }); if (!data) { @@ -102,6 +102,31 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { ? "Solution" : data.snapshot.post_type; + const features = { + ...metadata.features, + + sponsorship_request_indicator: + postType === "Solution" && + data.snapshot.is_funding_requested && + metadata.features.sponsorship_request_indicator, + + requested_grant_value: + postType === "Solution" && + data.snapshot.is_funding_requested && + metadata.features.requested_grant_value, + + requested_sponsor: + postType === "Solution" && + data.snapshot.is_funding_requested && + metadata.features.requested_sponsor, + + approved_grant_value: + postType === "Sponsorship" && metadata.features.approved_grant_value, + + sponsorship_supervisor: + postType === "Sponsorship" && metadata.features.sponsorship_supervisor, + }; + console.log(data); const header = ( @@ -199,21 +224,6 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => {
) : null; - const isFundingRequested = - postType === "Solution" && data.snapshot.is_funding_requested; - - const isRequestedFundsAmountFeatured = - isFundingRequested && features.requested_grant_value; - - const isGrantedFundsAmountFeatured = - postType === "Sponsorship" && features.approved_grant_value; - - const isRequestedSponsorFeatured = - isFundingRequested && features.requested_sponsor; - - const isFundingSupervisorFeatured = - postType === "Sponsorship" && features.sponsorship_supervisor; - return ( {header} @@ -222,7 +232,7 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { {titleArea} {descriptionArea} - {isFundingRequested && features.sponsorship_request_marker ? ( + {features.sponsorship_request_indicator ? ( {widget("components.atom.icon", { type: "bootstrap_icon", @@ -233,7 +243,7 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { ) : null} - {isRequestedFundsAmountFeatured || isGrantedFundsAmountFeatured ? ( + {features.requested_grant_value || features.approved_grant_value ? ( Amount: @@ -244,15 +254,23 @@ const KanbanPostTicket = ({ metadata: { id, features } }) => { ) : null} - {isRequestedSponsorFeatured || isFundingSupervisorFeatured ? ( + {features.requested_sponsor || features.sponsorship_supervisor ? (
- Supervisor: + {`${ + features.requested_sponsor ? "Requested sponsor" : "Supervisor" + }:`} Date: Mon, 18 Sep 2023 23:15:37 +0400 Subject: [PATCH 30/81] fix: Adjust viewport width --- src/gigs-board/entity/community/configurator.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gigs-board/entity/community/configurator.jsx b/src/gigs-board/entity/community/configurator.jsx index 18ba9b903..4fedf4cf2 100644 --- a/src/gigs-board/entity/community/configurator.jsx +++ b/src/gigs-board/entity/community/configurator.jsx @@ -387,7 +387,7 @@ const CommunityConfigurator = ({ handle, link }) => {
Loading...
) : (
{community.data === null ? ( From 2c0e8b5c82bac99b2c0a70e6229c2b2d0b49ce57 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 26 Sep 2023 02:21:12 +0400 Subject: [PATCH 31/81] Implement pre-release amendments --- .../components/organism/configurator.jsx | 7 ++- .../workspace/view/github/configurator.jsx | 36 +++++++++-- .../workspace/view/kanban/configurator.jsx | 46 +++++++++++---- .../workspace/view/kanban/post_ticket.jsx | 4 +- .../entity/workspace/view/layout.jsx | 59 +++++++++---------- 5 files changed, 101 insertions(+), 51 deletions(-) diff --git a/src/gigs-board/components/organism/configurator.jsx b/src/gigs-board/components/organism/configurator.jsx index ec01aa96b..df7d019bc 100644 --- a/src/gigs-board/components/organism/configurator.jsx +++ b/src/gigs-board/components/organism/configurator.jsx @@ -260,7 +260,10 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( return ( <>
@@ -292,7 +295,7 @@ const defaultFieldsRender = ({ schema, form, isEditable, isUnlocked }) => ( className: [ "w-100", fieldProps.className ?? "", - isEditable ? "" : "d-none", + isEditable && !noop ? "" : "d-none", ].join(" "), disabled: isDisabled, diff --git a/src/gigs-board/entity/workspace/view/github/configurator.jsx b/src/gigs-board/entity/workspace/view/github/configurator.jsx index 28091a272..ae49fa196 100644 --- a/src/gigs-board/entity/workspace/view/github/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/github/configurator.jsx @@ -345,7 +345,7 @@ const settings = { }; const GithubKanbanBoardTicketFeaturesSchema = { - id: { label: "Id" }, + id: { label: "GitHub ID" }, author: { label: "Author" }, labels: { label: "Labels" }, type: { label: "Type" }, @@ -457,7 +457,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { formToggle(false); }; - const onSubmit = () => + const onSave = () => DevHub.update_community_github({ handle: communityHandle, @@ -539,7 +539,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => {
{widget("components.organism.configurator", { - heading: "Ticket features", + heading: "Card fields", classNames: { root: "col-12 col-md-4 h-auto" }, externalState: form.values.metadata.ticket.features, isActive: true, @@ -623,6 +623,34 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { ) )} + +
+ {widget("components.molecule.button", { + classNames: { + root: "d-flex btn btn-outline-danger shadow-none border-0", + }, + + isHidden: typeof onCancel !== "function" || !state.isActive, + label: "Cancel", + onClick: onCancel, + })} + + {widget("components.molecule.button", { + classNames: { root: "btn btn-success" }, + disabled: form.isSynced, + + icon: { + type: "svg_icon", + variant: "floppy_drive", + width: 14, + height: 14, + }, + + isHidden: typeof onSave !== "function" || !state.isActive, + label: "Save", + onClick: onSave, + })} +
) : null; @@ -706,9 +734,7 @@ const GithubViewConfigurator = ({ communityHandle, link, permissions }) => { isConfiguratorActive: state.isActive, isSynced: form.isSynced, link, - onCancel, onConfigure: () => formToggle(true), - onSave: onSubmit, permissions, }) ) : ( diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 1e5f43da6..e100c1063 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -373,9 +373,9 @@ const KanbanPostBoardTagsSchema = { }; const KanbanPostBoardTicketFeaturesSchema = { - author_avatar: { label: "Author's avatar" }, - like_count: { label: "Amount of likes" }, - reply_count: { label: "Amount of replies", noop: true }, + author: { label: "Author" }, + like_count: { label: "Likes" }, + reply_count: { label: "Replies", noop: true }, sponsorship_request_indicator: { label: "Sponsorship request indicator", @@ -384,8 +384,8 @@ const KanbanPostBoardTicketFeaturesSchema = { requested_grant_value: { label: "Requested grant value", noop: true }, requested_sponsor: { label: "Requested sponsor", noop: true }, - approved_grant_value: { label: "Approved grant value" }, - sponsorship_supervisor: { label: "Sponsorship supervisor" }, + approved_grant_value: { label: "Approved amount" }, + sponsorship_supervisor: { label: "Supervisor" }, tags: { label: "Tags" }, type: { label: "Post type" }, }; @@ -401,7 +401,7 @@ const KanbanPostBoardDefaults = { type: "kanban.post_ticket", features: { - author_avatar: true, + author: true, like_count: true, reply_count: false, sponsorship_request_indicator: false, @@ -509,7 +509,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { formToggle(false); }; - const onSubmit = () => + const onSave = () => DevHub.update_community_board({ handle: communityHandle, board: JSON.stringify(form.values), @@ -544,7 +544,7 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
{widget("components.organism.configurator", { - heading: "Ticket features", + heading: "Card fields", classNames: { root: "w-auto h-auto" }, externalState: form.values.metadata.ticket.features, isActive: true, @@ -628,6 +628,34 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => {
) )} + +
+ {widget("components.molecule.button", { + classNames: { + root: "d-flex btn btn-outline-danger shadow-none border-0", + }, + + isHidden: typeof onCancel !== "function" || !state.isActive, + label: "Cancel", + onClick: onCancel, + })} + + {widget("components.molecule.button", { + classNames: { root: "btn btn-success" }, + disabled: form.isSynced, + + icon: { + type: "svg_icon", + variant: "floppy_drive", + width: 14, + height: 14, + }, + + isHidden: typeof onSave !== "function" || !state.isActive, + label: "Save", + onClick: onSave, + })} +
) : null; @@ -711,10 +739,8 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { isConfiguratorActive: state.isActive, isSynced: form.isSynced, link, - onCancel, onConfigure: () => formToggle(true), onDelete: isViewInitialized ? viewDelete : null, - onSave: onSubmit, permissions, }) ) : ( diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index b82a583d0..d75c4a634 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -127,15 +127,13 @@ const KanbanPostTicket = ({ metadata }) => { postType === "Sponsorship" && metadata.features.sponsorship_supervisor, }; - console.log(data); - const header = (
- {features.author_avatar ? ( + {features.author ? (
{typeof link === "string" && link.length > 0 ? ( <> {widget("components.molecule.button", { - classNames: { root: "btn-sm btn-outline-secondary" }, + classNames: { root: "btn-sm btn-outline-secondary text-light" }, href: link, icon: { type: "bootstrap_icon", variant: "box-arrow-up-right" }, isHidden: "Disabled for MVP", @@ -98,7 +91,7 @@ const WorkspaceViewLayout = ({ })} {widget("components.molecule.button", { - classNames: { root: "btn-sm btn-outline-secondary" }, + classNames: { root: "btn-sm btn-outline-secondary text-light" }, icon: { type: "bootstrap_icon", variant: "bi-clipboard-fill" }, isHidden: isConfiguratorActive, label: "Copy link", @@ -109,35 +102,39 @@ const WorkspaceViewLayout = ({ {permissions.can_configure && ( <> - {widget("components.molecule.button", { - classNames: { root: "btn-sm btn-primary" }, - icon: { type: "bootstrap_icon", variant: "bi-gear-wide-connected" }, - isHidden: typeof onConfigure !== "function" || isConfiguratorActive, - label: "Configure", - onClick: onConfigure, - })} +
+ {(configurationControls ?? []).map((controlProps) => + widget( + "components.molecule.button", + { + classNames: { + root: "btn-sm btn-outline-secondary text-light", + }, + ...controlProps, + isHidden: !isConfiguratorActive, + }, + controlProps.label + ) + )} +
{widget("components.molecule.button", { classNames: { - root: "btn-sm btn-outline-warning shadow-none border-0 text-dark", + root: "btn-sm btn-outline-warning shadow-none border-0", }, - isHidden: typeof onSave !== "function" || !isConfiguratorActive, + isHidden: typeof onCancel !== "function" || !isConfiguratorActive, label: "Cancel", onClick: onCancel, })} - {(configurationControls ?? []).map((controlProps) => - widget( - "components.molecule.button", - { - classNames: { root: "btn-sm btn-outline-secondary" }, - ...controlProps, - isHidden: !isConfiguratorActive, - }, - controlProps.label - ) - )} + {widget("components.molecule.button", { + classNames: { root: "btn-sm btn-primary" }, + icon: { type: "bootstrap_icon", variant: "bi-gear-wide-connected" }, + isHidden: typeof onConfigure !== "function" || isConfiguratorActive, + label: "Configure", + onClick: onConfigure, + })} {widget("components.molecule.button", { classNames: { root: "btn-sm btn-success" }, From 89f54ca01cb319cedf72411faf7ebdb7c463118e Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 26 Sep 2023 02:46:48 +0400 Subject: [PATCH 32/81] wip --- src/gigs-board/pages/community/teams.jsx | 51 +++++++++++------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/gigs-board/pages/community/teams.jsx b/src/gigs-board/pages/community/teams.jsx index c26241e37..0a1eb1e47 100644 --- a/src/gigs-board/pages/community/teams.jsx +++ b/src/gigs-board/pages/community/teams.jsx @@ -140,35 +140,30 @@ if (communityData === null) { return
Loading...
; } -const UserList = (name, users) => { - return ( -
- {(users ?? []).map((user, i) => ( -
-
- {name + " #" + (i + 1)} -
-
- - - -
+const UserList = (name, users) => ( +
+ {(users ?? []).map((user, i) => ( +
+
+ {name + " #" + (i + 1)}
- ))} -
- ); -}; + +
+ + + +
+
+ ))} +
+); return widget("entity.community.layout", { path: [{ label: "Communities", pageId: "communities" }], From 30be4a7c865ce5bb468243904a6ffd26e75ab369 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Sat, 30 Sep 2023 02:23:24 +0400 Subject: [PATCH 33/81] fix: Derive sponsorship request indicator --- .../entity/workspace/view/kanban/post_ticket.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index d75c4a634..e9bd3df9e 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -102,22 +102,25 @@ const KanbanPostTicket = ({ metadata }) => { ? "Solution" : data.snapshot.post_type; + const isFundingRequested = + typeof data.snapshot.amount === "number" && data.snapshot.amount > 0; + const features = { ...metadata.features, sponsorship_request_indicator: postType === "Solution" && - data.snapshot.is_funding_requested && + isFundingRequested && metadata.features.sponsorship_request_indicator, requested_grant_value: postType === "Solution" && - data.snapshot.is_funding_requested && + isFundingRequested && metadata.features.requested_grant_value, requested_sponsor: postType === "Solution" && - data.snapshot.is_funding_requested && + isFundingRequested && metadata.features.requested_sponsor, approved_grant_value: From af59c5a09fcb634c8260cbbae64f3b77dddefe4a Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Sat, 30 Sep 2023 08:32:45 +0400 Subject: [PATCH 34/81] Introduce updated solution post format --- src/gigs-board/entity/post/CompactPost.jsx | 9 +- src/gigs-board/entity/post/Post.jsx | 17 +- src/gigs-board/entity/post/PostEditor.jsx | 201 ++++++++---------- .../workspace/view/kanban/post_ticket.jsx | 21 +- src/gigs-board/pages/Create.jsx | 5 +- 5 files changed, 109 insertions(+), 144 deletions(-) diff --git a/src/gigs-board/entity/post/CompactPost.jsx b/src/gigs-board/entity/post/CompactPost.jsx index e7a57cd88..51449977a 100644 --- a/src/gigs-board/entity/post/CompactPost.jsx +++ b/src/gigs-board/entity/post/CompactPost.jsx @@ -133,7 +133,7 @@ const header = ( const emptyIcons = { Idea: "bi-lightbulb", Comment: "bi-chat", - Submission: "bi-rocket", + Solution: "bi-rocket", Attestation: "bi-check-circle", Sponsorship: "bi-cash-coin", }; @@ -141,14 +141,11 @@ const emptyIcons = { const borders = { Idea: "border-secondary", Comment: "border-secondary", - Submission: "border-secondary", + Solution: "border-secondary", Attestation: "border-secondary", Sponsorship: "border-secondary", }; -const renamedPostType = - snapshot.post_type == "Submission" ? "Solution" : snapshot.post_type; - const postLables = post.snapshot.labels ? (
{post.snapshot.labels.map((label) => ( @@ -165,7 +162,7 @@ const postTitle =
- {renamedPostType}: {snapshot.name} + {snapshot.post_type}: {snapshot.name}
diff --git a/src/gigs-board/entity/post/Post.jsx b/src/gigs-board/entity/post/Post.jsx index 863bfcb83..bd5d7d3d7 100644 --- a/src/gigs-board/entity/post/Post.jsx +++ b/src/gigs-board/entity/post/Post.jsx @@ -197,7 +197,7 @@ const editControl = allowedToEdit ? (
diff --git a/src/gigs-board/entity/post/PostEditor.jsx b/src/gigs-board/entity/post/PostEditor.jsx index 67147dbd7..a493b97cb 100644 --- a/src/gigs-board/entity/post/PostEditor.jsx +++ b/src/gigs-board/entity/post/PostEditor.jsx @@ -51,7 +51,6 @@ function href(widgetName, linkProps) { }${linkPropsQuery}`; } /* END_INCLUDE: "common.jsx" */ - /* INCLUDE: "core/lib/autocomplete" */ const autocompleteEnabled = true; const AutoComplete = styled.div` @@ -79,20 +78,24 @@ const parentId = props.parentId ?? null; const postId = props.postId ?? null; const mode = props.mode ?? "Create"; -const referralLabels = props.referral ? [`referral:${props.referral}`] : []; -const labelStrings = (props.labels ?? []).concat(referralLabels); -const labels = labelStrings.map((s) => { - return { name: s }; -}); +const tags = (props.tags ?? props.labels ?? []).concat( + props.referral ? [`referral:${props.referral}`] : [] +); initState({ - seekingFunding: false, + fundraising: false, author_id: context.accountId, - // Should be a list of objects with field "name". - labels, - // Should be a list of labels as strings. - // Both of the label structures should be modified together. - labelStrings, + + /** + * A list of string tags. + */ + tags, + + /** + * Tags as a list of objects with field "name". + */ + tagOptions: tags.map((tag) => ({ name: tag })), + postType, name: props.name ?? "", description: props.description ?? "", @@ -111,7 +114,7 @@ if (!state.draftStateApplied && props.draftState) { let fields = { Comment: ["description"], Idea: ["name", "description"], - Submission: ["name", "description", "fund_raising"], + Solution: ["name", "description", "fundraising"], Attestation: ["name", "description"], Sponsorship: [ "name", @@ -143,7 +146,7 @@ const tokenMapping = { }; const onSubmit = () => { - let labels = state.labelStrings; + let labels = state.tags; var body = { Comment: { description: state.description, comment_version: "V2" }, Idea: { @@ -151,16 +154,13 @@ const onSubmit = () => { description: state.description, idea_version: "V1", }, - Submission: { + Solution: { name: state.name, - description: generateDescription( - state.description, - state.amount, - state.token, - state.supervisor, - state.seekingFunding - ), - submission_version: "V1", + description: state.description, + amount: state.amount, + sponsorship_token: tokenMapping[state.token], + supervisor: state.supervisor, + solution_version: "V2", }, Attestation: { name: state.name, @@ -235,8 +235,8 @@ const onSubmit = () => { } }; -const normalizeLabel = (label) => - label +const normalizeTag = (tag) => + tag .replaceAll(/[- \.]/g, "_") .replaceAll(/[^\w]+/g, "") .replaceAll(/_+/g, "-") @@ -245,18 +245,18 @@ const normalizeLabel = (label) => .toLowerCase() .trim("-"); -const checkLabel = (label) => { +const checkTag = (tag) => { Near.asyncView(nearDevGovGigsContractAccountId, "is_allowed_to_use_labels", { editor: context.accountId, - labels: [label], + labels: [tag], }).then((allowed) => { if (allowed) { State.update({ warning: "" }); } else { State.update({ warning: - 'The label "' + - label + + 'The tag "' + + tag + '" is protected and can only be added by moderators', }); return; @@ -264,75 +264,69 @@ const checkLabel = (label) => { }); }; -const setLabels = (labels) => { - labels = labels.map((o) => { - o.name = normalizeLabel(o.name); - return o; - }); - if (labels.length < state.labels.length) { - let oldLabels = new Set(state.labels.map((label) => label.name)); - for (let label of labels) { - oldLabels.delete(label.name); +const setTags = (tagOptions) => { + tagOptions = tagOptions.map((tagOption) => ({ + name: normalizeTag(tagOption.name), + })); + + if (tagOptions.length < state.tagOptions.length) { + const lastKnownTagList = new Set(state.tagOptions.map(({ name }) => name)); + + for (const tag of tagOptions) { + lastKnownTagList.delete(tag.name); } - let removed = oldLabels.values().next().value; + + const protectedTag = lastKnownTagList.values().next().value; + Near.asyncView( nearDevGovGigsContractAccountId, "is_allowed_to_use_labels", - { editor: context.accountId, labels: [removed] } - ).then((allowed) => { - if (allowed) { - let labelStrings = labels.map(({ name }) => name); - State.update({ labels, labelStrings }); - } else { - State.update({ - warning: - 'The label "' + - removed + - '" is protected and can only be updated by moderators', - }); - return; - } - }); + { editor: context.accountId, labels: [protectedTag] } + ).then((allowed) => + State.update( + allowed + ? { tags: lastKnownTagList, tagOptions } + : { + warning: `The tag "${protectedTag}" is protected and can only be updated by moderators`, + } + ) + ); } else { - let labelStrings = labels.map((o) => { - return o.name; + State.update({ + tags, + + tagOptions: tags.map((tagOption) => ({ + name: normalizeTag(tagOption.name), + })), }); - State.update({ labels, labelStrings }); } }; -const existingLabelStrings = +const existingTags = Near.view(nearDevGovGigsContractAccountId, "get_all_allowed_labels", { editor: context.accountId, }) ?? []; -const existingLabelSet = new Set(existingLabelStrings); -const existingLabels = existingLabelStrings.map((s) => { - return { name: s }; -}); -const labelEditor = ( +const tagEditor = (
- Labels: + Tags: ({ name: tag }))} placeholder="near.social, widget, NEP, standard, protocol, tool" - selected={state.labels} + selected={state.tagOptions} positionFixed - allowNew={(results, props) => { - return ( - !existingLabelSet.has(props.text) && - props.selected.filter((selected) => selected.name === props.text) - .length == 0 && - Near.view( - nearDevGovGigsContractAccountId, - "is_allowed_to_use_labels", - { editor: context.accountId, labels: [props.text] } - ) - ); - }} + allowNew={(results, props) => + !new Set(existingTags).has(props.text) && + props.selected.filter((selected) => selected.name === props.text) + .length == 0 && + Near.view(nearDevGovGigsContractAccountId, "is_allowed_to_use_labels", { + editor: context.accountId, + labels: [props.text], + }) + } />
); @@ -447,14 +441,14 @@ const isFundraisingDiv = (
); -function generateDescription(text, amount, token, supervisor, seekingFunding) { - const fundingText = - amount > 0 && token ? `###### Requested amount: ${amount} ${token}\n` : ""; - const supervisorText = supervisor - ? `###### Requested sponsor: @${supervisor}\n` - : ""; - return seekingFunding ? `${fundingText}${supervisorText}${text}` : text; -} - -const renamedPostType = postType == "Submission" ? "Solution" : postType; // Below there is a weird code with fields.includes("githubLink") ternary operator. // This is to hack around rendering bug of near.social. return (
- {mode} {renamedPostType} + {mode} {postType}
@@ -570,26 +554,26 @@ return ( >
)} - {/* This statement around the githubLinkDiv creates a weird render bug + {/* This statement around the githubLinkDiv creates a weird render bug where the title renders extra on state change. */} {fields.includes("githubLink") ? (
{fields.includes("githubLink") && githubLinkDiv} - {labelEditor} + {tagEditor} {fields.includes("name") && nameDiv} {fields.includes("description") && callDescriptionDiv()}
) : (
- {labelEditor} + {tagEditor} {fields.includes("name") && nameDiv} {fields.includes("amount") && amountDiv} {fields.includes("sponsorship_token") && tokenDiv} {fields.includes("supervisor") && supervisorDiv} {fields.includes("description") && callDescriptionDiv()} - {fields.includes("fund_raising") && isFundraisingDiv} - {state.seekingFunding && - fields.includes("fund_raising") && + {fields.includes("fundraising") && isFundraisingDiv} + {state.fundraising && + fields.includes("fundraising") && fundraisingDiv}
)} @@ -599,7 +583,7 @@ return ( backgroundColor: "#0C7283", color: "#f3f3f3", }} - disabled={state.seekingFunding && (!state.amount || state.amount < 1)} + disabled={state.fundraising && (!state.amount || state.amount < 1)} className="btn btn-light mb-2 p-3" onClick={onSubmit} > @@ -617,19 +601,10 @@ return ( likes: [], snapshot: { editor_id: state.editor_id, - labels: state.labelStrings, + labels: state.tags, post_type: postType, name: state.name, - description: - postType == "Submission" - ? generateDescription( - state.description, - state.amount, - state.token, - state.supervisor, - state.seekingFunding - ) - : state.description, + description: state.description, amount: state.amount, sponsorship_token: state.token, supervisor: state.supervisor, diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index e9bd3df9e..30edbede1 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -83,7 +83,7 @@ const AttractableImage = styled.img` const iconsByPostType = { Idea: "bi-lightbulb", Comment: "bi-chat", - Submission: "bi-rocket", + Solution: "bi-rocket", Attestation: "bi-check-circle", Sponsorship: "bi-cash-coin", }; @@ -97,11 +97,6 @@ const KanbanPostTicket = ({ metadata }) => { return
Loading ...
; } - const postType = - data.snapshot.post_type === "Submission" - ? "Solution" - : data.snapshot.post_type; - const isFundingRequested = typeof data.snapshot.amount === "number" && data.snapshot.amount > 0; @@ -109,25 +104,27 @@ const KanbanPostTicket = ({ metadata }) => { ...metadata.features, sponsorship_request_indicator: - postType === "Solution" && + data.snapshot.post_type === "Solution" && isFundingRequested && metadata.features.sponsorship_request_indicator, requested_grant_value: - postType === "Solution" && + data.snapshot.post_type === "Solution" && isFundingRequested && metadata.features.requested_grant_value, requested_sponsor: - postType === "Solution" && + data.snapshot.post_type === "Solution" && isFundingRequested && metadata.features.requested_sponsor, approved_grant_value: - postType === "Sponsorship" && metadata.features.approved_grant_value, + data.snapshot.post_type === "Sponsorship" && + metadata.features.approved_grant_value, sponsorship_supervisor: - postType === "Sponsorship" && metadata.features.sponsorship_supervisor, + data.snapshot.post_type === "Sponsorship" && + metadata.features.sponsorship_supervisor, }; const header = ( @@ -197,7 +194,7 @@ const KanbanPostTicket = ({ metadata }) => { ) : null} - {[features.type ? postType : null, data.snapshot.name] + {[features.type ? data.snapshot.post_type : null, data.snapshot.name] .filter( (maybeString) => typeof maybeString === "string" && maybeString.length > 0 diff --git a/src/gigs-board/pages/Create.jsx b/src/gigs-board/pages/Create.jsx index b554143fb..f145e7a08 100644 --- a/src/gigs-board/pages/Create.jsx +++ b/src/gigs-board/pages/Create.jsx @@ -154,11 +154,10 @@ const onSubmit = () => { if (state.postType === "Solution") { body = { ...body, - post_type: "Submission", - submission_version: "V1", + post_type: "Solution", + solution_version: "V2", }; } else { - // Idea body = { ...body, post_type: "Idea", From b2e6dedd71109eda6086c7034fb8dc911ed8291b Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 3 Oct 2023 21:31:32 +0400 Subject: [PATCH 35/81] wip: Unlock noop controls --- .../workspace/view/kanban/configurator.jsx | 97 +++++++++---------- 1 file changed, 45 insertions(+), 52 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index e100c1063..cddac004d 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -157,44 +157,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, } - }; + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -375,15 +375,10 @@ const KanbanPostBoardTagsSchema = { const KanbanPostBoardTicketFeaturesSchema = { author: { label: "Author" }, like_count: { label: "Likes" }, - reply_count: { label: "Replies", noop: true }, - - sponsorship_request_indicator: { - label: "Sponsorship request indicator", - noop: true, - }, - - requested_grant_value: { label: "Requested grant value", noop: true }, - requested_sponsor: { label: "Requested sponsor", noop: true }, + reply_count: { label: "Replies" }, + sponsorship_request_indicator: { label: "Sponsorship request indicator" }, + requested_grant_value: { label: "Requested grant value" }, + requested_sponsor: { label: "Requested sponsor" }, approved_grant_value: { label: "Approved amount" }, sponsorship_supervisor: { label: "Supervisor" }, tags: { label: "Tags" }, @@ -497,12 +492,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); From c093506c30846b8810d656728e4efb8fdcb6b912 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 6 Oct 2023 04:27:01 +0400 Subject: [PATCH 36/81] wip --- src/gigs-board/entity/post/PostEditor.jsx | 286 ++++++++++-------- .../workspace/view/kanban/configurator.jsx | 92 +++--- .../workspace/view/kanban/post_ticket.jsx | 11 +- src/gigs-board/pages/Teams.jsx | 1 - 4 files changed, 220 insertions(+), 170 deletions(-) diff --git a/src/gigs-board/entity/post/PostEditor.jsx b/src/gigs-board/entity/post/PostEditor.jsx index a493b97cb..514b100ce 100644 --- a/src/gigs-board/entity/post/PostEditor.jsx +++ b/src/gigs-board/entity/post/PostEditor.jsx @@ -73,7 +73,7 @@ function autoCompleteAccountId(id) { } /* END_INCLUDE: "core/lib/autocomplete" */ -const postType = props.postType ?? "Sponsorship"; +const postType = props.postType ?? "Idea"; const parentId = props.parentId ?? null; const postId = props.postId ?? null; const mode = props.mode ?? "Create"; @@ -99,9 +99,9 @@ initState({ postType, name: props.name ?? "", description: props.description ?? "", - amount: props.amount ?? "0", + amount: props.amount ?? props.requested_sponsorship_amount ?? "0", token: tokenMapping[props.token] ?? "USDT", - supervisor: props.supervisor ?? "", + supervisor: props.supervisor ?? props.requested_sponsor ?? "", githubLink: props.githubLink ?? "", warning: "", draftStateApplied: false, @@ -114,8 +114,17 @@ if (!state.draftStateApplied && props.draftState) { let fields = { Comment: ["description"], Idea: ["name", "description"], - Solution: ["name", "description", "fundraising"], + + Solution: [ + "name", + "description", + "requested_sponsorship_amount", + "sponsorship_token", + "requested_sponsor", + ], + Attestation: ["name", "description"], + Sponsorship: [ "name", "description", @@ -123,6 +132,7 @@ let fields = { "sponsorship_token", "supervisor", ], + Github: ["githubLink", "name", "description"], }[postType]; @@ -157,9 +167,9 @@ const onSubmit = () => { Solution: { name: state.name, description: state.description, - amount: state.amount, + requested_sponsor: state.supervisor, + requested_sponsorship_amount: state.amount, sponsorship_token: tokenMapping[state.token], - supervisor: state.supervisor, solution_version: "V2", }, Attestation: { @@ -170,9 +180,9 @@ const onSubmit = () => { Sponsorship: { name: state.name, description: state.description, + supervisor: state.supervisor, amount: state.amount, sponsorship_token: tokenMapping[state.token], - supervisor: state.supervisor, sponsorship_version: "V1", }, Github: { @@ -380,17 +390,6 @@ const tokenDiv = (
); -const supervisorDiv = ( -
- Supervisor: - State.update({ supervisor: event.target.value })} - /> -
-); - const callDescriptionDiv = () => { return (
@@ -429,103 +428,56 @@ const disclaimer = ( ); const isFundraisingDiv = ( - // This is jank with just btns and not radios. But the radios were glitchy af - <> -
-

- Are you seeking funding for your solution? - (Optional) -

-
-
-
-
+
+

+ Are you seeking funding for your solution? + (Optional) +

+ +
+
- -); -const fundraisingDiv = ( -
-
- Currency - -
-
- Requested amount - (Numbers Only) - 0 ? state.amount : ""} - min={0} - onChange={(event) => { - State.update({ - amount: Number( - event.target.value.toString().replace(/e/g, "") - ).toString(), - }); - }} - /> -
-
-

- Requested sponsor - (Optional) -

-

- If you are requesting funding from a specific sponsor, please enter - their username. -

-
- - @ - - State.update({ supervisor: event.target.value })} +
+
+ No +
); @@ -545,15 +497,17 @@ return ( role="alert" > {state.warning} + + />
)} + {/* This statement around the githubLinkDiv creates a weird render bug where the title renders extra on state change. */} {fields.includes("githubLink") ? ( @@ -567,16 +521,106 @@ return (
{tagEditor} {fields.includes("name") && nameDiv} + {fields.includes("amount") && amountDiv} + {fields.includes("sponsorship_token") && tokenDiv} - {fields.includes("supervisor") && supervisorDiv} + + {(fields.includes("supervisor") || + fields.includes("requested_sponsor")) && ( +
+ {`${ + state.postType === "Solution" + ? "Requested sponsor" + : "Supervisor" + }:`} + + + State.update({ supervisor: event.target.value }) + } + /> +
+ )} + {fields.includes("description") && callDescriptionDiv()} - {fields.includes("fundraising") && isFundraisingDiv} - {state.fundraising && - fields.includes("fundraising") && - fundraisingDiv} + + {fields.includes("requested_sponsorship_amount") && + state.fundraising && ( +
+
+ Currency + + +
+ +
+ Requested amount + (Numbers only) + + 0 ? state.amount : ""} + min={0} + onChange={(event) => + State.update({ + amount: Number( + event.target.value.toString().replace(/e/g, "") + ).toString(), + }) + } + /> +
+ +
+

+ Requested sponsor + (Optional) +

+ +

+ If you are requesting funding from a specific sponsor, + please enter their username. +

+ +
+ + @ + + + + State.update({ supervisor: event.target.value }) + } + /> +
+
+
+ )}
)} + + {disclaimer}
+ +
+ {widget("entity.post.spawner", { + isHidden: state.isSpawnerHidden, + onCancel: () => spawnerToggle(false), + })} + {widget("entity.post.List", { tag: communityData.tag })}
+
{widget("entity.community.sidebar", { handle: communityData.handle, From e6d49b6d1516763e2ef035fef88e84d55f4986a1 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 10 Oct 2023 17:00:52 +0400 Subject: [PATCH 43/81] wip: Fix errors preventing post spawner rendering --- src/gigs-board/entity/post/Post.jsx | 2 +- src/gigs-board/entity/post/editor.jsx | 20 ++++++++++---------- src/gigs-board/entity/post/spawner.jsx | 5 +++-- src/gigs-board/pages/community/activity.jsx | 1 + 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gigs-board/entity/post/Post.jsx b/src/gigs-board/entity/post/Post.jsx index 60e6e01b6..dcd7dbfe0 100644 --- a/src/gigs-board/entity/post/Post.jsx +++ b/src/gigs-board/entity/post/Post.jsx @@ -549,7 +549,7 @@ const postExtra = snapshot.post_type == "Sponsorship" ? (
- {`Maximum amount: ${snapshot.amount}`} + {`Maximum amount: ${snapshot.amount} `} {tokenResolver(snapshot.sponsorship_token)}
diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index 2db5477fe..b3208c4df 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -255,7 +255,7 @@ const PostEditor = ({ body["post_type"] = state.post_type; - let transactions = []; + const transactions = []; if (mode == "Create") { onDraftStateChange?.({ ...state, parent_post_id: id }); @@ -314,8 +314,8 @@ const PostEditor = ({ })) ); - const setTags = (tagOptions) => { - tagOptions = tagOptions.map((tagOption) => ({ + const setTags = (options) => { + const tagOptions = options.map((tagOption) => ({ name: normalizeTag(tagOption.name), })); @@ -376,7 +376,7 @@ const PostEditor = ({ positionFixed allowNew={(results, params) => !new Set(existingTags).has(params.text) && - selected.filter( + (selected ?? []).filter( (selectedTagOption) => selectedTagOption.name === params.text ).length === 0 && Near.view( @@ -392,7 +392,7 @@ const PostEditor = ({
); - const nameDiv = ( + const titleSection = (
Title: @@ -409,7 +409,7 @@ const PostEditor = ({
); - const callDescriptionDiv = () => ( + const descriptionSection = (
Description:
@@ -554,13 +554,13 @@ const PostEditor = ({ )} {tagEditor} - {fields.includes("name") && nameDiv} - {fields.includes("description") && callDescriptionDiv()} + {fields.includes("name") && titleSection} + {fields.includes("description") && descriptionSection}
) : (
{tagEditor} - {fields.includes("name") && nameDiv} + {fields.includes("name") && titleSection} {fundraisingToggle} {fields.includes("amount") && ( @@ -625,7 +625,7 @@ const PostEditor = ({
)} - {fields.includes("description") && callDescriptionDiv()} + {fields.includes("description") && descriptionSection} {fields.includes("requested_sponsorship_amount") && state.fundraising && ( diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/spawner.jsx index bedc07d81..d5439bc51 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/spawner.jsx @@ -112,7 +112,7 @@ const postTypeOptions = { }, }; -const PostSpawner = ({ isHidden, onCancel }) => { +const PostSpawner = ({ isHidden, onCancel, tags }) => { State.init({ post_type: postTypeOptions.Idea.name }); const typeSwitch = (optionName) => @@ -124,8 +124,8 @@ const PostSpawner = ({ isHidden, onCancel }) => { return (
{Object.values(postTypeOptions).map((option) => ( @@ -154,6 +154,7 @@ const PostSpawner = ({ isHidden, onCancel }) => { onDraftStateChange, parent_id: null, post_type: type, + tags, })}
); diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index a66867df4..70e23dbea 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -189,6 +189,7 @@ const CommunityActivityPage = ({ handle }) => { {widget("entity.post.spawner", { isHidden: state.isSpawnerHidden, onCancel: () => spawnerToggle(false), + tags: [communityData.tag], })} {widget("entity.post.List", { tag: communityData.tag })} From c0bb50ab4b52bed76fb9d0bbd13ada6dd8638920 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 10 Oct 2023 17:50:24 +0400 Subject: [PATCH 44/81] wip --- src/gigs-board/entity/post/editor.jsx | 223 ++++++++++---------- src/gigs-board/entity/post/spawner.jsx | 8 +- src/gigs-board/pages/community/activity.jsx | 18 +- 3 files changed, 122 insertions(+), 127 deletions(-) diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index b3208c4df..09612f376 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -92,6 +92,31 @@ const normalizeTag = (tag) => .toLowerCase() .trim("-"); +const postSchemas = { + Comment: ["description"], + Idea: ["name", "description"], + + Solution: [ + "name", + "description", + "requested_sponsorship_amount", + "sponsorship_token", + "requested_sponsor", + ], + + Attestation: ["name", "description"], + + Sponsorship: [ + "name", + "description", + "amount", + "sponsorship_token", + "supervisor", + ], + + Github: ["github_link", "name", "description"], +}; + const availableTokenParameters = { NEAR: "NEAR", @@ -121,7 +146,6 @@ const PostEditor = ({ onCancel, onDraftStateChange, parent_id, - post_type, referral, requested_sponsor, requested_sponsorship_amount, @@ -132,10 +156,11 @@ const PostEditor = ({ sponsorship_token, ...otherProps }) => { - const mode = otherProps.mode ?? "Create"; + const mode = otherProps.mode ?? "Create", + post_type = otherProps.post_type ?? "Idea"; State.init({ - fundraising: false, + fundraising: typeof amount === "string" && parseInt(amount) > 0, author_id: context.accountId, /** @@ -147,7 +172,6 @@ const PostEditor = ({ ], tagOptions: tags.map((tag) => ({ name: tag })), - post_type: post_type ?? "Idea", name: name ?? "", description: description ?? "", amount: requested_sponsorship_amount ?? amount ?? "0", @@ -186,30 +210,7 @@ const PostEditor = ({ })); } - const fields = { - Comment: ["description"], - Idea: ["name", "description"], - - Solution: [ - "name", - "description", - "requested_sponsorship_amount", - "sponsorship_token", - "requested_sponsor", - ], - - Attestation: ["name", "description"], - - Sponsorship: [ - "name", - "description", - "amount", - "sponsorship_token", - "supervisor", - ], - - Github: ["github_link", "name", "description"], - }[state.post_type]; + const fields = postSchemas[post_type]; const onSubmit = () => { const body = { @@ -251,9 +252,9 @@ const PostEditor = ({ github_version: "V0", github_link: state.github_link, }, - }[state.post_type]; + }[post_type]; - body["post_type"] = state.post_type; + body["post_type"] = post_type; const transactions = []; @@ -507,7 +508,7 @@ const PostEditor = ({ return (
-
{`${mode} ${state.post_type}`}
+
{`${mode} ${post_type}`}
{state.warning && ( @@ -560,10 +561,10 @@ const PostEditor = ({ ) : (
{tagEditor} - {fields.includes("name") && titleSection} - {fundraisingToggle} + {fields.includes("name") ? titleSection : null} + {post_type === "Solution" ? fundraisingToggle : null} - {fields.includes("amount") && ( + {fields.includes("amount") ? (
Amount: @@ -578,9 +579,9 @@ const PostEditor = ({ } />
- )} + ) : null} - {state.post_type === "Sponsorship" && ( + {post_type === "Sponsorship" ? (
Currency @@ -601,16 +602,11 @@ const PostEditor = ({
- )} + ) : null} - {(fields.includes("supervisor") || - fields.includes("requested_sponsor")) && ( + {post_type === "Sponsorship" && (
- {`${ - state.post_type === "Solution" - ? "Requested sponsor" - : "Supervisor" - }:`} + Supervisor )} - {fields.includes("description") && descriptionSection} - - {fields.includes("requested_sponsorship_amount") && - state.fundraising && ( -
-
- Currency + {fields.includes("description") ? descriptionSection : null} + + {post_type === "Solution" && state.fundraising ? ( +
+
+ Currency + + +
- -
+
+ Requested amount + (Numbers only) + + 0 ? state.amount : ""} + min={0} + onChange={(event) => + State.update((lastKnownState) => ({ + ...lastKnownState, + + amount: Number( + event.target.value.toString().replace(/e/g, "") + ).toString(), + })) + } + /> +
-
- Requested amount - (Numbers only) +
+

+ Requested sponsor + (Optional) +

+ +

+ If you are requesting funding from a specific sponsor, + please enter their account ID. +

+ +
+ + @ + 0 ? state.amount : ""} - min={0} + type="text" + className="form-control" + placeholder="Enter account ID" + value={state.supervisor} onChange={(event) => State.update((lastKnownState) => ({ ...lastKnownState, - - amount: Number( - event.target.value.toString().replace(/e/g, "") - ).toString(), + supervisor: event.target.value, })) } />
- -
-

- Requested sponsor - (Optional) -

- -

- If you are requesting funding from a specific sponsor, - please enter their account ID. -

- -
- - @ - - - - State.update((lastKnownState) => ({ - ...lastKnownState, - supervisor: event.target.value, - })) - } - /> -
-
- )} +
+ ) : null}
)} @@ -751,7 +746,7 @@ const PostEditor = ({ editor_id: state.editor_id, github_link: state.github_link, labels: state.tags, - post_type: state.post_type, + post_type: post_type, sponsorship_token: state.sponsorship_token, supervisor: state.supervisor, }, diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/spawner.jsx index d5439bc51..9d93ffbc0 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/spawner.jsx @@ -123,9 +123,11 @@ const PostSpawner = ({ isHidden, onCancel, tags }) => { return (
{Object.values(postTypeOptions).map((option) => ( @@ -153,7 +155,7 @@ const PostSpawner = ({ isHidden, onCancel, tags }) => { onCancel, onDraftStateChange, parent_id: null, - post_type: type, + post_type: state.post_type, tags, })}
diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 70e23dbea..76c00c8a6 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -184,16 +184,14 @@ const CommunityActivityPage = ({ handle }) => {
-
-
- {widget("entity.post.spawner", { - isHidden: state.isSpawnerHidden, - onCancel: () => spawnerToggle(false), - tags: [communityData.tag], - })} - - {widget("entity.post.List", { tag: communityData.tag })} -
+
+ {widget("entity.post.spawner", { + isHidden: state.isSpawnerHidden, + onCancel: () => spawnerToggle(false), + tags: [communityData.tag], + })} + + {widget("entity.post.List", { tag: communityData.tag })}
From 840bc01eafe97864201686e72ebac098c8520d40 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 11 Oct 2023 00:18:25 +0400 Subject: [PATCH 45/81] wip --- src/gigs-board/entity/post/Post.jsx | 407 ++++++++++++++++------------ 1 file changed, 230 insertions(+), 177 deletions(-) diff --git a/src/gigs-board/entity/post/Post.jsx b/src/gigs-board/entity/post/Post.jsx index dcd7dbfe0..cc9a9b25d 100644 --- a/src/gigs-board/entity/post/Post.jsx +++ b/src/gigs-board/entity/post/Post.jsx @@ -82,6 +82,7 @@ const AttractableImage = styled.img` const ButtonWithHover = styled.button` background-color: #fff; + &:hover { background-color: #e9ecef; color: #000; @@ -89,9 +90,11 @@ const ButtonWithHover = styled.button` `; const postId = props.post.id ?? (props.id ? parseInt(props.id) : 0); + const post = props.post ?? Near.view(nearDevGovGigsContractAccountId, "get_post", { post_id: postId }); + if (!post) { return
Loading ...
; } @@ -102,12 +105,18 @@ const compareTimestamp = props.compareTimestamp ?? ""; const swapTimestamps = currentTimestamp < compareTimestamp; const snapshotHistory = post.snapshot_history; + const snapshot = currentTimestamp === post.snapshot.timestamp ? post.snapshot : (snapshotHistory && snapshotHistory.find((s) => s.timestamp === currentTimestamp)) ?? null; + +const fundingAmount = parseInt( + snapshot.requested_sponsorship_amount ?? snapshot.amount +); + const compareSnapshot = compareTimestamp === post.snapshot.timestamp ? post.snapshot @@ -117,6 +126,7 @@ const compareSnapshot = // If this post is displayed under another post. Used to limit the size. const isUnderPost = props.isUnderPost ? true : false; + const parent_id = Near.view(nearDevGovGigsContractAccountId, "get_parent_id", { post_id: postId, }); @@ -133,32 +143,33 @@ const defaultExpanded = expandable ? props.defaultExpanded : true; const draftState = props.draftState; function readableDate(timestamp) { - var a = new Date(timestamp); - return a.toDateString() + " " + a.toLocaleTimeString(); + const date = new Date(timestamp); + return date.toDateString() + " " + date.toLocaleTimeString(); } const timestamp = readableDate( snapshot.timestamp ? snapshot.timestamp / 1000000 : Date.now() ); -const postSearchKeywords = props.searchKeywords ? ( -
- Found keywords: - {props.searchKeywords.map((tag) => { - return widget("components.atom.tag", { linkTo: "Feed", tag }); - })} -
-) : ( -
-); +const searchKeywords = + (props.searchKeywords ?? []).length > 0 ? ( +
+ + { +
+ Found keywords: -const searchKeywords = props.searchKeywords ? ( -
- {postSearchKeywords} -
-) : ( -
-); + {(props.searchKeywords ?? []).map((tag) => + widget("components.atom.tag", { linkTo: "Feed", tag }, tag) + )} +
+ } +
+
+ ) : null; const allowedToEdit = !props.isPreview && @@ -167,35 +178,34 @@ const allowedToEdit = editor: context.accountId, }); -const btnEditorWidget = (post_type, name) => { - return ( -
  • - - State.update({ post_type, editorType: "EDIT", showEditor: true }) - } - > - {name} - -
  • - ); -}; +const btnEditorWidget = (post_type, name) => ( +
  • + + State.update({ post_type, editorType: "EDIT", showEditor: true }) + } + > + {name} + +
  • +); const editControl = allowedToEdit ? ( -
    +
    -
    -) : ( -
    -); +) : null; -const shareButton = props.isPreview ? ( -
    -) : ( +const shareButton = props.isPreview ? null : ( -
    +
    ); -// card-header const header = (
    - -
    -
    + +
    +
    {widget("components.molecule.profile-card", { accountId: post.author_id, })}
    -
    -
    + +
    +
    {editControl} {timestamp} + {widget("entity.post.History", { post, timestamp: currentTimestamp, })} + {shareButton}
    @@ -269,8 +277,6 @@ const fillIcons = { Reply: "bi-reply-fill", }; -// Trigger saving this widget. - const borders = { Idea: "border-light", Comment: "border-light", @@ -282,28 +288,36 @@ const borders = { const containsLike = props.isPreview ? false - : post.likes.find((l) => l.author_id == context.accountId); + : post.likes.find((l) => l.author_id === context.accountId); + const likeBtnClass = containsLike ? fillIcons.Like : emptyIcons.Like; -// This must be outside onLike, because Near.view returns null at first, and when the view call finished, it returns true/false. + +// This must be outside onLike, because Near.view returns null at first, +// and when the view call finished, it returns true/false. // If checking this inside onLike, it will give `null` and we cannot tell the result is true or false. let grantNotify = Near.view("social.near", "is_write_permission_granted", { predecessor_id: nearDevGovGigsContractAccountId, key: context.accountId + "/index/notify", }); + if (grantNotify === null) { return; } + const onLike = () => { if (!context.accountId) { return; } + let likeTxn = [ { contractName: nearDevGovGigsContractAccountId, methodName: "add_like", + args: { post_id: postId, }, + deposit: Big(10).pow(21).mul(2), gas: Big(10).pow(12).mul(100), }, @@ -313,34 +327,36 @@ const onLike = () => { likeTxn.unshift({ contractName: "social.near", methodName: "grant_write_permission", + args: { predecessor_id: nearDevGovGigsContractAccountId, keys: [context.accountId + "/index/notify"], }, + deposit: Big(10).pow(23), gas: Big(10).pow(12).mul(30), }); } + Near.call(likeTxn); }; const btnCreatorWidget = (post_type, icon, name, desc) => { return ( -
  • +
  • State.update({ post_type, editorType: "CREATE", showEditor: true }) } > - - {" "} - -
  • @@ -348,17 +364,22 @@ const btnCreatorWidget = (post_type, icon, name, desc) => { }; const buttonsFooter = props.isPreview ? null : ( -
    -
    -
    +
    +
    +
    - - {post.likes.length == 0 + + + {post.likes.length === 0 ? "Like" : widget("components.layout.LikeButton.Faces", { likesByUsers: Object.fromEntries( @@ -366,44 +387,52 @@ const buttonsFooter = props.isPreview ? null : ( ), })} -
    + +
    -
    + - {" "} + {`Expand Replies (${childPostIds.length})`} @@ -435,7 +465,8 @@ const buttonsFooter = props.isPreview ? null : ( className="btn" key="link-to-parent" > - Go to parent + + Go to parent )} @@ -446,6 +477,7 @@ const buttonsFooter = props.isPreview ? null : ( const tokenMapping = { NEAR: "NEAR", + USDT: { NEP141: { address: "usdt.tether-token.near", @@ -457,11 +489,14 @@ const tokenMapping = { const reverseTokenMapping = Object.keys(tokenMapping).reduce( (reverseMap, key) => { const value = tokenMapping[key]; + if (typeof value === "object") { reverseMap[JSON.stringify(value)] = key; } + return reverseMap; }, + {} ); @@ -484,61 +519,62 @@ const isDraft = function Editor() { return ( -
    +
    - {state.editorType === "CREATE" ? ( - <> - {widget("entity.post.editor", { - post_type: state.post_type, - onDraftStateChange: props.onDraftStateChange, - draftState: - draftState?.parent_post_id == postId ? draftState : undefined, - parent_id: postId, - mode: "Create", - })} - - ) : ( - <> - {widget("entity.post.editor", { - ...post.snapshot, - post_type: state.post_type, - id: postId, - mode: "Edit", - author_id: post.author_id, - sponsorship_token: tokenResolver(post.snapshot.sponsorship_token), - onDraftStateChange: props.onDraftStateChange, - - draftState: - draftState?.edit_post_id == postId ? draftState : undefined, - })} - + {widget( + "entity.post.editor", + + state.editorType === "CREATE" + ? { + draftState: + draftState?.parent_post_id === postId + ? draftState + : undefined, + + mode: "Create", + onDraftStateChange: props.onDraftStateChange, + parent_id: postId, + post_type: state.post_type, + } + : { + ...post.snapshot, + id: postId, + author_id: post.author_id, + + draftState: + draftState?.edit_post_id === postId ? draftState : undefined, + + mode: "Edit", + onDraftStateChange: props.onDraftStateChange, + post_type: state.post_type, + + sponsorship_token: tokenResolver( + post.snapshot.sponsorship_token + ), + } )}
    ); } -const tags = post.snapshot.labels ? ( -
    - {post.snapshot.labels.map((tag) => { - return widget("components.atom.tag", { linkTo: "Feed", tag }); - })} +const tags = ( +
    + {(post.snapshot.labels ?? []).map((tag) => + widget("components.atom.tag", { linkTo: "Feed", tag }, tag) + )}
    -) : ( -
    ); const postTitle = - snapshot.post_type == "Comment" ? ( -
    - ) : ( -
    + snapshot.post_type === "Comment" ? null : ( +
    -
    - +
    + {snapshot.post_type}: {snapshot.name}
    @@ -546,42 +582,49 @@ const postTitle = ); const postExtra = - snapshot.post_type == "Sponsorship" ? ( + (snapshot.post_type === "Solution" || snapshot.post_type === "Sponsorship") && + typeof fundingAmount === "number" && + fundingAmount > 0 ? (
    -
    - {`Maximum amount: ${snapshot.amount} `} - {tokenResolver(snapshot.sponsorship_token)} +
    + {`Maximum amount: ${fundingAmount} ${tokenResolver( + snapshot.sponsorship_token + )}`}
    -
    - Supervisor:{" "} + +
    + {`${ + snapshot.post_type === "Solution" ? "Requested sponsor" : "Supervisor" + }:`} +
    - ) : ( -
    - ); + ) : null; const childPostHasDraft = childPostIds.find( (childId) => - childId == draftState?.edit_post_id || childId == draftState?.parent_post_id + childId === draftState?.edit_post_id || + childId === draftState?.parent_post_id ); + if ( (childPostHasDraft || state.childrenOfChildPostsHasDraft) && - props.expandParent + typeof props.expandParent === "function" ) { props.expandParent(); } const postsList = - props.isPreview || childPostIds.length == 0 ? ( -
    - ) : ( -
    + props.isPreview || childPostIds.length === 0 ? null : ( +
    State.update({ childrenOfChildPostsHasDraft: true }), }, @@ -617,7 +661,7 @@ const isInList = props.isInList; const contentArray = snapshot.description.split("\n"); const needClamp = isInList && contentArray.length > 5; -initState({ +State.init({ clamp: needClamp, }); @@ -634,56 +678,54 @@ const descriptionArea = isUnderPost ? ( ) : (
    -
    +
    {widget("components.molecule.markdown-viewer", { text: state.clamp ? clampedContent : snapshot.description, })}
    + {state.clamp ? ( -
    + - ) : ( - <> - )} + ) : null}
    ); -const timestampElement = (_snapshot) => { - return ( - - {readableDate(_snapshot.timestamp / 1000000).substring(4)} - - - {_snapshot.editor_id.substring(0, 8)} - - ); -}; +const timestampElement = (_snapshot) => ( + + {readableDate(_snapshot.timestamp / 1000000).substring(4)} + + + + {_snapshot.editor_id.substring(0, 8)} + +); function combineText(_snapshot) { return ( @@ -699,21 +741,28 @@ function combineText(_snapshot) { return ( {header} +
    {searchKeywords} + {compareSnapshot ? (
    -
    -
    +
    +
    {timestampElement(snapshot)} + {snapshot !== compareSnapshot && ( <> -
    - +
    +
    + {timestampElement(compareSnapshot)} )} @@ -724,12 +773,15 @@ return ( src="markeljan.near/widget/MarkdownDiff" props={{ post: post, + currentCode: combineText( swapTimestamps ? compareSnapshot : snapshot ), + prevCode: combineText( swapTimestamps ? snapshot : compareSnapshot ), + showLineNumber: true, }} /> @@ -741,6 +793,7 @@ return ( {descriptionArea} )} + {tags} {buttonsFooter} {!props.isPreview && (isDraft || state.showEditor) && } From befec5680a03ba88faca5fa6766d41c36ee8086c Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 11 Oct 2023 01:48:38 +0400 Subject: [PATCH 46/81] wip --- src/gigs-board/entity/post/List.jsx | 2 +- src/gigs-board/entity/post/{Post.jsx => card.jsx} | 11 +++-------- src/gigs-board/entity/post/editor.jsx | 2 +- src/gigs-board/pages/Create.jsx | 2 +- src/gigs-board/pages/Post.jsx | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) rename src/gigs-board/entity/post/{Post.jsx => card.jsx} (99%) diff --git a/src/gigs-board/entity/post/List.jsx b/src/gigs-board/entity/post/List.jsx index 140db7f9d..18af4bb00 100644 --- a/src/gigs-board/entity/post/List.jsx +++ b/src/gigs-board/entity/post/List.jsx @@ -107,7 +107,7 @@ function defaultRenderItem(postId, additionalProps) { return (
    {widget( - `entity.post.Post`, + `entity.post.card`, { id: postId, expandable: true, diff --git a/src/gigs-board/entity/post/Post.jsx b/src/gigs-board/entity/post/card.jsx similarity index 99% rename from src/gigs-board/entity/post/Post.jsx rename to src/gigs-board/entity/post/card.jsx index cc9a9b25d..5ddb07013 100644 --- a/src/gigs-board/entity/post/Post.jsx +++ b/src/gigs-board/entity/post/card.jsx @@ -635,7 +635,7 @@ const postsList = > {childPostIds.map((childId) => widget( - "entity.post.Post", + "entity.post.card", { id: childId, isUnderPost: true, @@ -713,13 +713,8 @@ const timestampElement = (_snapshot) => ( src="mob.near/widget/ProfileImage" props={{ accountId: _snapshot.editor_id, - style: { - width: "1.25em", - height: "1.25em", - }, - imageStyle: { - transform: "translateY(-12.5%)", - }, + style: { width: "1.25em", height: "1.25em" }, + imageStyle: { transform: "translateY(-12.5%)" }, }} /> diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index 09612f376..78779dd49 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -731,7 +731,7 @@ const PostEditor = ({
    Preview: - {widget("entity.post.Post", { + {widget("entity.post.card", { isPreview: true, id: 0, // irrelevant diff --git a/src/gigs-board/pages/Create.jsx b/src/gigs-board/pages/Create.jsx index 84dc307d5..916a1ad29 100644 --- a/src/gigs-board/pages/Create.jsx +++ b/src/gigs-board/pages/Create.jsx @@ -596,7 +596,7 @@ return (

    Preview

    - {widget("entity.post.Post", { + {widget("entity.post.card", { isPreview: true, id: 0, // irrelevant post: { diff --git a/src/gigs-board/pages/Post.jsx b/src/gigs-board/pages/Post.jsx index 797f545ad..dab4ee1a1 100644 --- a/src/gigs-board/pages/Post.jsx +++ b/src/gigs-board/pages/Post.jsx @@ -108,7 +108,7 @@ if (is_edit_or_add_post_transaction) { ); } else { return widget("components.template.app-layout", { - children: widget("entity.post.Post", { + children: widget("entity.post.card", { id: props.id, timestamp: props.timestamp, compareTimestamp: props.compareTimestamp, From 0a79007baaec15b224a30ec5bf09b474568dddcd Mon Sep 17 00:00:00 2001 From: Espen Simensen Date: Wed, 11 Oct 2023 18:40:41 +0200 Subject: [PATCH 47/81] feat: Added USDC currency support for solution and sponsorship posts (#263) --- src/gigs-board/entity/post/Post.jsx | 5 +++++ src/gigs-board/entity/post/PostEditor.jsx | 7 +++++++ src/gigs-board/pages/Create.jsx | 1 + 3 files changed, 13 insertions(+) diff --git a/src/gigs-board/entity/post/Post.jsx b/src/gigs-board/entity/post/Post.jsx index 863bfcb83..3526a0b0a 100644 --- a/src/gigs-board/entity/post/Post.jsx +++ b/src/gigs-board/entity/post/Post.jsx @@ -474,6 +474,11 @@ const tokenMapping = { address: "usdt.tether-token.near", }, }, + USDC: { + NEP141: { + address: "usdc.tether-token.near", + }, + }, // Add more tokens here as needed }; diff --git a/src/gigs-board/entity/post/PostEditor.jsx b/src/gigs-board/entity/post/PostEditor.jsx index 21767589b..369b00411 100644 --- a/src/gigs-board/entity/post/PostEditor.jsx +++ b/src/gigs-board/entity/post/PostEditor.jsx @@ -144,6 +144,11 @@ const tokenMapping = { address: "usdt.tether-token.near", }, }, + USDC: { + NEP141: { + address: "usdc.tether-token.near", + }, + }, }; const onSubmit = () => { @@ -386,6 +391,7 @@ const tokenDiv = ( USDT +
    ); @@ -497,6 +503,7 @@ const fundraisingDiv = ( NEAR +
    diff --git a/src/gigs-board/pages/Create.jsx b/src/gigs-board/pages/Create.jsx index 5f2a92d6c..1abb64cb1 100644 --- a/src/gigs-board/pages/Create.jsx +++ b/src/gigs-board/pages/Create.jsx @@ -420,6 +420,7 @@ const fundraisingDiv = ( USDT +
    From 28b1d91c54d194353aa554fe05c66b8f4a492df3 Mon Sep 17 00:00:00 2001 From: Espen Simensen Date: Wed, 11 Oct 2023 18:44:03 +0200 Subject: [PATCH 48/81] fix: Fixed existing currency value not being set on edit (#263) --- src/gigs-board/entity/post/Post.jsx | 2 +- src/gigs-board/entity/post/PostEditor.jsx | 22 ++++++++++------------ src/gigs-board/pages/Create.jsx | 7 +++---- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/gigs-board/entity/post/Post.jsx b/src/gigs-board/entity/post/Post.jsx index 3526a0b0a..fc8cd7d46 100644 --- a/src/gigs-board/entity/post/Post.jsx +++ b/src/gigs-board/entity/post/Post.jsx @@ -569,7 +569,7 @@ function Editor() { name: post.snapshot.name, description: post.snapshot.description, amount: post.snapshot.amount, - token: post.snapshot.sponsorship_token, + token: tokenResolver(post.snapshot.sponsorship_token), supervisor: post.snapshot.supervisor, githubLink: post.snapshot.github_link, onDraftStateChange: props.onDraftStateChange, diff --git a/src/gigs-board/entity/post/PostEditor.jsx b/src/gigs-board/entity/post/PostEditor.jsx index 369b00411..27d6ea5e8 100644 --- a/src/gigs-board/entity/post/PostEditor.jsx +++ b/src/gigs-board/entity/post/PostEditor.jsx @@ -101,7 +101,7 @@ initState({ name: props.name ?? "", description: props.description ?? "", amount: props.amount ?? "0", - token: tokenMapping[props.token] ?? "USDT", + token: props.token ?? "USDT", supervisor: props.supervisor ?? "", githubLink: props.githubLink ?? "", warning: "", @@ -380,16 +380,15 @@ const amountDiv = ( ); const tokenDiv = ( -
    +
    Currency @@ -492,17 +491,16 @@ const isFundraisingDiv = ( const fundraisingDiv = (
    -
    +
    Currency
    diff --git a/src/gigs-board/pages/Create.jsx b/src/gigs-board/pages/Create.jsx index 1abb64cb1..90c4f56d4 100644 --- a/src/gigs-board/pages/Create.jsx +++ b/src/gigs-board/pages/Create.jsx @@ -414,11 +414,10 @@ const fundraisingDiv = ( From d5fe82a154eedba422cd58dce3c60039a6163570 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Thu, 12 Oct 2023 05:22:31 +0400 Subject: [PATCH 49/81] wip: Create new post compose page --- .../post/author_search.jsx} | 0 src/gigs-board/entity/post/editor.jsx | 80 ++++++- .../post/search_panel.jsx} | 4 +- src/gigs-board/entity/post/spawner.jsx | 37 ++-- .../by-tag.jsx => entity/post/tag_search.jsx} | 0 src/gigs-board/pages/Feed.jsx | 12 +- src/gigs-board/pages/new_post.jsx | 209 ++++++++++++++++++ 7 files changed, 315 insertions(+), 27 deletions(-) rename src/gigs-board/{feature/post-search/by-author.jsx => entity/post/author_search.jsx} (100%) rename src/gigs-board/{feature/post-search/panel.jsx => entity/post/search_panel.jsx} (99%) rename src/gigs-board/{feature/post-search/by-tag.jsx => entity/post/tag_search.jsx} (100%) create mode 100644 src/gigs-board/pages/new_post.jsx diff --git a/src/gigs-board/feature/post-search/by-author.jsx b/src/gigs-board/entity/post/author_search.jsx similarity index 100% rename from src/gigs-board/feature/post-search/by-author.jsx rename to src/gigs-board/entity/post/author_search.jsx diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index 78779dd49..0cc848b18 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -81,6 +81,43 @@ function autoCompleteAccountId(id) { })); } /* END_INCLUDE: "core/lib/autocomplete" */ +/* INCLUDE: "core/lib/draftstate" */ +const DRAFT_STATE_STORAGE_KEY = "POST_DRAFT_STATE"; +let is_edit_or_add_post_transaction = false; +let transaction_method_name; + +if (props.transactionHashes) { + const transaction = fetch("https://rpc.mainnet.near.org", { + method: "POST", + headers: { + "content-type": "application/json", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: "dontcare", + method: "tx", + params: [props.transactionHashes, context.accountId], + }), + }); + transaction_method_name = + transaction?.body?.result?.transaction?.actions[0].FunctionCall.method_name; + + is_edit_or_add_post_transaction = + transaction_method_name == "add_post" || + transaction_method_name == "edit_post"; + + if (is_edit_or_add_post_transaction) { + Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + } +} + +const onDraftStateChange = (draftState) => + Storage.privateSet(DRAFT_STATE_STORAGE_KEY, JSON.stringify(draftState)); +let draftState; +try { + draftState = JSON.parse(Storage.privateGet(DRAFT_STATE_STORAGE_KEY)); +} catch (e) {} +/* END_INCLUDE: "core/lib/draftstate" */ const normalizeTag = (tag) => tag @@ -163,14 +200,14 @@ const PostEditor = ({ fundraising: typeof amount === "string" && parseInt(amount) > 0, author_id: context.accountId, - /** - * A list of string tags. - */ tags: [ ...(tags ?? otherProps.labels ?? []), ...(typeof referral === "string" ? [`referral:${referral}`] : []), ], + /** + * Should always be updated along with `state.tags` + */ tagOptions: tags.map((tag) => ({ name: tag })), name: name ?? "", description: description ?? "", @@ -179,9 +216,42 @@ const PostEditor = ({ supervisor: requested_sponsor ?? supervisor ?? "", github_link: github_link ?? "", draftStateApplied: false, + waitForDraftStateRestore: true, warning: "", }); + if (state.waitForDraftStateRestore) { + const draftstatestring = Storage.privateGet(DRAFT_STATE_STORAGE_KEY); + + if (draftstatestring != null) { + if (props.transactionHashes) { + // TODO: Consider to remove this particular state update as it might be redundant + State.update((lastKnownState) => ({ + ...lastKnownState, + waitForDraftStateRestore: false, + })); + + Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + } else { + try { + State.update(JSON.parse(draftstatestring)); + } catch (error) { + console.error("error restoring draft", draftstatestring); + } + } + + State.update((lastKnownState) => ({ + ...lastKnownState, + waitForDraftStateRestore: false, + })); + } + } + + const onCancelClick = () => { + if (typeof onCancel === "function") onCancel(); + Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + }; + // This must be outside onClick, because Near.view returns null at first, // and when the view call finished, it returns true/false. // If checking this inside onClick, it will give `null` and we cannot tell the result is true or false. @@ -705,9 +775,9 @@ const PostEditor = ({ )} diff --git a/src/gigs-board/feature/post-search/panel.jsx b/src/gigs-board/entity/post/search_panel.jsx similarity index 99% rename from src/gigs-board/feature/post-search/panel.jsx rename to src/gigs-board/entity/post/search_panel.jsx index 5643b61fb..2fecb8864 100644 --- a/src/gigs-board/feature/post-search/panel.jsx +++ b/src/gigs-board/entity/post/search_panel.jsx @@ -736,13 +736,13 @@ return (
    - {widget("feature.post-search.by-tag", { + {widget("entity.post.tag_search", { tagQuery: props.tagQuery, onTagSearch: props.onTagSearch, })} diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/spawner.jsx index 9d93ffbc0..3d6200b7f 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/spawner.jsx @@ -126,24 +126,29 @@ const PostSpawner = ({ isHidden, onCancel, tags }) => { className={`flex-column gap-3 py-4 collapse ${ isHidden ? "" : "d-flex show" }`} - data-bs-parent={`#accordion${postId}`} id={`${state.post_type}_post_spawner`} > -
    - {Object.values(postTypeOptions).map((option) => ( - - ))} +
    +

    What do you want to create?

    + +
    + {Object.values(postTypeOptions).map((option) => ( + + ))} +

    diff --git a/src/gigs-board/feature/post-search/by-tag.jsx b/src/gigs-board/entity/post/tag_search.jsx similarity index 100% rename from src/gigs-board/feature/post-search/by-tag.jsx rename to src/gigs-board/entity/post/tag_search.jsx diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index ed51dc233..a9a35af91 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -235,13 +235,17 @@ const FeedPage = ({ author, recency, tag }) => { return widget("components.template.app-layout", { banner, - children: widget("feature.post-search.panel", { + children: widget("entity.post.search_panel", { author: state.author, authorQuery: { author: state.author }, - children: widget("components.layout.Controls", { - title: "Post", - href: href("Create"), + + children: widget("components.molecule.button", { + type: "link", + href: href("new_post"), + icon: { type: "bootstrap_icon", variant: "bi-plus-circle-fill" }, + label: "Post", }), + onAuthorSearch, onTagSearch, recency, diff --git a/src/gigs-board/pages/new_post.jsx b/src/gigs-board/pages/new_post.jsx new file mode 100644 index 000000000..f616236e6 --- /dev/null +++ b/src/gigs-board/pages/new_post.jsx @@ -0,0 +1,209 @@ +/* INCLUDE: "common.jsx" */ +const nearDevGovGigsContractAccountId = + props.nearDevGovGigsContractAccountId || + (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; + +const nearDevGovGigsWidgetsAccountId = + props.nearDevGovGigsWidgetsAccountId || + (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; + +function widget(widgetName, widgetProps, key) { + widgetProps = { + ...widgetProps, + nearDevGovGigsContractAccountId: props.nearDevGovGigsContractAccountId, + nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId, + referral: props.referral, + }; + + return ( + + ); +} + +function href(widgetName, linkProps) { + linkProps = { ...linkProps }; + + if (props.nearDevGovGigsContractAccountId) { + linkProps.nearDevGovGigsContractAccountId = + props.nearDevGovGigsContractAccountId; + } + + if (props.nearDevGovGigsWidgetsAccountId) { + linkProps.nearDevGovGigsWidgetsAccountId = + props.nearDevGovGigsWidgetsAccountId; + } + + if (props.referral) { + linkProps.referral = props.referral; + } + + const linkPropsQuery = Object.entries(linkProps) + .filter(([_key, nullable]) => (nullable ?? null) !== null) + .map(([key, value]) => `${key}=${value}`) + .join("&"); + + return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${ + linkPropsQuery ? "?" : "" + }${linkPropsQuery}`; +} +/* END_INCLUDE: "common.jsx" */ +/* INCLUDE: "core/lib/draftstate" */ +const DRAFT_STATE_STORAGE_KEY = "POST_DRAFT_STATE"; +let is_edit_or_add_post_transaction = false; +let transaction_method_name; + +if (props.transactionHashes) { + const transaction = fetch("https://rpc.mainnet.near.org", { + method: "POST", + headers: { + "content-type": "application/json", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: "dontcare", + method: "tx", + params: [props.transactionHashes, context.accountId], + }), + }); + transaction_method_name = + transaction?.body?.result?.transaction?.actions[0].FunctionCall.method_name; + + is_edit_or_add_post_transaction = + transaction_method_name == "add_post" || + transaction_method_name == "edit_post"; + + if (is_edit_or_add_post_transaction) { + Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + } +} + +const onDraftStateChange = (draftState) => + Storage.privateSet(DRAFT_STATE_STORAGE_KEY, JSON.stringify(draftState)); +let draftState; +try { + draftState = JSON.parse(Storage.privateGet(DRAFT_STATE_STORAGE_KEY)); +} catch (e) {} +/* END_INCLUDE: "core/lib/draftstate" */ + +const activeOptionStyle = { + backgroundColor: "#0C7283", + color: "#f3f3f3", +}; + +const postTypeOptions = { + Idea: { + name: "Idea", + icon: "bi-lightbulb", + + description: + "Get feedback from the community about a problem, opportunity, or need.", + }, + + Solution: { + name: "Solution", + icon: "bi-rocket", + + description: + "Provide a specific proposal or implementation to an idea, optionally requesting funding. If your solution relates to an existing idea, please reply to the original post with a solution.", + }, +}; + +const NewPostPage = ({ transactionHashes }) => { + State.init({ post_type: postTypeOptions.Idea.name }); + + const typeSwitch = (optionName) => + State.update((lastKnownState) => ({ + ...lastKnownState, + post_type: optionName, + })); + + return widget("components.template.app-layout", { + banner: ( +

    + +
    + ), + + children: ( +
    + {transactionHashes ? ( +

    + Post created successfully. + + + Back to feed + +

    + ) : ( + <> +
    +

    + What do you want to create? +

    + +
    + {Object.values(postTypeOptions).map((option) => ( + + ))} +
    +
    + +

    + {postTypeOptions[state.post_type].description} +

    + + {widget("entity.post.editor", { + mode: "Create", + onDraftStateChange, + parent_id: null, + post_type: state.post_type, + })} + + )} +
    + ), + }); +}; + +return NewPostPage(props); From c598797c80b7bd786a976e405f5839d5997ba209 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Thu, 12 Oct 2023 06:17:07 +0400 Subject: [PATCH 50/81] wip --- src/gigs-board/entity/post/CompactPost.jsx | 194 -------------------- src/gigs-board/entity/post/card.jsx | 5 +- src/gigs-board/entity/post/editor.jsx | 3 +- src/gigs-board/entity/post/search_panel.jsx | 4 +- src/gigs-board/entity/post/spawner.jsx | 8 +- src/gigs-board/pages/community/activity.jsx | 2 +- src/gigs-board/pages/new_post.jsx | 32 +--- 7 files changed, 15 insertions(+), 233 deletions(-) delete mode 100644 src/gigs-board/entity/post/CompactPost.jsx diff --git a/src/gigs-board/entity/post/CompactPost.jsx b/src/gigs-board/entity/post/CompactPost.jsx deleted file mode 100644 index 51449977a..000000000 --- a/src/gigs-board/entity/post/CompactPost.jsx +++ /dev/null @@ -1,194 +0,0 @@ -/* INCLUDE: "common.jsx" */ -const nearDevGovGigsContractAccountId = - props.nearDevGovGigsContractAccountId || - (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; - -const nearDevGovGigsWidgetsAccountId = - props.nearDevGovGigsWidgetsAccountId || - (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; - -function widget(widgetName, widgetProps, key) { - widgetProps = { - ...widgetProps, - nearDevGovGigsContractAccountId: props.nearDevGovGigsContractAccountId, - nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId, - referral: props.referral, - }; - - return ( - - ); -} - -function href(widgetName, linkProps) { - linkProps = { ...linkProps }; - - if (props.nearDevGovGigsContractAccountId) { - linkProps.nearDevGovGigsContractAccountId = - props.nearDevGovGigsContractAccountId; - } - - if (props.nearDevGovGigsWidgetsAccountId) { - linkProps.nearDevGovGigsWidgetsAccountId = - props.nearDevGovGigsWidgetsAccountId; - } - - if (props.referral) { - linkProps.referral = props.referral; - } - - const linkPropsQuery = Object.entries(linkProps) - .filter(([_key, nullable]) => (nullable ?? null) !== null) - .map(([key, value]) => `${key}=${value}`) - .join("&"); - - return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${ - linkPropsQuery ? "?" : "" - }${linkPropsQuery}`; -} -/* END_INCLUDE: "common.jsx" */ -/* INCLUDE: "core/lib/gui/attractable" */ -const AttractableDiv = styled.div` - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; - - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } -`; - -const AttractableLink = styled.a` - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; - - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } -`; - -const AttractableImage = styled.img` - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; - - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } -`; -/* END_INCLUDE: "core/lib/gui/attractable" */ - -const postId = props.post.id ?? (props.id ? parseInt(props.id) : 0); -const post = - props.post ?? - Near.view(nearDevGovGigsContractAccountId, "get_post", { post_id: postId }); -if (!post) { - return
    Loading ...
    ; -} -const snapshot = post.snapshot; - -const shareButton = ( - -
    -
    -); - -const header = ( -
    - -
    - -
    -
    {shareButton}
    -
    -
    -
    -
    -); - -const emptyIcons = { - Idea: "bi-lightbulb", - Comment: "bi-chat", - Solution: "bi-rocket", - Attestation: "bi-check-circle", - Sponsorship: "bi-cash-coin", -}; - -const borders = { - Idea: "border-secondary", - Comment: "border-secondary", - Solution: "border-secondary", - Attestation: "border-secondary", - Sponsorship: "border-secondary", -}; - -const postLables = post.snapshot.labels ? ( -
    - {post.snapshot.labels.map((label) => ( - - {label} - - ))} -
    -) : null; - -const postTitle = - snapshot.post_type == "Comment" ? null : ( -
    -
    -
    - - {snapshot.post_type}: {snapshot.name} -
    -
    -
    - ); - -const LimitedMarkdown = styled.div` - max-height: 6em; -`; - -// Should make sure the posts under the currently top viewed post are limited in size. -const descriptionArea = - snapshot.post_type == "Comment" ? ( - - {widget("components.molecule.markdown-viewer", { - text: snapshot.description, - })} - - ) : null; - -return ( - - {header} -
    - {postTitle} - {descriptionArea} - {postLables} -
    -
    -); diff --git a/src/gigs-board/entity/post/card.jsx b/src/gigs-board/entity/post/card.jsx index 5ddb07013..8f9e05451 100644 --- a/src/gigs-board/entity/post/card.jsx +++ b/src/gigs-board/entity/post/card.jsx @@ -242,7 +242,7 @@ const header = ( {editControl} {timestamp} - {widget("entity.post.History", { + {widget("entity.post.history", { post, timestamp: currentTimestamp, })} @@ -535,7 +535,6 @@ function Editor() { : undefined, mode: "Create", - onDraftStateChange: props.onDraftStateChange, parent_id: postId, post_type: state.post_type, } @@ -548,7 +547,6 @@ function Editor() { draftState?.edit_post_id === postId ? draftState : undefined, mode: "Edit", - onDraftStateChange: props.onDraftStateChange, post_type: state.post_type, sponsorship_token: tokenResolver( @@ -639,7 +637,6 @@ const postsList = { id: childId, isUnderPost: true, - onDraftStateChange: props.onDraftStateChange, draftState, expandParent: () => diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index 0cc848b18..da3b8217e 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -181,7 +181,6 @@ const PostEditor = ({ draftState, github_link, onCancel, - onDraftStateChange, parent_id, referral, requested_sponsor, @@ -208,7 +207,7 @@ const PostEditor = ({ /** * Should always be updated along with `state.tags` */ - tagOptions: tags.map((tag) => ({ name: tag })), + tagOptions: (tags ?? []).map((tag) => ({ name: tag })), name: name ?? "", description: description ?? "", amount: requested_sponsorship_amount ?? amount ?? "0", diff --git a/src/gigs-board/entity/post/search_panel.jsx b/src/gigs-board/entity/post/search_panel.jsx index 2fecb8864..25116e6ad 100644 --- a/src/gigs-board/entity/post/search_panel.jsx +++ b/src/gigs-board/entity/post/search_panel.jsx @@ -760,7 +760,7 @@ return (
    )} {state.term && state.term.length > 1 && state.searchResult - ? widget("entity.post.List", { + ? widget("entity.post.list", { searchResult: { postIds: state.searchResult, keywords: Object.fromEntries( @@ -773,7 +773,7 @@ return ( tag: props.tag, author: props.author, }) - : widget("entity.post.List", { + : widget("entity.post.list", { recency: props.recency, tag: props.tag, author: props.author, diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/spawner.jsx index 3d6200b7f..8caf99b48 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/spawner.jsx @@ -149,11 +149,11 @@ const PostSpawner = ({ isHidden, onCancel, tags }) => { ))}
    -
    -

    - {postTypeOptions[state.post_type].description} -

    +

    + {postTypeOptions[state.post_type].description} +

    +
    {widget("entity.post.editor", { mode: "Create", diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 76c00c8a6..78d8f3698 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -191,7 +191,7 @@ const CommunityActivityPage = ({ handle }) => { tags: [communityData.tag], })} - {widget("entity.post.List", { tag: communityData.tag })} + {widget("entity.post.list", { tag: communityData.tag })}
    diff --git a/src/gigs-board/pages/new_post.jsx b/src/gigs-board/pages/new_post.jsx index f616236e6..bd820208e 100644 --- a/src/gigs-board/pages/new_post.jsx +++ b/src/gigs-board/pages/new_post.jsx @@ -122,29 +122,9 @@ const NewPostPage = ({ transactionHashes }) => { })); return widget("components.template.app-layout", { - banner: ( -
    - -
    - ), - children: (
    @@ -162,7 +142,7 @@ const NewPostPage = ({ transactionHashes }) => {

    ) : ( <> -
    +

    What do you want to create?

    @@ -187,11 +167,11 @@ const NewPostPage = ({ transactionHashes }) => { ))}
    -
    -

    - {postTypeOptions[state.post_type].description} -

    +

    + {postTypeOptions[state.post_type].description} +

    +
    {widget("entity.post.editor", { mode: "Create", From 9836d0e146d66eabc4797fe5d448d145c661410c Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 13 Oct 2023 06:35:28 +0400 Subject: [PATCH 51/81] fix: Use SimpleMDE on testnet --- src/gigs-board/components/molecule/markdown-editor.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gigs-board/components/molecule/markdown-editor.jsx b/src/gigs-board/components/molecule/markdown-editor.jsx index 6c1bfb617..c1bd95e40 100644 --- a/src/gigs-board/components/molecule/markdown-editor.jsx +++ b/src/gigs-board/components/molecule/markdown-editor.jsx @@ -1,7 +1,11 @@ const MarkdownEditor = ({ data, onChange }) => { return ( Date: Fri, 13 Oct 2023 09:02:59 +0400 Subject: [PATCH 52/81] wip --- src/gigs-board/entity/post/editor.jsx | 87 ++++++++++++++++----- src/gigs-board/entity/post/spawner.jsx | 3 +- src/gigs-board/pages/community/activity.jsx | 3 +- src/gigs-board/pages/new_post.jsx | 6 +- 4 files changed, 75 insertions(+), 24 deletions(-) diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index da3b8217e..f85eb62d0 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -129,6 +129,17 @@ const normalizeTag = (tag) => .toLowerCase() .trim("-"); +function tokenResolver(token) { + if (typeof token === "string") { + return token; + } else if (typeof token === "object") { + const tokenString = reverseTokenMapping[JSON.stringify(token)]; + return tokenString || null; + } else { + return null; // Invalid input + } +} + const postSchemas = { Comment: ["description"], Idea: ["name", "description"], @@ -189,13 +200,14 @@ const PostEditor = ({ supervisor, tags, text, + transactionHashes, sponsorship_token, ...otherProps }) => { const mode = otherProps.mode ?? "Create", post_type = otherProps.post_type ?? "Idea"; - State.init({ + const initialState = { fundraising: typeof amount === "string" && parseInt(amount) > 0, author_id: context.accountId, @@ -217,23 +229,36 @@ const PostEditor = ({ draftStateApplied: false, waitForDraftStateRestore: true, warning: "", - }); + }; + + State.init(initialState); + + const stateReset = () => { + State.update({ ...initialState, waitForDraftStateRestore: false }); + Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + }; if (state.waitForDraftStateRestore) { const draftstatestring = Storage.privateGet(DRAFT_STATE_STORAGE_KEY); - if (draftstatestring != null) { - if (props.transactionHashes) { - // TODO: Consider to remove this particular state update as it might be redundant - State.update((lastKnownState) => ({ - ...lastKnownState, - waitForDraftStateRestore: false, - })); - - Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + if (draftstatestring !== null) { + if (transactionHashes) { + stateReset(); } else { try { - State.update(JSON.parse(draftstatestring)); + const recoveredDraft = JSON.parse(draftstatestring); + + State.update((lastKnownState) => ({ + ...lastKnownState, + ...recoveredDraft, + + ...{ + tags: (lastKnownState.tags.length > 0 + ? lastKnownState + : recoveredDraft + ).tags, + }, + })); } catch (error) { console.error("error restoring draft", draftstatestring); } @@ -248,7 +273,7 @@ const PostEditor = ({ const onCancelClick = () => { if (typeof onCancel === "function") onCancel(); - Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + stateReset(); }; // This must be outside onClick, because Near.view returns null at first, @@ -327,8 +352,8 @@ const PostEditor = ({ const transactions = []; - if (mode == "Create") { - onDraftStateChange?.({ ...state, parent_post_id: id }); + if (mode === "Create") { + onDraftStateChange?.({ ...state, parent_post_id: id ?? null }); transactions.push({ contractName: nearDevGovGigsContractAccountId, @@ -337,7 +362,7 @@ const PostEditor = ({ deposit: Big(10).pow(21).mul(2), gas: Big(10).pow(12).mul(100), }); - } else if (mode == "Edit") { + } else if (mode === "Edit") { onDraftStateChange?.({ ...state, edit_post_id: id }); transactions.push({ @@ -664,11 +689,19 @@ const PostEditor = ({ className="form-select" aria-label="Default select" > - - +
    ) : null} @@ -707,11 +740,23 @@ const PostEditor = ({ className="form-select" aria-label="Default select example" > - - +
    diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/spawner.jsx index 8caf99b48..6b181a9cb 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/spawner.jsx @@ -112,7 +112,7 @@ const postTypeOptions = { }, }; -const PostSpawner = ({ isHidden, onCancel, tags }) => { +const PostSpawner = ({ isHidden, onCancel, tags, transactionHashes }) => { State.init({ post_type: postTypeOptions.Idea.name }); const typeSwitch = (optionName) => @@ -162,6 +162,7 @@ const PostSpawner = ({ isHidden, onCancel, tags }) => { parent_id: null, post_type: state.post_type, tags, + transactionHashes, })}
    ); diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 78d8f3698..60c2c60e0 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -134,7 +134,7 @@ const DevHub = { }; /* END_INCLUDE: "core/adapter/dev-hub" */ -const CommunityActivityPage = ({ handle }) => { +const CommunityActivityPage = ({ handle, transactionHashes }) => { State.init({ isSpawnerHidden: true }); const spawnerToggle = (forcedState) => @@ -189,6 +189,7 @@ const CommunityActivityPage = ({ handle }) => { isHidden: state.isSpawnerHidden, onCancel: () => spawnerToggle(false), tags: [communityData.tag], + transactionHashes, })} {widget("entity.post.list", { tag: communityData.tag })} diff --git a/src/gigs-board/pages/new_post.jsx b/src/gigs-board/pages/new_post.jsx index bd820208e..3b8b95ea5 100644 --- a/src/gigs-board/pages/new_post.jsx +++ b/src/gigs-board/pages/new_post.jsx @@ -129,7 +129,10 @@ const NewPostPage = ({ transactionHashes }) => { id={`${state.post_type}_post_spawner`} > {transactionHashes ? ( -

    +

    Post created successfully. { onDraftStateChange, parent_id: null, post_type: state.post_type, + transactionHashes, })} )} From 66b87b2df2a3851b384c5a4f9cbb5c7aab828e3d Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 13 Oct 2023 09:52:18 +0400 Subject: [PATCH 53/81] wip: Prepare branch for release --- src/gigs-board/entity/post/editor.jsx | 4 +-- src/gigs-board/entity/post/spawner.jsx | 34 +++++++++++++++++++++++--- src/gigs-board/pages/new_post.jsx | 28 +++++++++++++++++++-- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index f85eb62d0..1e67ae132 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -234,8 +234,8 @@ const PostEditor = ({ State.init(initialState); const stateReset = () => { - State.update({ ...initialState, waitForDraftStateRestore: false }); Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); + State.update({ ...initialState, waitForDraftStateRestore: false }); }; if (state.waitForDraftStateRestore) { @@ -847,7 +847,7 @@ const PostEditor = ({ {widget("entity.post.card", { isPreview: true, - id: 0, // irrelevant + id: null, post: { author_id: state.author_id, diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/spawner.jsx index 6b181a9cb..f6262095c 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/spawner.jsx @@ -113,14 +113,42 @@ const postTypeOptions = { }; const PostSpawner = ({ isHidden, onCancel, tags, transactionHashes }) => { - State.init({ post_type: postTypeOptions.Idea.name }); + const recoveredPostType = Storage.privateGet("post_type"); - const typeSwitch = (optionName) => + const initialState = { + post_type: recoveredPostType ?? postTypeOptions.Idea.name, + }; + + State.init(initialState); + + const stateReset = () => { + Storage.privateSet("post_type", null); + State.update(initialState); + }; + + if (typeof transactionHashes === "string") stateReset(); + + if (recoveredPostType !== null) { + State.update((lastKnownState) => ({ + ...lastKnownState, + post_type: recoveredPostType, + })); + } + + const typeSwitch = (optionName) => { State.update((lastKnownState) => ({ ...lastKnownState, post_type: optionName, })); + Storage.privateSet("post_type", optionName); + }; + + const onCancelClick = () => { + if (typeof onCancel === "function") onCancel(); + stateReset(); + }; + return (

    { {widget("entity.post.editor", { mode: "Create", - onCancel, + onCancel: onCancelClick, onDraftStateChange, parent_id: null, post_type: state.post_type, diff --git a/src/gigs-board/pages/new_post.jsx b/src/gigs-board/pages/new_post.jsx index 3b8b95ea5..922ba9f11 100644 --- a/src/gigs-board/pages/new_post.jsx +++ b/src/gigs-board/pages/new_post.jsx @@ -113,14 +113,37 @@ const postTypeOptions = { }; const NewPostPage = ({ transactionHashes }) => { - State.init({ post_type: postTypeOptions.Idea.name }); + const recoveredPostType = Storage.privateGet("post_type"); - const typeSwitch = (optionName) => + const initialState = { + post_type: recoveredPostType ?? postTypeOptions.Idea.name, + }; + + State.init(initialState); + + const stateReset = () => { + Storage.privateSet("post_type", null); + State.update(initialState); + }; + + if (typeof transactionHashes === "string") stateReset(); + + if (recoveredPostType !== null) { + State.update((lastKnownState) => ({ + ...lastKnownState, + post_type: recoveredPostType, + })); + } + + const typeSwitch = (optionName) => { State.update((lastKnownState) => ({ ...lastKnownState, post_type: optionName, })); + Storage.privateSet("post_type", optionName); + }; + return widget("components.template.app-layout", { children: (
    { {widget("entity.post.editor", { mode: "Create", + onCancel: stateReset, onDraftStateChange, parent_id: null, post_type: state.post_type, From 2a8c22995b3113c4d7b15bec7aed4e2efc762d32 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 13 Oct 2023 10:35:20 +0400 Subject: [PATCH 54/81] wip: Prepare branch for release --- src/gigs-board/entity/post/editor.jsx | 10 +- src/gigs-board/entity/post/spawner.jsx | 1 - src/gigs-board/pages/Create.jsx | 628 ------------------------- src/gigs-board/pages/new_post.jsx | 34 +- 4 files changed, 26 insertions(+), 647 deletions(-) delete mode 100644 src/gigs-board/pages/Create.jsx diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/editor.jsx index 1e67ae132..c7d45ea92 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/editor.jsx @@ -187,6 +187,7 @@ const kycDisclaimer = ( const PostEditor = ({ id, amount, + className, name, description, draftState, @@ -239,7 +240,8 @@ const PostEditor = ({ }; if (state.waitForDraftStateRestore) { - const draftstatestring = Storage.privateGet(DRAFT_STATE_STORAGE_KEY); + const draftstatestring = + Storage.privateGet(DRAFT_STATE_STORAGE_KEY) ?? null; if (draftstatestring !== null) { if (transactionHashes) { @@ -353,7 +355,7 @@ const PostEditor = ({ const transactions = []; if (mode === "Create") { - onDraftStateChange?.({ ...state, parent_post_id: id ?? null }); + onDraftStateChange({ ...state, parent_post_id: id ?? null }); transactions.push({ contractName: nearDevGovGigsContractAccountId, @@ -363,7 +365,7 @@ const PostEditor = ({ gas: Big(10).pow(12).mul(100), }); } else if (mode === "Edit") { - onDraftStateChange?.({ ...state, edit_post_id: id }); + onDraftStateChange({ ...state, edit_post_id: id }); transactions.push({ contractName: nearDevGovGigsContractAccountId, @@ -601,7 +603,7 @@ const PostEditor = ({ ); return ( -
    +
    {`${mode} ${post_type}`}
    diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/spawner.jsx index f6262095c..2953d7f5b 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/spawner.jsx @@ -186,7 +186,6 @@ const PostSpawner = ({ isHidden, onCancel, tags, transactionHashes }) => { {widget("entity.post.editor", { mode: "Create", onCancel: onCancelClick, - onDraftStateChange, parent_id: null, post_type: state.post_type, tags, diff --git a/src/gigs-board/pages/Create.jsx b/src/gigs-board/pages/Create.jsx deleted file mode 100644 index 916a1ad29..000000000 --- a/src/gigs-board/pages/Create.jsx +++ /dev/null @@ -1,628 +0,0 @@ -/* INCLUDE: "common.jsx" */ -const nearDevGovGigsContractAccountId = - props.nearDevGovGigsContractAccountId || - (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; - -const nearDevGovGigsWidgetsAccountId = - props.nearDevGovGigsWidgetsAccountId || - (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; - -function widget(widgetName, widgetProps, key) { - widgetProps = { - ...widgetProps, - nearDevGovGigsContractAccountId: props.nearDevGovGigsContractAccountId, - nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId, - referral: props.referral, - }; - - return ( - - ); -} - -function href(widgetName, linkProps) { - linkProps = { ...linkProps }; - - if (props.nearDevGovGigsContractAccountId) { - linkProps.nearDevGovGigsContractAccountId = - props.nearDevGovGigsContractAccountId; - } - - if (props.nearDevGovGigsWidgetsAccountId) { - linkProps.nearDevGovGigsWidgetsAccountId = - props.nearDevGovGigsWidgetsAccountId; - } - - if (props.referral) { - linkProps.referral = props.referral; - } - - const linkPropsQuery = Object.entries(linkProps) - .filter(([_key, nullable]) => (nullable ?? null) !== null) - .map(([key, value]) => `${key}=${value}`) - .join("&"); - - return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${ - linkPropsQuery ? "?" : "" - }${linkPropsQuery}`; -} -/* END_INCLUDE: "common.jsx" */ -/* INCLUDE: "core/lib/autocomplete" */ -const autocompleteEnabled = true; - -const AutoComplete = styled.div` - z-index: 5; - - > div > div { - padding: calc(var(--padding) / 2); - } -`; - -function textareaInputHandler(value) { - const showAccountAutocomplete = /@[\w][^\s]*$/.test(value); - State.update((lastKnownState) => ({ - ...lastKnownState, - text: value, - showAccountAutocomplete, - })); -} - -function autoCompleteAccountId(id) { - let description = state.description.replace(/[\s]{0,1}@[^\s]*$/, ""); - description = `${description} @${id}`.trim() + " "; - State.update((lastKnownState) => ({ - ...lastKnownState, - description, - showAccountAutocomplete: false, - })); -} -/* END_INCLUDE: "core/lib/autocomplete" */ - -const DRAFT_STATE_STORAGE_KEY = "DRAFT_STATE"; -const parent_id = props.parent_id ?? null; -const postId = props.postId ?? null; -const mode = props.mode ?? "Create"; - -const referralLabels = props.referral ? [`referral:${props.referral}`] : []; -const labelStrings = (props.labels ? props.labels.split(",") : []).concat( - referralLabels -); -const labels = labelStrings.map((s) => { - return { name: s }; -}); - -initState({ - seekingFunding: false, - - author_id: context.accountId, - // Should be a list of objects with field "name". - labels, - // Should be a list of labels as strings. - // Both of the label structures should be modified together. - labelStrings, - post_type: "Idea", - name: props.name ?? "", - description: props.description ?? "", - amount: props.amount ?? "", - token: props.token ?? "USDT", - supervisor: props.supervisor ?? "neardevgov.near", - github_link: props.github_link ?? "", - warning: "", - waitForDraftStateRestore: true, -}); - -if (state.waitForDraftStateRestore) { - const draftstatestring = Storage.privateGet(DRAFT_STATE_STORAGE_KEY); - if (draftstatestring != null) { - if (props.transactionHashes) { - State.update({ waitForDraftStateRestore: false }); - Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); - } else { - try { - const draftstate = JSON.parse(draftstatestring); - State.update(draftstate); - } catch (e) { - console.error("error restoring draft", draftstatestring); - } - } - State.update({ waitForDraftStateRestore: false }); - } -} - -// This must be outside onClick, because Near.view returns null at first, and when the view call finished, it returns true/false. -// If checking this inside onClick, it will give `null` and we cannot tell the result is true or false. -let grantNotify = Near.view("social.near", "is_write_permission_granted", { - predecessor_id: nearDevGovGigsContractAccountId, - key: context.accountId + "/index/notify", -}); -if (grantNotify === null) { - return; -} - -const onSubmit = () => { - Storage.privateSet(DRAFT_STATE_STORAGE_KEY, JSON.stringify(state)); - - let labels = state.labelStrings; - - let body = { - name: state.name, - - description: generateDescription( - state.description, - state.amount, - state.token, - state.supervisor, - state.seekingFunding - ), - }; - - if (state.post_type === "Solution") { - body = { - ...body, - post_type: "Solution", - solution_version: "V2", - }; - } else { - body = { - ...body, - post_type: "Idea", - idea_version: "V1", - }; - } - - if (!context.accountId) return; - - let txn = []; - if (mode == "Create") { - txn.push({ - contractName: nearDevGovGigsContractAccountId, - methodName: "add_post", - args: { - parent_id, - labels, - body: body, - }, - deposit: Big(10).pow(21).mul(3), - gas: Big(10).pow(12).mul(100), - }); - } else if (mode == "Edit") { - txn.push({ - contractName: nearDevGovGigsContractAccountId, - methodName: "edit_post", - args: { - id: postId, - labels, - body: body, - }, - deposit: Big(10).pow(21).mul(2), - gas: Big(10).pow(12).mul(100), - }); - } - if (mode == "Create" || mode == "Edit") { - if (grantNotify === false) { - txn.unshift({ - contractName: "social.near", - methodName: "grant_write_permission", - args: { - predecessor_id: nearDevGovGigsContractAccountId, - keys: [context.accountId + "/index/notify"], - }, - deposit: Big(10).pow(23), - gas: Big(10).pow(12).mul(30), - }); - } - Near.call(txn); - } -}; - -const onIdeaClick = () => { - State.update({ post_type: "Idea", seekingFunding: false }); -}; - -const onSolutionClick = () => { - State.update({ post_type: "Solution" }); -}; - -const normalizeLabel = (label) => - label - .replaceAll(/[- \.]/g, "_") - .replaceAll(/[^\w]+/g, "") - .replaceAll(/_+/g, "-") - .replace(/^-+/, "") - .replace(/-+$/, "") - .toLowerCase() - .trim("-"); - -const checkLabel = (label) => { - Near.asyncView(nearDevGovGigsContractAccountId, "is_allowed_to_use_labels", { - editor: context.accountId, - labels: [label], - }).then((allowed) => { - if (allowed) { - State.update({ warning: "" }); - } else { - State.update({ - warning: - 'The label "' + - label + - '" is protected and can only be added by moderators', - }); - return; - } - }); -}; - -const setLabels = (labels) => { - labels = labels.map((o) => { - o.name = normalizeLabel(o.name); - return o; - }); - if (labels.length < state.labels.length) { - let oldLabels = new Set(state.labels.map((label) => label.name)); - for (let label of labels) { - oldLabels.delete(label.name); - } - let removed = oldLabels.values().next().value; - Near.asyncView( - nearDevGovGigsContractAccountId, - "is_allowed_to_use_labels", - { editor: context.accountId, labels: [removed] } - ).then((allowed) => { - if (allowed) { - let labelStrings = labels.map(({ name }) => name); - State.update({ labels, labelStrings }); - } else { - State.update({ - warning: - 'The label "' + - removed + - '" is protected and can only be updated by moderators', - }); - return; - } - }); - } else { - let labelStrings = labels.map((o) => { - return o.name; - }); - State.update({ labels, labelStrings }); - } -}; -const existingLabelStrings = - Near.view(nearDevGovGigsContractAccountId, "get_all_allowed_labels", { - editor: context.accountId, - }) ?? []; -const existingLabelSet = new Set(existingLabelStrings); -const existingLabels = existingLabelStrings.map((s) => { - return { name: s }; -}); - -const labelEditor = ( -
    -

    Labels

    - { - return ( - !existingLabelSet.has(props.text) && - props.selected.filter((selected) => selected.name === props.text) - .length == 0 && - Near.view( - nearDevGovGigsContractAccountId, - "is_allowed_to_use_labels", - { editor: context.accountId, labels: [props.text] } - ) - ); - }} - /> -
    -); - -const nameDiv = ( -
    -

    Title

    - State.update({ name: event.target.value })} - /> -
    -); - -const descriptionDiv = ( -
    -

    Description

    - {widget("components.molecule.markdown-editor", { - data: { handler: state.handler, content: state.description }, - onChange: (content) => { - State.update({ description: content, handler: "update" }); - textareaInputHandler(content); - }, - })} - {autocompleteEnabled && state.showAccountAutocomplete && ( - - State.update({ showAccountAutocomplete: false }), - }} - /> - - )} -
    -); - -const isFundraisingDiv = ( - // This is jank with just btns and not radios. But the radios were glitchy af - <> -
    -

    - Are you seeking funding for your solution? - (Optional) -

    -
    -
    -
    -
    -
    - -); - -const fundraisingDiv = ( -
    -
    - Currency - -
    -
    - Requested amount (Numbers Only) - 0 ? state.amount : ""} - min={0} - onChange={(event) => - State.update({ - amount: Number( - event.target.value.toString().replace(/e/g, "") - ).toString(), - }) - } - /> -
    -
    -

    - Requested sponsor (Optional) -

    -

    - If you are requesting funding from a specific sponsor, please enter - their username. -

    -
    - - @ - - State.update({ supervisor: event.target.value })} - /> -
    -
    -
    -); - -function generateDescription(text, amount, token, supervisor, seekingFunding) { - const fundingText = - amount > 0 && token ? `###### Requested amount: ${amount} ${token}\n` : ""; - const supervisorText = supervisor - ? `###### Requested sponsor: @${supervisor}\n` - : ""; - return seekingFunding ? `${fundingText}${supervisorText}${text}` : text; -} - -return ( -
    - {widget("components.organism.app-header")} -
    - - {props.transactionHashes ? ( - <> - Post created successfully. Back to{" "} - - feed - - - ) : ( - <> -

    Create a new post

    -

    {state.seekingFunding}

    -
    -
    -

    What do you want to create?

    -
    - - -
    -

    - {state.post_type === "Idea" - ? "Get feedback from the community about a problem, opportunity, or need." - : "Provide a specific proposal or implementation to an idea, optionally requesting funding. If your solution relates to an existing idea, please reply to the original post with a solution."} -

    - {state.warning && ( - - )} -
    - {nameDiv} - {descriptionDiv} - {labelEditor} - {state.post_type === "Solution" && isFundraisingDiv} - {state.seekingFunding && fundraisingDiv} -
    - -
    -
    -
    -

    Preview

    -
    - {widget("entity.post.card", { - isPreview: true, - id: 0, // irrelevant - post: { - author_id: state.author_id, - likes: [], - snapshot: { - editor_id: state.editor_id, - labels: state.labelStrings, - post_type: state.post_type, - name: state.name, - description: generateDescription( - state.description, - state.amount, - state.token, - state.supervisor, - state.seekingFunding - ), - github_link: state.github_link, - }, - }, - })} -
    -
    -
    - - )} -
    -
    -); diff --git a/src/gigs-board/pages/new_post.jsx b/src/gigs-board/pages/new_post.jsx index 922ba9f11..aa864ccbe 100644 --- a/src/gigs-board/pages/new_post.jsx +++ b/src/gigs-board/pages/new_post.jsx @@ -152,20 +152,27 @@ const NewPostPage = ({ transactionHashes }) => { id={`${state.post_type}_post_spawner`} > {transactionHashes ? ( -

    - Post created successfully. - - +

    - Back to feed - -

    + Post created successfully. + + + Back to feed + +

    + + {widget("entity.post.editor", { + className: "d-none", + transactionHashes, + })} + ) : ( <>
    @@ -202,7 +209,6 @@ const NewPostPage = ({ transactionHashes }) => { {widget("entity.post.editor", { mode: "Create", onCancel: stateReset, - onDraftStateChange, parent_id: null, post_type: state.post_type, transactionHashes, From 6ce0739408bc8ba9398bb05905cab41272a7ab76 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 13 Oct 2023 11:01:45 +0400 Subject: [PATCH 55/81] wip: Prepare branch for release --- src/gigs-board/entity/post/History.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gigs-board/entity/post/History.jsx b/src/gigs-board/entity/post/History.jsx index cdcaef9e4..294935ed7 100644 --- a/src/gigs-board/entity/post/History.jsx +++ b/src/gigs-board/entity/post/History.jsx @@ -68,7 +68,7 @@ const post = post_id: postId, }); if (!post || !post.snapshot_history) { - return
    ; + return
    ; } const referral = props.referral; @@ -91,20 +91,20 @@ snapshotHistory.push(snapshot); snapshotHistory.reverse(); const history = ( -
    + - + ); From 1f09cce44ca97995898819e7e37e8dac4958c774 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 13 Oct 2023 11:36:38 +0400 Subject: [PATCH 56/81] wip: Disable unimplemented feature --- .../workspace/view/kanban/configurator.jsx | 86 +++++++++---------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index b4612c23d..6ad391d8c 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -157,44 +157,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, - } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); + const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( + fieldInput + ) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, } - }; + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); + } + }; if ( !uninitialized && @@ -375,7 +375,7 @@ const KanbanPostBoardTagsSchema = { const KanbanPostBoardTicketFeaturesSchema = { author: { label: "Author" }, like_count: { label: "Likes" }, - reply_count: { label: "Replies" }, + reply_count: { label: "Replies", noop: true }, sponsorship_request_indicator: { label: "Sponsorship request indicator" }, requested_sponsorship_value: { label: "Amount of requested funds" }, requested_sponsor: { label: "Requested sponsor" }, @@ -492,12 +492,10 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = - (id) => - ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = (id) => ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); From 71d69df67e2d45f0a31884b9e55e14abc3c1c340 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 13 Oct 2023 18:29:48 +0400 Subject: [PATCH 57/81] chore: Format --- .../workspace/view/kanban/configurator.jsx | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx index 6ad391d8c..f6c6e6b78 100644 --- a/src/gigs-board/entity/workspace/view/kanban/configurator.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/configurator.jsx @@ -157,44 +157,44 @@ const useForm = ({ initialValues, onUpdate, stateKey, uninitialized }) => { hasUnsubmittedChanges: false, })); - const formUpdate = ({ path, via: customFieldUpdate, ...params }) => ( - fieldInput - ) => { - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - - { - input: fieldInput?.target?.value ?? fieldInput, - params, - path, - - via: - typeof customFieldUpdate === "function" - ? customFieldUpdate - : defaultFieldUpdate, + const formUpdate = + ({ path, via: customFieldUpdate, ...params }) => + (fieldInput) => { + const updatedValues = Struct.deepFieldUpdate( + formState?.values ?? {}, + + { + input: fieldInput?.target?.value ?? fieldInput, + params, + path, + + via: + typeof customFieldUpdate === "function" + ? customFieldUpdate + : defaultFieldUpdate, + } + ); + + State.update((lastKnownComponentState) => ({ + ...lastKnownComponentState, + + [stateKey]: { + hasUnsubmittedChanges: !Struct.isEqual( + updatedValues, + initialFormState.values + ), + + values: updatedValues, + }, + })); + + if ( + typeof onUpdate === "function" && + !Struct.isEqual(updatedValues, initialFormState.values) + ) { + onUpdate(updatedValues); } - ); - - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - - values: updatedValues, - }, - })); - - if ( - typeof onUpdate === "function" && - !Struct.isEqual(updatedValues, initialFormState.values) - ) { - onUpdate(updatedValues); - } - }; + }; if ( !uninitialized && @@ -492,10 +492,12 @@ const KanbanViewConfigurator = ({ communityHandle, link, permissions }) => { } : lastKnownValue; - const columnsDeleteById = (id) => ({ lastKnownValue }) => - Object.fromEntries( - Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) - ); + const columnsDeleteById = + (id) => + ({ lastKnownValue }) => + Object.fromEntries( + Object.entries(lastKnownValue).filter(([columnId]) => columnId !== id) + ); const onCancel = () => { form.reset(); From fa1d1aaee339bf07bdeeefc945b8f8a004f1307a Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 18 Oct 2023 12:28:11 +0400 Subject: [PATCH 58/81] chore: Format --- .../entity/post/{author_search.jsx => author-search.jsx} | 0 .../entity/post/{search_panel.jsx => search-panel.jsx} | 4 ++-- src/gigs-board/entity/post/{tag_search.jsx => tag-search.jsx} | 0 src/gigs-board/pages/Feed.jsx | 4 ++-- src/gigs-board/pages/{new_post.jsx => new-post.jsx} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/gigs-board/entity/post/{author_search.jsx => author-search.jsx} (100%) rename src/gigs-board/entity/post/{search_panel.jsx => search-panel.jsx} (99%) rename src/gigs-board/entity/post/{tag_search.jsx => tag-search.jsx} (100%) rename src/gigs-board/pages/{new_post.jsx => new-post.jsx} (100%) diff --git a/src/gigs-board/entity/post/author_search.jsx b/src/gigs-board/entity/post/author-search.jsx similarity index 100% rename from src/gigs-board/entity/post/author_search.jsx rename to src/gigs-board/entity/post/author-search.jsx diff --git a/src/gigs-board/entity/post/search_panel.jsx b/src/gigs-board/entity/post/search-panel.jsx similarity index 99% rename from src/gigs-board/entity/post/search_panel.jsx rename to src/gigs-board/entity/post/search-panel.jsx index 25116e6ad..da7d0a6f0 100644 --- a/src/gigs-board/entity/post/search_panel.jsx +++ b/src/gigs-board/entity/post/search-panel.jsx @@ -736,13 +736,13 @@ return (
    - {widget("entity.post.tag_search", { + {widget("entity.post.tag-search", { tagQuery: props.tagQuery, onTagSearch: props.onTagSearch, })} diff --git a/src/gigs-board/entity/post/tag_search.jsx b/src/gigs-board/entity/post/tag-search.jsx similarity index 100% rename from src/gigs-board/entity/post/tag_search.jsx rename to src/gigs-board/entity/post/tag-search.jsx diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index a9a35af91..f93edfeb4 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -235,13 +235,13 @@ const FeedPage = ({ author, recency, tag }) => { return widget("components.template.app-layout", { banner, - children: widget("entity.post.search_panel", { + children: widget("entity.post.search-panel", { author: state.author, authorQuery: { author: state.author }, children: widget("components.molecule.button", { type: "link", - href: href("new_post"), + href: href("new-post"), icon: { type: "bootstrap_icon", variant: "bi-plus-circle-fill" }, label: "Post", }), diff --git a/src/gigs-board/pages/new_post.jsx b/src/gigs-board/pages/new-post.jsx similarity index 100% rename from src/gigs-board/pages/new_post.jsx rename to src/gigs-board/pages/new-post.jsx From 73b20448332b96e6093ac9e2256b5586b0f519d1 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 18 Oct 2023 13:24:38 +0400 Subject: [PATCH 59/81] wip --- .../entity/post/{author-search.jsx => AuthorSearch.jsx} | 0 src/gigs-board/entity/post/{card.jsx => Card.jsx} | 4 ++-- src/gigs-board/entity/post/{editor.jsx => Editor.jsx} | 2 +- src/gigs-board/entity/post/List.jsx | 2 +- .../entity/post/{search-panel.jsx => SearchPanel.jsx} | 4 ++-- src/gigs-board/entity/post/{spawner.jsx => Spawner.jsx} | 2 +- src/gigs-board/entity/post/{tag-search.jsx => TagSearch.jsx} | 0 src/gigs-board/pages/Feed.jsx | 2 +- src/gigs-board/pages/Post.jsx | 2 +- src/gigs-board/pages/new-post.jsx | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) rename src/gigs-board/entity/post/{author-search.jsx => AuthorSearch.jsx} (100%) rename src/gigs-board/entity/post/{card.jsx => Card.jsx} (99%) rename src/gigs-board/entity/post/{editor.jsx => Editor.jsx} (99%) rename src/gigs-board/entity/post/{search-panel.jsx => SearchPanel.jsx} (99%) rename src/gigs-board/entity/post/{spawner.jsx => Spawner.jsx} (99%) rename src/gigs-board/entity/post/{tag-search.jsx => TagSearch.jsx} (100%) diff --git a/src/gigs-board/entity/post/author-search.jsx b/src/gigs-board/entity/post/AuthorSearch.jsx similarity index 100% rename from src/gigs-board/entity/post/author-search.jsx rename to src/gigs-board/entity/post/AuthorSearch.jsx diff --git a/src/gigs-board/entity/post/card.jsx b/src/gigs-board/entity/post/Card.jsx similarity index 99% rename from src/gigs-board/entity/post/card.jsx rename to src/gigs-board/entity/post/Card.jsx index 1e6b42691..0f8895d50 100644 --- a/src/gigs-board/entity/post/card.jsx +++ b/src/gigs-board/entity/post/Card.jsx @@ -530,7 +530,7 @@ function Editor() { key={`${state.post_type}${state.editorType}${postId}`} > {widget( - "entity.post.editor", + "entity.post.Editor", state.editorType === "CREATE" ? { @@ -638,7 +638,7 @@ const postsList = > {childPostIds.map((childId) => widget( - "entity.post.card", + "entity.post.Card", { id: childId, isUnderPost: true, diff --git a/src/gigs-board/entity/post/editor.jsx b/src/gigs-board/entity/post/Editor.jsx similarity index 99% rename from src/gigs-board/entity/post/editor.jsx rename to src/gigs-board/entity/post/Editor.jsx index 94c26481e..110f3eaf3 100644 --- a/src/gigs-board/entity/post/editor.jsx +++ b/src/gigs-board/entity/post/Editor.jsx @@ -870,7 +870,7 @@ const PostEditor = ({
    Preview: - {widget("entity.post.card", { + {widget("entity.post.Card", { isPreview: true, id: null, diff --git a/src/gigs-board/entity/post/List.jsx b/src/gigs-board/entity/post/List.jsx index 18af4bb00..52a4986d9 100644 --- a/src/gigs-board/entity/post/List.jsx +++ b/src/gigs-board/entity/post/List.jsx @@ -107,7 +107,7 @@ function defaultRenderItem(postId, additionalProps) { return (
    {widget( - `entity.post.card`, + `entity.post.Card`, { id: postId, expandable: true, diff --git a/src/gigs-board/entity/post/search-panel.jsx b/src/gigs-board/entity/post/SearchPanel.jsx similarity index 99% rename from src/gigs-board/entity/post/search-panel.jsx rename to src/gigs-board/entity/post/SearchPanel.jsx index da7d0a6f0..b1dbb4db8 100644 --- a/src/gigs-board/entity/post/search-panel.jsx +++ b/src/gigs-board/entity/post/SearchPanel.jsx @@ -736,13 +736,13 @@ return (
    - {widget("entity.post.tag-search", { + {widget("entity.post.TagSearch", { tagQuery: props.tagQuery, onTagSearch: props.onTagSearch, })} diff --git a/src/gigs-board/entity/post/spawner.jsx b/src/gigs-board/entity/post/Spawner.jsx similarity index 99% rename from src/gigs-board/entity/post/spawner.jsx rename to src/gigs-board/entity/post/Spawner.jsx index 2953d7f5b..7524369c3 100644 --- a/src/gigs-board/entity/post/spawner.jsx +++ b/src/gigs-board/entity/post/Spawner.jsx @@ -183,7 +183,7 @@ const PostSpawner = ({ isHidden, onCancel, tags, transactionHashes }) => {

    - {widget("entity.post.editor", { + {widget("entity.post.Editor", { mode: "Create", onCancel: onCancelClick, parent_id: null, diff --git a/src/gigs-board/entity/post/tag-search.jsx b/src/gigs-board/entity/post/TagSearch.jsx similarity index 100% rename from src/gigs-board/entity/post/tag-search.jsx rename to src/gigs-board/entity/post/TagSearch.jsx diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index f93edfeb4..0c5442589 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -235,7 +235,7 @@ const FeedPage = ({ author, recency, tag }) => { return widget("components.template.app-layout", { banner, - children: widget("entity.post.search-panel", { + children: widget("entity.post.SearchPanel", { author: state.author, authorQuery: { author: state.author }, diff --git a/src/gigs-board/pages/Post.jsx b/src/gigs-board/pages/Post.jsx index dab4ee1a1..b26a49b1f 100644 --- a/src/gigs-board/pages/Post.jsx +++ b/src/gigs-board/pages/Post.jsx @@ -108,7 +108,7 @@ if (is_edit_or_add_post_transaction) { ); } else { return widget("components.template.app-layout", { - children: widget("entity.post.card", { + children: widget("entity.post.Card", { id: props.id, timestamp: props.timestamp, compareTimestamp: props.compareTimestamp, diff --git a/src/gigs-board/pages/new-post.jsx b/src/gigs-board/pages/new-post.jsx index aa864ccbe..9130f85f0 100644 --- a/src/gigs-board/pages/new-post.jsx +++ b/src/gigs-board/pages/new-post.jsx @@ -168,7 +168,7 @@ const NewPostPage = ({ transactionHashes }) => {

    - {widget("entity.post.editor", { + {widget("entity.post.Editor", { className: "d-none", transactionHashes, })} @@ -206,7 +206,7 @@ const NewPostPage = ({ transactionHashes }) => {

    - {widget("entity.post.editor", { + {widget("entity.post.Editor", { mode: "Create", onCancel: stateReset, parent_id: null, From 45d80a184998302817e437c2743acca3de46df04 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 18 Oct 2023 13:27:23 +0400 Subject: [PATCH 60/81] wip --- src/gigs-board/entity/post/SearchPanel.jsx | 4 ++-- src/gigs-board/pages/community/activity.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gigs-board/entity/post/SearchPanel.jsx b/src/gigs-board/entity/post/SearchPanel.jsx index b1dbb4db8..513e206a6 100644 --- a/src/gigs-board/entity/post/SearchPanel.jsx +++ b/src/gigs-board/entity/post/SearchPanel.jsx @@ -760,7 +760,7 @@ return (
    )} {state.term && state.term.length > 1 && state.searchResult - ? widget("entity.post.list", { + ? widget("entity.posr.List", { searchResult: { postIds: state.searchResult, keywords: Object.fromEntries( @@ -773,7 +773,7 @@ return ( tag: props.tag, author: props.author, }) - : widget("entity.post.list", { + : widget("entity.posr.List", { recency: props.recency, tag: props.tag, author: props.author, diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 60c2c60e0..275ddec54 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -192,7 +192,7 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => { transactionHashes, })} - {widget("entity.post.list", { tag: communityData.tag })} + {widget("entity.posr.List", { tag: communityData.tag })}
    From f76d7b4e57e7dfa0ebe71bb39283c302ab22002d Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 18 Oct 2023 13:32:58 +0400 Subject: [PATCH 61/81] wip: Rollback post history component to main --- src/gigs-board/entity/post/History.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gigs-board/entity/post/History.jsx b/src/gigs-board/entity/post/History.jsx index 294935ed7..cdcaef9e4 100644 --- a/src/gigs-board/entity/post/History.jsx +++ b/src/gigs-board/entity/post/History.jsx @@ -68,7 +68,7 @@ const post = post_id: postId, }); if (!post || !post.snapshot_history) { - return
    ; + return
    ; } const referral = props.referral; @@ -91,20 +91,20 @@ snapshotHistory.push(snapshot); snapshotHistory.reverse(); const history = ( -
    + - + ); From 8c51f58abc28fc31c8fb9bb8f3450f800a711b3d Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 18 Oct 2023 13:35:09 +0400 Subject: [PATCH 62/81] wip: Fix typo --- src/gigs-board/entity/post/SearchPanel.jsx | 2 +- src/gigs-board/pages/community/activity.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gigs-board/entity/post/SearchPanel.jsx b/src/gigs-board/entity/post/SearchPanel.jsx index 588f81977..502dab997 100644 --- a/src/gigs-board/entity/post/SearchPanel.jsx +++ b/src/gigs-board/entity/post/SearchPanel.jsx @@ -185,7 +185,7 @@ return ( searchResult: state.searchResult, recency: props.recency, }) - : widget("entity.posr.List", { + : widget("entity.post.List", { recency: props.recency, transactionHashes: props.transactionHashes, })} diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 275ddec54..7e78c98eb 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -192,7 +192,7 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => { transactionHashes, })} - {widget("entity.posr.List", { tag: communityData.tag })} + {widget("entity.post.List", { tag: communityData.tag })}
    From 6a1792ff28cd8381609bf3ea205b9d030db065fc Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 18 Oct 2023 13:42:30 +0400 Subject: [PATCH 63/81] wip --- .../entity/workspace/view/kanban/post_ticket.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index 122d5bc02..3cc8e61ff 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -99,7 +99,7 @@ const KanbanPostTicket = ({ metadata }) => { post_type, name, description, - labels, + labels: tags, requested_sponsor, supervisor, requested_sponsorship_amount, @@ -217,11 +217,11 @@ const KanbanPostTicket = ({ metadata }) => { ) : null; const tagList = - Array.isArray(labels) && features.tags ? ( + Array.isArray(tags) && features.tags ? (
    - {labels.map((label) => ( - - {label} + {tags.map((tag) => ( + + {tag} ))}
    From 674c348a9d83c27e11b4ceac68fca335211f2490 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Fri, 20 Oct 2023 02:45:24 +0400 Subject: [PATCH 64/81] wip --- src/gigs-board/entity/post/Card.jsx | 12 +++++- src/gigs-board/entity/post/Editor.jsx | 54 +++++++++++++-------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/gigs-board/entity/post/Card.jsx b/src/gigs-board/entity/post/Card.jsx index 0f8895d50..dab7fa0d4 100644 --- a/src/gigs-board/entity/post/Card.jsx +++ b/src/gigs-board/entity/post/Card.jsx @@ -522,7 +522,13 @@ const isDraft = (draftState?.edit_post_id === postId && draftState?.post_type === state.post_type); -function Editor() { +const Editor = () => { + const onCancel = () => + State.update((lastKnownState) => ({ + ...lastKnownState, + showEditor: false, + })); + return (
    ); -} +}; const tags = (
    diff --git a/src/gigs-board/entity/post/Editor.jsx b/src/gigs-board/entity/post/Editor.jsx index 110f3eaf3..4f164f361 100644 --- a/src/gigs-board/entity/post/Editor.jsx +++ b/src/gigs-board/entity/post/Editor.jsx @@ -235,7 +235,7 @@ const PostEditor = ({ supervisor: requested_sponsor ?? supervisor ?? "", github_link: github_link ?? "", draftStateApplied: false, - waitForDraftStateRestore: true, + waitForDraftRecover: true, warning: "", }; @@ -243,40 +243,38 @@ const PostEditor = ({ const stateReset = () => { Storage.privateSet(DRAFT_STATE_STORAGE_KEY, undefined); - State.update({ ...initialState, waitForDraftStateRestore: false }); + State.update({ ...initialState, waitForDraftRecover: false }); }; - if (state.waitForDraftStateRestore) { - const draftstatestring = - Storage.privateGet(DRAFT_STATE_STORAGE_KEY) ?? null; + if (state.waitForDraftRecover) { + const recoveredDraft = JSON.parse( + Storage.privateGet(DRAFT_STATE_STORAGE_KEY) ?? null + ); + + const isDraft = + (recoveredDraft?.parent_post_id === id && + recoveredDraft?.post_type === post_type) || + (recoveredDraft?.edit_post_id === id && + recoveredDraft?.post_type === post_type); - if (draftstatestring !== null) { - if (transactionHashes) { + if (recoveredDraft !== null && isDraft) { + if (typeof transactionHashes === "string") { stateReset(); } else { - try { - const recoveredDraft = JSON.parse(draftstatestring); - - State.update((lastKnownState) => ({ - ...lastKnownState, - ...recoveredDraft, + State.update((lastKnownState) => ({ + ...lastKnownState, + ...recoveredDraft, + + ...{ + tags: (lastKnownState.tags.length > 0 + ? lastKnownState + : recoveredDraft + ).tags, + }, - ...{ - tags: (lastKnownState.tags.length > 0 - ? lastKnownState - : recoveredDraft - ).tags, - }, - })); - } catch (error) { - console.error("error restoring draft", draftstatestring); - } + waitForDraftRecover: false, + })); } - - State.update((lastKnownState) => ({ - ...lastKnownState, - waitForDraftStateRestore: false, - })); } } From 858d0b626540a481ba9bcebd97619d98def0b3a6 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Mon, 23 Oct 2023 21:18:01 +0400 Subject: [PATCH 65/81] wip: Detect if there's a relevant draft --- src/gigs-board/entity/post/Editor.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gigs-board/entity/post/Editor.jsx b/src/gigs-board/entity/post/Editor.jsx index 4f164f361..18ba8d230 100644 --- a/src/gigs-board/entity/post/Editor.jsx +++ b/src/gigs-board/entity/post/Editor.jsx @@ -251,13 +251,14 @@ const PostEditor = ({ Storage.privateGet(DRAFT_STATE_STORAGE_KEY) ?? null ); - const isDraft = - (recoveredDraft?.parent_post_id === id && + const isRelevantDraftDetected = + recoveredDraft !== null && + ((recoveredDraft?.parent_post_id === id && recoveredDraft?.post_type === post_type) || - (recoveredDraft?.edit_post_id === id && - recoveredDraft?.post_type === post_type); + (recoveredDraft?.edit_post_id === id && + recoveredDraft?.post_type === post_type)); - if (recoveredDraft !== null && isDraft) { + if (isRelevantDraftDetected) { if (typeof transactionHashes === "string") { stateReset(); } else { From a41017283d84e6e3246625703a0786ec6e7a29f3 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 04:49:18 +0400 Subject: [PATCH 66/81] chore: Format --- src/gigs-board/pages/Feed.jsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index a075a1a2a..575fcd6ba 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -192,14 +192,13 @@ const banner = (
    Featured Communities
    - {( - Near.view(devHubAccountId, "get_featured_communities") ?? [] - ).map((community) => - widget( - "entity.community.card", - { metadata: community, format: "medium" }, - community.handle - ) + {(Near.view(devHubAccountId, "get_featured_communities") ?? []).map( + (community) => + widget( + "entity.community.card", + { metadata: community, format: "medium" }, + community.handle + ) )}
    From 9bfd56569826fbb56d55504dff756bd982c96a92 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 05:13:09 +0400 Subject: [PATCH 67/81] fix: Use correct component ids --- src/gigs-board/pages/communities.jsx | 2 +- src/gigs-board/pages/community/activity.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gigs-board/pages/communities.jsx b/src/gigs-board/pages/communities.jsx index c78ead930..15b1f26d5 100644 --- a/src/gigs-board/pages/communities.jsx +++ b/src/gigs-board/pages/communities.jsx @@ -184,7 +184,7 @@ const CommunitiesPage = () => { ), })} - {widget("entity.community.spawner", { + {widget("entity.community.Spawner", { isHidden: state.isSpawnerHidden, onCancel: () => spawnerToggle(false), })} diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 7e78c98eb..c61d2b528 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -185,7 +185,7 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => {
    - {widget("entity.post.spawner", { + {widget("entity.post.Spawner", { isHidden: state.isSpawnerHidden, onCancel: () => spawnerToggle(false), tags: [communityData.tag], From 0e5a30528c3da302f683551d1656960a6545776c Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 05:31:41 +0400 Subject: [PATCH 68/81] fix: Display community activity via post lookup component --- .../entity/post/{SearchPanel.jsx => Lookup.jsx} | 0 src/gigs-board/pages/Feed.jsx | 17 +++++++++-------- src/gigs-board/pages/community/activity.jsx | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) rename src/gigs-board/entity/post/{SearchPanel.jsx => Lookup.jsx} (100%) diff --git a/src/gigs-board/entity/post/SearchPanel.jsx b/src/gigs-board/entity/post/Lookup.jsx similarity index 100% rename from src/gigs-board/entity/post/SearchPanel.jsx rename to src/gigs-board/entity/post/Lookup.jsx diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index 575fcd6ba..38cca1f55 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -192,13 +192,14 @@ const banner = (
    Featured Communities
    - {(Near.view(devHubAccountId, "get_featured_communities") ?? []).map( - (community) => - widget( - "entity.community.card", - { metadata: community, format: "medium" }, - community.handle - ) + {( + Near.view(devHubAccountId, "get_featured_communities") ?? [] + ).map((community) => + widget( + "entity.community.card", + { metadata: community, format: "medium" }, + community.handle + ) )}
    @@ -227,7 +228,7 @@ const FeedPage = ({ author, recency, tag }) => { return widget("components.template.app-layout", { banner, - children: widget("entity.post.SearchPanel", { + children: widget("entity.post.Lookup", { children: widget("components.layout.Controls", { title: "Post", href: href("new-post"), diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index c61d2b528..308100466 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -192,7 +192,7 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => { transactionHashes, })} - {widget("entity.post.List", { tag: communityData.tag })} + {widget("entity.post.Lookup", { tag: communityData.tag })}
    From 4a06cf85c6633141480818a2486a075513d02802 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 06:01:03 +0400 Subject: [PATCH 69/81] fix: Preserve default behavior for `npm run dev` --- package.json | 6 ++++-- scripts/dev.sh | 0 2 files changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 scripts/dev.sh diff --git a/package.json b/package.json index 2c06a1be3..f836d1bc0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "fmt": "prettier --write '**/*.{js,jsx,ts,tsx,json}'", "fmt:check": "prettier --check '**/*.{js,jsx,ts,tsx,json}'", "build": "npm run fmt && node ./module/include.js", - "dev": "sh ./scripts/dev.sh", + "dev:testnet": "./scripts/dev.sh", + "dev:mainnet": "./scripts/dev.sh -a devgovgigs.near -c devgovgigs.near -n mainnet", + "dev": "npm run dev:mainnet", "test": "npx playwright test" }, "repository": { @@ -24,4 +26,4 @@ "url": "https://github.com/near/neardevhub-widgets/issues" }, "homepage": "https://github.com/near/neardevhub-widgets#readme" -} +} \ No newline at end of file diff --git a/scripts/dev.sh b/scripts/dev.sh old mode 100644 new mode 100755 From 3c5364695f4eb2ad81a5800eca619acee56ba14e Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 06:07:00 +0400 Subject: [PATCH 70/81] chore: Format --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f836d1bc0..43b59f01e 100644 --- a/package.json +++ b/package.json @@ -26,4 +26,4 @@ "url": "https://github.com/near/neardevhub-widgets/issues" }, "homepage": "https://github.com/near/neardevhub-widgets#readme" -} \ No newline at end of file +} From 6a6cf5320d7d1f1db1a4339fd7587e29bc07684e Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 06:10:10 +0400 Subject: [PATCH 71/81] fix: Use correct component id --- src/gigs-board/entity/post/Card.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gigs-board/entity/post/Card.jsx b/src/gigs-board/entity/post/Card.jsx index dab7fa0d4..5046b39f7 100644 --- a/src/gigs-board/entity/post/Card.jsx +++ b/src/gigs-board/entity/post/Card.jsx @@ -242,7 +242,7 @@ const header = ( {editControl} {timestamp} - {widget("entity.post.history", { + {widget("entity.post.History", { post, timestamp: currentTimestamp, })} From 5fc7375ac35aea39cc7e5b9ff0a41b57437836e7 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 06:10:34 +0400 Subject: [PATCH 72/81] chore: Format --- src/gigs-board/pages/Feed.jsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index 38cca1f55..002501e7d 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -192,14 +192,13 @@ const banner = (
    Featured Communities
    - {( - Near.view(devHubAccountId, "get_featured_communities") ?? [] - ).map((community) => - widget( - "entity.community.card", - { metadata: community, format: "medium" }, - community.handle - ) + {(Near.view(devHubAccountId, "get_featured_communities") ?? []).map( + (community) => + widget( + "entity.community.card", + { metadata: community, format: "medium" }, + community.handle + ) )}
    From 3740e4704c4293167a7308ae316df990b4859e27 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 07:01:39 +0400 Subject: [PATCH 73/81] fix: Make community activity feed a little bit less broken --- src/gigs-board/entity/post/Lookup.jsx | 12 +++--- src/gigs-board/pages/community/activity.jsx | 42 ++++++++------------- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/gigs-board/entity/post/Lookup.jsx b/src/gigs-board/entity/post/Lookup.jsx index 13743d29a..f33fa7e64 100644 --- a/src/gigs-board/entity/post/Lookup.jsx +++ b/src/gigs-board/entity/post/Lookup.jsx @@ -81,6 +81,10 @@ function fetchGraphQL(operationsDoc, operationName, variables) { }); } +State.init({ + tag: props.tag, +}); + function search({ author, tag }) { State.update({ loading: true }); let where = {}; @@ -138,7 +142,7 @@ const buttonStyle = { return ( <> -
    +
    - {state.searchResult ? ( + {state.searchResult && !props.noReset ? (
    {state.searchResult ? widget("entity.post.List", { diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 308100466..2dbd11817 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -158,32 +158,6 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => { communityData !== null ? (
    -
    -
    -
    - - Required tags: - - {widget("components.atom.tag", { - tag: communityData.tag, - linkTo: "Feed", - })} - - - {widget("components.molecule.button", { - icon: { - type: "bootstrap_icon", - variant: "bi-plus-circle-fill", - }, - - isHidden: !state.isSpawnerHidden, - label: "Post", - onClick: () => spawnerToggle(true), - })} -
    -
    -
    -
    {widget("entity.post.Spawner", { isHidden: state.isSpawnerHidden, @@ -192,7 +166,21 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => { transactionHashes, })} - {widget("entity.post.Lookup", { tag: communityData.tag })} + {widget("entity.post.Lookup", { + noReset: true, + tag: communityData.tag, + + children: widget("components.molecule.button", { + icon: { + type: "bootstrap_icon", + variant: "bi-plus-circle-fill", + }, + + isHidden: !state.isSpawnerHidden, + label: "Post", + onClick: () => spawnerToggle(true), + }), + })}
    From 616f73e7f954268d7a6a3928152d836d10adf713 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 07:01:58 +0400 Subject: [PATCH 74/81] fix: Use correct component id --- src/gigs-board/pages/communities.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gigs-board/pages/communities.jsx b/src/gigs-board/pages/communities.jsx index 15b1f26d5..c78ead930 100644 --- a/src/gigs-board/pages/communities.jsx +++ b/src/gigs-board/pages/communities.jsx @@ -184,7 +184,7 @@ const CommunitiesPage = () => { ), })} - {widget("entity.community.Spawner", { + {widget("entity.community.spawner", { isHidden: state.isSpawnerHidden, onCancel: () => spawnerToggle(false), })} From 4d9bc68820f81581989ad827797bbb9213c8efcc Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 07:22:11 +0400 Subject: [PATCH 75/81] wip: Fix tags propagation --- src/gigs-board/entity/post/Card.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gigs-board/entity/post/Card.jsx b/src/gigs-board/entity/post/Card.jsx index 5046b39f7..93dc530bd 100644 --- a/src/gigs-board/entity/post/Card.jsx +++ b/src/gigs-board/entity/post/Card.jsx @@ -558,6 +558,8 @@ const Editor = () => { draftState: draftState?.edit_post_id === postId ? draftState : undefined, + tags: post.snapshot.labels ?? [], + mode: "Edit", onCancel, post_type: state.post_type, From 70bc8416bd7075f8d9c9169bc163fc14196f98ce Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Tue, 24 Oct 2023 09:53:41 +0400 Subject: [PATCH 76/81] fix: Reincarnate post draft recovery --- src/gigs-board/entity/post/Card.jsx | 7 +++---- src/gigs-board/entity/post/Editor.jsx | 28 ++++++++------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/gigs-board/entity/post/Card.jsx b/src/gigs-board/entity/post/Card.jsx index 93dc530bd..3898d093d 100644 --- a/src/gigs-board/entity/post/Card.jsx +++ b/src/gigs-board/entity/post/Card.jsx @@ -517,10 +517,9 @@ function tokenResolver(token) { } const isDraft = - (draftState?.parent_post_id === postId && - draftState?.post_type === state.post_type) || - (draftState?.edit_post_id === postId && - draftState?.post_type === state.post_type); + draftState?.post_type === state.post_type && + (draftState?.parent_post_id === postId || + draftState?.edit_post_id === postId); const Editor = () => { const onCancel = () => diff --git a/src/gigs-board/entity/post/Editor.jsx b/src/gigs-board/entity/post/Editor.jsx index 18ba8d230..6750fe529 100644 --- a/src/gigs-board/entity/post/Editor.jsx +++ b/src/gigs-board/entity/post/Editor.jsx @@ -197,7 +197,6 @@ const PostEditor = ({ className, name, description, - draftState, github_link, onCancel, parent_id, @@ -234,7 +233,6 @@ const PostEditor = ({ sponsorship_token: availableTokenParameters[sponsorship_token] ?? "USDT", supervisor: requested_sponsor ?? supervisor ?? "", github_link: github_link ?? "", - draftStateApplied: false, waitForDraftRecover: true, warning: "", }; @@ -247,16 +245,14 @@ const PostEditor = ({ }; if (state.waitForDraftRecover) { - const recoveredDraft = JSON.parse( - Storage.privateGet(DRAFT_STATE_STORAGE_KEY) ?? null - ); + const recoveredDraft = + otherProps.draftState ?? + JSON.parse(Storage.privateGet(DRAFT_STATE_STORAGE_KEY) ?? null); const isRelevantDraftDetected = - recoveredDraft !== null && - ((recoveredDraft?.parent_post_id === id && - recoveredDraft?.post_type === post_type) || - (recoveredDraft?.edit_post_id === id && - recoveredDraft?.post_type === post_type)); + recoveredDraft?.post_type === post_type && + (recoveredDraft?.parent_post_id === id || + recoveredDraft?.edit_post_id === id); if (isRelevantDraftDetected) { if (typeof transactionHashes === "string") { @@ -304,14 +300,6 @@ const PostEditor = ({ return

    Loading...

    ; } - if (!state.draftStateApplied && draftState) { - State.update((lastKnownState) => ({ - ...lastKnownState, - ...draftState, - draftStateApplied: true, - })); - } - const fields = postSchemas[post_type]; const onSubmit = () => { @@ -361,7 +349,7 @@ const PostEditor = ({ const transactions = []; if (mode === "Create") { - onDraftStateChange({ ...state, parent_post_id: id ?? null }); + onDraftStateChange({ ...state, parent_post_id: id ?? null, post_type }); transactions.push({ contractName: nearDevGovGigsContractAccountId, @@ -371,7 +359,7 @@ const PostEditor = ({ gas: Big(10).pow(12).mul(100), }); } else if (mode === "Edit") { - onDraftStateChange({ ...state, edit_post_id: id }); + onDraftStateChange({ ...state, edit_post_id: id, post_type }); transactions.push({ contractName: nearDevGovGigsContractAccountId, From eb6272af6316dea13be63dc7039e44615aa77ffb Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 1 Nov 2023 02:19:55 +0400 Subject: [PATCH 77/81] wip: Apply post-review amendments --- playwright-tests/create.spec.js | 2 +- src/gigs-board/entity/post/Card.jsx | 2 +- .../entity/post/{Editor.jsx => PostEditor.jsx} | 0 src/gigs-board/entity/post/Spawner.jsx | 2 +- .../pages/{new-post.jsx => Create.jsx} | 8 ++++---- src/gigs-board/pages/Feed.jsx | 17 +++++++++-------- 6 files changed, 16 insertions(+), 15 deletions(-) rename src/gigs-board/entity/post/{Editor.jsx => PostEditor.jsx} (100%) rename src/gigs-board/pages/{new-post.jsx => Create.jsx} (97%) diff --git a/playwright-tests/create.spec.js b/playwright-tests/create.spec.js index 8013a4717..600b5b4b5 100644 --- a/playwright-tests/create.spec.js +++ b/playwright-tests/create.spec.js @@ -4,7 +4,7 @@ import { setInputAndAssert, selectAndAssert } from "./testUtils"; test("should be able to submit a solution with USDC as currency", async ({ page, }) => { - await page.goto("/devgovgigs.near/widget/gigs-board.pages.new-post"); + await page.goto("/devgovgigs.near/widget/gigs-board.pages.Create"); await page.click('[data-testid="btn-solution"]'); await setInputAndAssert( diff --git a/src/gigs-board/entity/post/Card.jsx b/src/gigs-board/entity/post/Card.jsx index 43a327afe..64ab70c55 100644 --- a/src/gigs-board/entity/post/Card.jsx +++ b/src/gigs-board/entity/post/Card.jsx @@ -536,7 +536,7 @@ const Editor = () => { key={`${state.post_type}${state.editorType}${postId}`} > {widget( - "entity.post.Editor", + "entity.post.PostEditor", state.editorType === "CREATE" ? { diff --git a/src/gigs-board/entity/post/Editor.jsx b/src/gigs-board/entity/post/PostEditor.jsx similarity index 100% rename from src/gigs-board/entity/post/Editor.jsx rename to src/gigs-board/entity/post/PostEditor.jsx diff --git a/src/gigs-board/entity/post/Spawner.jsx b/src/gigs-board/entity/post/Spawner.jsx index 7524369c3..274301b75 100644 --- a/src/gigs-board/entity/post/Spawner.jsx +++ b/src/gigs-board/entity/post/Spawner.jsx @@ -183,7 +183,7 @@ const PostSpawner = ({ isHidden, onCancel, tags, transactionHashes }) => {

    - {widget("entity.post.Editor", { + {widget("entity.post.PostEditor", { mode: "Create", onCancel: onCancelClick, parent_id: null, diff --git a/src/gigs-board/pages/new-post.jsx b/src/gigs-board/pages/Create.jsx similarity index 97% rename from src/gigs-board/pages/new-post.jsx rename to src/gigs-board/pages/Create.jsx index 31123a5e2..07ba102a2 100644 --- a/src/gigs-board/pages/new-post.jsx +++ b/src/gigs-board/pages/Create.jsx @@ -112,7 +112,7 @@ const postTypeOptions = { }, }; -const NewPostPage = ({ transactionHashes }) => { +const CreatePage = ({ transactionHashes }) => { const recoveredPostType = Storage.privateGet("post_type"); const initialState = { @@ -168,7 +168,7 @@ const NewPostPage = ({ transactionHashes }) => {

    - {widget("entity.post.Editor", { + {widget("entity.post.PostEditor", { className: "d-none", transactionHashes, })} @@ -207,7 +207,7 @@ const NewPostPage = ({ transactionHashes }) => {

    - {widget("entity.post.Editor", { + {widget("entity.post.PostEditor", { mode: "Create", onCancel: stateReset, parent_id: null, @@ -221,4 +221,4 @@ const NewPostPage = ({ transactionHashes }) => { }); }; -return NewPostPage(props); +return CreatePage(props); diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index b6c387dfe..158bd84d8 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -192,13 +192,14 @@ const banner = (
    Featured Communities
    - {(Near.view(devHubAccountId, "get_featured_communities") ?? []).map( - (community) => - widget( - "entity.community.card", - { metadata: community, format: "medium" }, - community.handle - ) + {( + Near.view(devHubAccountId, "get_featured_communities") ?? [] + ).map((community) => + widget( + "entity.community.card", + { metadata: community, format: "medium" }, + community.handle + ) )}
    @@ -214,7 +215,7 @@ const FeedPage = ({ recency, tag }) => { children: widget("entity.post.Lookup", { children: widget("components.layout.Controls", { title: "Post", - href: href("new-post"), + href: href("Create"), }), recency, tag, From 087cd22ff4ca4f9661bb958301f5ff7abd887ae3 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 1 Nov 2023 02:34:31 +0400 Subject: [PATCH 78/81] chore: Format --- src/gigs-board/pages/Feed.jsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/gigs-board/pages/Feed.jsx b/src/gigs-board/pages/Feed.jsx index 158bd84d8..0ce7e9817 100644 --- a/src/gigs-board/pages/Feed.jsx +++ b/src/gigs-board/pages/Feed.jsx @@ -192,14 +192,13 @@ const banner = (
    Featured Communities
    - {( - Near.view(devHubAccountId, "get_featured_communities") ?? [] - ).map((community) => - widget( - "entity.community.card", - { metadata: community, format: "medium" }, - community.handle - ) + {(Near.view(devHubAccountId, "get_featured_communities") ?? []).map( + (community) => + widget( + "entity.community.card", + { metadata: community, format: "medium" }, + community.handle + ) )}
    From 7cefb1a2778752b528841934b9b36e164cbfe7d5 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 1 Nov 2023 05:14:16 +0400 Subject: [PATCH 79/81] fix: Rollback irrelevant changes --- src/gigs-board/pages/community/activity.jsx | 60 +++++++++++++-------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 2dbd11817..41e380e2a 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -158,29 +158,43 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => { communityData !== null ? (
    -
    - {widget("entity.post.Spawner", { - isHidden: state.isSpawnerHidden, - onCancel: () => spawnerToggle(false), - tags: [communityData.tag], - transactionHashes, - })} - - {widget("entity.post.Lookup", { - noReset: true, - tag: communityData.tag, - - children: widget("components.molecule.button", { - icon: { - type: "bootstrap_icon", - variant: "bi-plus-circle-fill", - }, - - isHidden: !state.isSpawnerHidden, - label: "Post", - onClick: () => spawnerToggle(true), - }), - })} +
    +
    +
    + + Required tags: + + {widget("components.atom.tag", { + linkTo: "Feed", + ...communityData, + })} + + + {widget("components.molecule.button", { + icon: { + type: "bootstrap_icon", + variant: "bi-plus-circle-fill", + }, + + isHidden: !state.isSpawnerHidden, + label: "Post", + onClick: () => spawnerToggle(true), + })} +
    +
    +
    + +
    +
    + {widget("entity.post.Spawner", { + isHidden: state.isSpawnerHidden, + onCancel: () => spawnerToggle(false), + tags: [communityData.tag], + transactionHashes, + })} + + {widget("entity.post.List", { tag: communityData.tag })} +
    From 0efa0b6dd397e78d3c074cf781a4f0ba081ca225 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Wed, 1 Nov 2023 21:15:52 +0400 Subject: [PATCH 80/81] Apply post-review amendments --- src/gigs-board/entity/post/Card.jsx | 12 +++++------- src/gigs-board/entity/post/PostEditor.jsx | 19 ++++++++++++++----- .../workspace/view/kanban/post_ticket.jsx | 7 ++++--- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/gigs-board/entity/post/Card.jsx b/src/gigs-board/entity/post/Card.jsx index 64ab70c55..f242bf4c4 100644 --- a/src/gigs-board/entity/post/Card.jsx +++ b/src/gigs-board/entity/post/Card.jsx @@ -117,6 +117,9 @@ const fundingAmount = parseInt( snapshot.requested_sponsorship_amount ?? snapshot.amount ); +const sponsorshipToken = + snapshot.requested_sponsorship_token ?? snapshot.sponsorship_token; + const compareSnapshot = compareTimestamp === post.snapshot.timestamp ? post.snapshot @@ -563,10 +566,7 @@ const Editor = () => { mode: "Edit", onCancel, post_type: state.post_type, - - sponsorship_token: tokenResolver( - post.snapshot.sponsorship_token - ), + sponsorship_token: tokenResolver(sponsorshipToken), } )}
    @@ -600,9 +600,7 @@ const postExtra = fundingAmount > 0 ? (
    - {`Maximum amount: ${fundingAmount} ${tokenResolver( - snapshot.sponsorship_token - )}`} + {`Maximum amount: ${fundingAmount} ${tokenResolver(sponsorshipToken)}`}
    diff --git a/src/gigs-board/entity/post/PostEditor.jsx b/src/gigs-board/entity/post/PostEditor.jsx index 9b226daa2..4eaa30c73 100644 --- a/src/gigs-board/entity/post/PostEditor.jsx +++ b/src/gigs-board/entity/post/PostEditor.jsx @@ -148,7 +148,7 @@ const postSchemas = { "name", "description", "requested_sponsorship_amount", - "sponsorship_token", + "requested_sponsorship_token", "requested_sponsor", ], @@ -203,12 +203,13 @@ const PostEditor = ({ referral, requested_sponsor, requested_sponsorship_amount, - selected, + requested_sponsorship_token, + sponsorship_token, supervisor, + selected, tags, text, transactionHashes, - sponsorship_token, ...otherProps }) => { const mode = otherProps.mode ?? "Create", @@ -230,7 +231,12 @@ const PostEditor = ({ name: name ?? "", description: description ?? "", amount: requested_sponsorship_amount ?? amount ?? "0", - sponsorship_token: availableTokenParameters[sponsorship_token] ?? "USDT", + + sponsorship_token: + availableTokenParameters[ + sponsorship_token ?? requested_sponsorship_token + ] ?? "USDT", + supervisor: requested_sponsor ?? supervisor ?? "neardevdao.near", github_link: github_link ?? "", waitForDraftRecover: true, @@ -317,7 +323,10 @@ const PostEditor = ({ description: state.description, requested_sponsor: state.supervisor, requested_sponsorship_amount: state.amount, - sponsorship_token: availableTokenParameters[state.sponsorship_token], + + requested_sponsorship_token: + availableTokenParameters[state.sponsorship_token], + solution_version: "V2", }, diff --git a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx index 3cc8e61ff..8121ab3e1 100644 --- a/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx +++ b/src/gigs-board/entity/workspace/view/kanban/post_ticket.jsx @@ -100,11 +100,12 @@ const KanbanPostTicket = ({ metadata }) => { name, description, labels: tags, - requested_sponsor, - supervisor, requested_sponsorship_amount, + requested_sponsorship_token, + requested_sponsor, amount, sponsorship_token, + supervisor, } = data.snapshot; const isFundingRequested = @@ -255,7 +256,7 @@ const KanbanPostTicket = ({ metadata }) => { {requested_sponsorship_amount ?? amount} - {sponsorship_token} + {requested_sponsorship_token ?? sponsorship_token} ) : null} From a5ee63cfd03a0c33b395ebbeeaa203ef1082f260 Mon Sep 17 00:00:00 2001 From: "Carina.Akaia.near" Date: Thu, 2 Nov 2023 02:51:06 +0400 Subject: [PATCH 81/81] fix: Delete redundant code --- src/gigs-board/pages/community/activity.jsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gigs-board/pages/community/activity.jsx b/src/gigs-board/pages/community/activity.jsx index 41e380e2a..e9b3940c9 100644 --- a/src/gigs-board/pages/community/activity.jsx +++ b/src/gigs-board/pages/community/activity.jsx @@ -145,10 +145,6 @@ const CommunityActivityPage = ({ handle, transactionHashes }) => { const communityData = DevHub.get_community({ handle }); - if (communityData === null) { - return
    Loading...
    ; - } - return widget("entity.community.layout", { path: [{ label: "Communities", pageId: "communities" }], title: "Activity",