mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Merge branch 'refactor/space-app' of github.com:makeplane/plane into refactor/space-app
This commit is contained in:
commit
d7ed0d2cd8
@ -21,7 +21,7 @@ type Props = {
|
||||
export const SidePeekView: React.FC<Props> = observer((props) => {
|
||||
const { anchor, handleClose, issueDetails } = props;
|
||||
// store hooks
|
||||
const { comments } = usePublish(anchor);
|
||||
const { canComment } = usePublish(anchor);
|
||||
|
||||
return (
|
||||
<div className="flex h-full w-full flex-col overflow-hidden">
|
||||
@ -41,7 +41,7 @@ export const SidePeekView: React.FC<Props> = observer((props) => {
|
||||
{/* divider */}
|
||||
<div className="my-5 h-[1] w-full border-t border-custom-border-200" />
|
||||
{/* issue activity/comments */}
|
||||
{comments && (
|
||||
{canComment && (
|
||||
<div className="w-full pb-5">
|
||||
<PeekOverviewIssueActivity anchor={anchor} issueDetails={issueDetails} />
|
||||
</div>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
6
space/types/publish.d.ts
vendored
6
space/types/publish.d.ts
vendored
@ -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;
|
||||
};
|
||||
|
@ -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<Props> = 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<Props> = 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<Props> = 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<Props> = 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<Props> = observer((props) => {
|
||||
<CustomPopover
|
||||
label={
|
||||
value.length > 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<Props> = observer((props) => {
|
||||
placeholder="Select views"
|
||||
>
|
||||
<>
|
||||
{viewOptions.map((option) => (
|
||||
{VIEW_OPTIONS.map((option) => (
|
||||
<div
|
||||
key={option.key}
|
||||
className={`relative m-1 flex cursor-pointer items-center justify-between gap-2 rounded-sm p-1 px-2 text-custom-text-200 ${
|
||||
@ -385,7 +384,7 @@ export const PublishProjectModal: React.FC<Props> = observer((props) => {
|
||||
<div className="text-sm">Allow comments</div>
|
||||
<Controller
|
||||
control={control}
|
||||
name="comments"
|
||||
name="is_comments_enabled"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<ToggleSwitch
|
||||
value={value}
|
||||
@ -402,7 +401,7 @@ export const PublishProjectModal: React.FC<Props> = observer((props) => {
|
||||
<div className="text-sm">Allow reactions</div>
|
||||
<Controller
|
||||
control={control}
|
||||
name="reactions"
|
||||
name="is_reactions_enabled"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<ToggleSwitch
|
||||
value={value}
|
||||
@ -419,7 +418,7 @@ export const PublishProjectModal: React.FC<Props> = observer((props) => {
|
||||
<div className="text-sm">Allow voting</div>
|
||||
<Controller
|
||||
control={control}
|
||||
name="votes"
|
||||
name="is_votes_enabled"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<ToggleSwitch
|
||||
value={value}
|
||||
|
@ -16,9 +16,9 @@ export interface IProjectPublishSettings {
|
||||
anchor?: string;
|
||||
id?: string;
|
||||
project?: string;
|
||||
comments: boolean;
|
||||
reactions: boolean;
|
||||
votes: boolean;
|
||||
is_comments_enabled: boolean;
|
||||
is_reactions_enabled: boolean;
|
||||
is_votes_enabled: boolean;
|
||||
view_props: TProjectPublishViewsSettings;
|
||||
inbox: string | null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user