diff --git a/space/components/issues/peek-overview/side-peek-view.tsx b/space/components/issues/peek-overview/side-peek-view.tsx index b464a065a..894441418 100644 --- a/space/components/issues/peek-overview/side-peek-view.tsx +++ b/space/components/issues/peek-overview/side-peek-view.tsx @@ -21,7 +21,7 @@ type Props = { export const SidePeekView: React.FC = observer((props) => { const { anchor, handleClose, issueDetails } = props; // store hooks - const { comments } = usePublish(anchor); + const { canComment } = usePublish(anchor); return (
@@ -41,7 +41,7 @@ export const SidePeekView: React.FC = observer((props) => { {/* divider */}
{/* issue activity/comments */} - {comments && ( + {canComment && (
diff --git a/space/store/publish/publish.store.ts b/space/store/publish/publish.store.ts index c90eb5bf9..5cad121db 100644 --- a/space/store/publish/publish.store.ts +++ b/space/store/publish/publish.store.ts @@ -18,7 +18,7 @@ export interface IPublishStore extends TPublishSettings { export class PublishStore implements IPublishStore { // observables anchor: string | undefined; - comments: boolean; + is_comments_enabled: boolean; created_at: string | undefined; created_by: string | undefined; entity_identifier: string | undefined; @@ -27,11 +27,11 @@ export class PublishStore implements IPublishStore { inbox: unknown; project: string | undefined; project_details: TProjectDetails | undefined; - reactions: boolean; + is_reactions_enabled: boolean; updated_at: string | undefined; updated_by: string | undefined; view_props: TViewDetails | undefined; - votes: boolean; + is_votes_enabled: boolean; workspace: string | undefined; workspace_detail: IWorkspaceLite | undefined; @@ -40,7 +40,7 @@ export class PublishStore implements IPublishStore { publishSettings: TPublishSettings ) { this.anchor = publishSettings.anchor; - this.comments = publishSettings.comments; + this.is_comments_enabled = publishSettings.is_comments_enabled; this.created_at = publishSettings.created_at; this.created_by = publishSettings.created_by; this.entity_identifier = publishSettings.entity_identifier; @@ -49,18 +49,18 @@ export class PublishStore implements IPublishStore { this.inbox = publishSettings.inbox; this.project = publishSettings.project; this.project_details = publishSettings.project_details; - this.reactions = publishSettings.reactions; + this.is_reactions_enabled = publishSettings.is_reactions_enabled; this.updated_at = publishSettings.updated_at; this.updated_by = publishSettings.updated_by; this.view_props = publishSettings.view_props; - this.votes = publishSettings.votes; + this.is_votes_enabled = publishSettings.is_votes_enabled; this.workspace = publishSettings.workspace; this.workspace_detail = publishSettings.workspace_detail; makeObservable(this, { // observables anchor: observable.ref, - comments: observable.ref, + is_comments_enabled: observable.ref, created_at: observable.ref, created_by: observable.ref, entity_identifier: observable.ref, @@ -69,11 +69,11 @@ export class PublishStore implements IPublishStore { inbox: observable, project: observable.ref, project_details: observable, - reactions: observable.ref, + is_reactions_enabled: observable.ref, updated_at: observable.ref, updated_by: observable.ref, view_props: observable, - votes: observable.ref, + is_votes_enabled: observable.ref, workspace: observable.ref, workspace_detail: observable, // computed @@ -95,20 +95,20 @@ export class PublishStore implements IPublishStore { * @description returns whether commenting is enabled or not */ get canComment() { - return !!this.comments; + return !!this.is_comments_enabled; } /** * @description returns whether reacting is enabled or not */ get canReact() { - return !!this.reactions; + return !!this.is_reactions_enabled; } /** * @description returns whether voting is enabled or not */ get canVote() { - return !!this.votes; + return !!this.is_votes_enabled; } } diff --git a/space/types/publish.d.ts b/space/types/publish.d.ts index 2dc3793f6..482cbafec 100644 --- a/space/types/publish.d.ts +++ b/space/types/publish.d.ts @@ -5,7 +5,7 @@ export type TPublishEntityType = "project"; export type TPublishSettings = { anchor: string | undefined; - comments: boolean; + is_comments_enabled: boolean; created_at: string | undefined; created_by: string | undefined; entity_identifier: string | undefined; @@ -14,11 +14,11 @@ export type TPublishSettings = { inbox: unknown; project: string | undefined; project_details: TProjectDetails | undefined; - reactions: boolean; + is_reactions_enabled: boolean; updated_at: string | undefined; updated_by: string | undefined; view_props: TViewDetails | undefined; - votes: boolean; + is_votes_enabled: boolean; workspace: string | undefined; workspace_detail: IWorkspaceLite | undefined; }; diff --git a/web/components/project/publish-project/modal.tsx b/web/components/project/publish-project/modal.tsx index 3469ca60a..1c547aa8d 100644 --- a/web/components/project/publish-project/modal.tsx +++ b/web/components/project/publish-project/modal.tsx @@ -27,9 +27,9 @@ type Props = { type FormData = { anchor: string; id: string | null; - comments: boolean; - reactions: boolean; - votes: boolean; + is_comments_enabled: boolean; + is_reactions_enabled: boolean; + is_votes_enabled: boolean; inbox: string | null; views: TProjectPublishViews[]; }; @@ -37,14 +37,14 @@ type FormData = { const defaultValues: FormData = { anchor: "", id: null, - comments: false, - reactions: false, - votes: false, + is_comments_enabled: false, + is_reactions_enabled: false, + is_votes_enabled: false, inbox: null, views: ["list", "kanban"], }; -const viewOptions: { +const VIEW_OPTIONS: { key: TProjectPublishViews; label: string; }[] = [ @@ -92,7 +92,7 @@ export const PublishProjectModal: React.FC = observer((props) => { // prefill form with the saved settings if the project is already published useEffect(() => { - if (!projectPublishSettings) return; + if (!projectPublishSettings?.anchor) return; let userBoards: TProjectPublishViews[] = []; @@ -112,9 +112,9 @@ export const PublishProjectModal: React.FC = observer((props) => { const updatedData = { id: projectPublishSettings?.id || null, - comments: projectPublishSettings?.comments || false, - reactions: projectPublishSettings?.reactions || false, - votes: projectPublishSettings?.votes || false, + is_comments_enabled: !!projectPublishSettings?.is_comments_enabled, + is_reactions_enabled: !!projectPublishSettings?.is_reactions_enabled, + is_votes_enabled: !!projectPublishSettings?.is_votes_enabled, inbox: projectPublishSettings?.inbox || null, views: userBoards, }; @@ -205,9 +205,9 @@ export const PublishProjectModal: React.FC = observer((props) => { } const payload = { - comments: formData.comments, - reactions: formData.reactions, - votes: formData.votes, + is_comments_enabled: formData.is_comments_enabled, + is_reactions_enabled: formData.is_reactions_enabled, + is_votes_enabled: formData.is_votes_enabled, inbox: formData.inbox, view_props: { list: formData.views.includes("list"), @@ -235,16 +235,16 @@ export const PublishProjectModal: React.FC = observer((props) => { const newSettings = getValues(); if ( - currentSettings.comments !== newSettings.comments || - currentSettings.reactions !== newSettings.reactions || - currentSettings.votes !== newSettings.votes + currentSettings.is_comments_enabled !== newSettings.is_comments_enabled || + currentSettings.is_reactions_enabled !== newSettings.is_reactions_enabled || + currentSettings.is_votes_enabled !== newSettings.is_votes_enabled ) { setIsUpdateRequired(true); return; } let viewCheckFlag = 0; - viewOptions.forEach((option) => { + VIEW_OPTIONS.forEach((option) => { if (currentSettings.view_props?.[option.key] !== newSettings.views.includes(option.key)) viewCheckFlag++; }); @@ -337,8 +337,7 @@ export const PublishProjectModal: React.FC = observer((props) => { 0 - ? viewOptions - .filter((v) => value.includes(v.key)) + ? VIEW_OPTIONS.filter((v) => value.includes(v.key)) .map((v) => v.label) .join(", ") : `` @@ -346,7 +345,7 @@ export const PublishProjectModal: React.FC = observer((props) => { placeholder="Select views" > <> - {viewOptions.map((option) => ( + {VIEW_OPTIONS.map((option) => (
= observer((props) => {
Allow comments
( = observer((props) => {
Allow reactions
( = observer((props) => {
Allow voting
(