forked from github/plane
connect workspace member's project roles to assigned
This commit is contained in:
parent
d1b41bfbd0
commit
2e7c16a9d8
@ -10,6 +10,7 @@ import { IIssue } from "types";
|
|||||||
import { EIssueActions } from "../../types";
|
import { EIssueActions } from "../../types";
|
||||||
import { BaseKanBanRoot } from "../base-kanban-root";
|
import { BaseKanBanRoot } from "../base-kanban-root";
|
||||||
import { EProjectStore } from "store/command-palette.store";
|
import { EProjectStore } from "store/command-palette.store";
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
|
export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -18,6 +19,7 @@ export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
|
|||||||
const {
|
const {
|
||||||
workspaceProfileIssues: profileIssuesStore,
|
workspaceProfileIssues: profileIssuesStore,
|
||||||
workspaceProfileIssuesFilter: profileIssueFiltersStore,
|
workspaceProfileIssuesFilter: profileIssueFiltersStore,
|
||||||
|
workspaceMember: { currentWorkspaceUserProjectsRole },
|
||||||
issueKanBanView: issueKanBanViewStore,
|
issueKanBanView: issueKanBanViewStore,
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
@ -34,6 +36,12 @@ export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const canEditPropertiesBasedOnProject = (projectId: string) => {
|
||||||
|
const currentProjectRole = currentWorkspaceUserProjectsRole && currentWorkspaceUserProjectsRole[projectId];
|
||||||
|
|
||||||
|
return !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseKanBanRoot
|
<BaseKanBanRoot
|
||||||
issueActions={issueActions}
|
issueActions={issueActions}
|
||||||
@ -43,6 +51,7 @@ export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
|
|||||||
showLoader={true}
|
showLoader={true}
|
||||||
QuickActions={ProjectIssueQuickActions}
|
QuickActions={ProjectIssueQuickActions}
|
||||||
currentStore={EProjectStore.PROFILE}
|
currentStore={EProjectStore.PROFILE}
|
||||||
|
canEditPropertiesBasedOnProject={canEditPropertiesBasedOnProject}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -12,14 +12,18 @@ import { EIssueActions } from "../../types";
|
|||||||
import { BaseListRoot } from "../base-list-root";
|
import { BaseListRoot } from "../base-list-root";
|
||||||
import { IProjectStore } from "store/project";
|
import { IProjectStore } from "store/project";
|
||||||
import { EProjectStore } from "store/command-palette.store";
|
import { EProjectStore } from "store/command-palette.store";
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
export const ProfileIssuesListLayout: FC = observer(() => {
|
export const ProfileIssuesListLayout: FC = observer(() => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, userId } = router.query as { workspaceSlug: string; userId: string };
|
const { workspaceSlug, userId } = router.query as { workspaceSlug: string; userId: string };
|
||||||
|
|
||||||
// store
|
// store
|
||||||
const { workspaceProfileIssuesFilter: profileIssueFiltersStore, workspaceProfileIssues: profileIssuesStore } =
|
const {
|
||||||
useMobxStore();
|
workspaceProfileIssuesFilter: profileIssueFiltersStore,
|
||||||
|
workspaceProfileIssues: profileIssuesStore,
|
||||||
|
workspaceMember: { currentWorkspaceUserProjectsRole },
|
||||||
|
} = useMobxStore();
|
||||||
|
|
||||||
const issueActions = {
|
const issueActions = {
|
||||||
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
||||||
@ -36,6 +40,17 @@ export const ProfileIssuesListLayout: FC = observer(() => {
|
|||||||
|
|
||||||
const getProjects = (projectStore: IProjectStore) => projectStore.workspaceProjects;
|
const getProjects = (projectStore: IProjectStore) => projectStore.workspaceProjects;
|
||||||
|
|
||||||
|
const canEditPropertiesBasedOnProject = (projectId: string) => {
|
||||||
|
const currentProjectRole = currentWorkspaceUserProjectsRole && currentWorkspaceUserProjectsRole[projectId];
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
projectId,
|
||||||
|
currentWorkspaceUserProjectsRole,
|
||||||
|
!!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER
|
||||||
|
);
|
||||||
|
return !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseListRoot
|
<BaseListRoot
|
||||||
issueFilterStore={profileIssueFiltersStore}
|
issueFilterStore={profileIssueFiltersStore}
|
||||||
@ -44,6 +59,7 @@ export const ProfileIssuesListLayout: FC = observer(() => {
|
|||||||
issueActions={issueActions}
|
issueActions={issueActions}
|
||||||
getProjects={getProjects}
|
getProjects={getProjects}
|
||||||
currentStore={EProjectStore.PROFILE}
|
currentStore={EProjectStore.PROFILE}
|
||||||
|
canEditPropertiesBasedOnProject={canEditPropertiesBasedOnProject}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,7 @@ import { IIssueUnGroupedStructure } from "store/issue";
|
|||||||
import { EIssueActions } from "../types";
|
import { EIssueActions } from "../types";
|
||||||
|
|
||||||
import { EFilterType, TUnGroupedIssues } from "store/issues/types";
|
import { EFilterType, TUnGroupedIssues } from "store/issues/types";
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
type?: TStaticViewTypes | null;
|
type?: TStaticViewTypes | null;
|
||||||
@ -35,6 +36,7 @@ export const AllIssueLayoutRoot: React.FC<Props> = observer((props) => {
|
|||||||
globalViews: { fetchAllGlobalViews },
|
globalViews: { fetchAllGlobalViews },
|
||||||
workspaceGlobalIssues: { loader, getIssues, getIssuesIds, fetchIssues, updateIssue, removeIssue },
|
workspaceGlobalIssues: { loader, getIssues, getIssuesIds, fetchIssues, updateIssue, removeIssue },
|
||||||
workspaceGlobalIssuesFilter: { currentView, issueFilters, fetchFilters, updateFilters, setCurrentView },
|
workspaceGlobalIssuesFilter: { currentView, issueFilters, fetchFilters, updateFilters, setCurrentView },
|
||||||
|
workspaceMember: { currentWorkspaceUserProjectsRole },
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
useSWR(workspaceSlug ? `WORKSPACE_GLOBAL_VIEWS${workspaceSlug}` : null, async () => {
|
useSWR(workspaceSlug ? `WORKSPACE_GLOBAL_VIEWS${workspaceSlug}` : null, async () => {
|
||||||
@ -56,9 +58,11 @@ export const AllIssueLayoutRoot: React.FC<Props> = observer((props) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const canEditProperties = (projectId: string | undefined) => {
|
const canEditProperties = (projectId: string | undefined) => {
|
||||||
const isEditingAllowedBasedOnProject = false;
|
if (!projectId) return false;
|
||||||
|
|
||||||
return isEditingAllowedBasedOnProject;
|
const currentProjectRole = currentWorkspaceUserProjectsRole && currentWorkspaceUserProjectsRole[projectId];
|
||||||
|
|
||||||
|
return !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
};
|
};
|
||||||
|
|
||||||
const issuesResponse = getIssues;
|
const issuesResponse = getIssues;
|
||||||
|
@ -27,11 +27,8 @@ export const ProfileIssuesPage = observer((props: IProfileIssuesPage) => {
|
|||||||
const {
|
const {
|
||||||
workspaceProfileIssues: { loader, getIssues, fetchIssues },
|
workspaceProfileIssues: { loader, getIssues, fetchIssues },
|
||||||
workspaceProfileIssuesFilter: { issueFilters, fetchFilters },
|
workspaceProfileIssuesFilter: { issueFilters, fetchFilters },
|
||||||
workspaceMember: { currentWorkspaceUserProjectsRole },
|
|
||||||
}: RootStore = useMobxStore();
|
}: RootStore = useMobxStore();
|
||||||
|
|
||||||
console.log("currentWorkspaceUserProjectsRole", currentWorkspaceUserProjectsRole);
|
|
||||||
|
|
||||||
useSWR(
|
useSWR(
|
||||||
workspaceSlug && userId ? `CURRENT_WORKSPACE_PROFILE_ISSUES_${workspaceSlug}_${userId}_${type}` : null,
|
workspaceSlug && userId ? `CURRENT_WORKSPACE_PROFILE_ISSUES_${workspaceSlug}_${userId}_${type}` : null,
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -233,8 +233,8 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
|
|||||||
let _issues = { ...this.issues };
|
let _issues = { ...this.issues };
|
||||||
if (!_issues) _issues = {};
|
if (!_issues) _issues = {};
|
||||||
if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} };
|
if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} };
|
||||||
_issues[userId][this.currentUserIssueTab][userId] = {
|
_issues[userId][this.currentUserIssueTab][issueId] = {
|
||||||
..._issues[userId][this.currentUserIssueTab][userId],
|
..._issues[userId][this.currentUserIssueTab][issueId],
|
||||||
...data,
|
...data,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
|
|||||||
// observables
|
// observables
|
||||||
members: observable.ref,
|
members: observable.ref,
|
||||||
memberInvitations: observable.ref,
|
memberInvitations: observable.ref,
|
||||||
|
workspaceUserProjectsRole: observable.ref,
|
||||||
// actions
|
// actions
|
||||||
fetchWorkspaceUserProjectsRole: action,
|
fetchWorkspaceUserProjectsRole: action,
|
||||||
fetchWorkspaceMembers: action,
|
fetchWorkspaceMembers: action,
|
||||||
|
2
web/types/users.d.ts
vendored
2
web/types/users.d.ts
vendored
@ -163,7 +163,7 @@ export interface IUserProfileProjectSegregation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IUserProjectsRole {
|
export interface IUserProjectsRole {
|
||||||
[project_id: string]: boolean;
|
[project_id: string]: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// export interface ICurrentUser {
|
// export interface ICurrentUser {
|
||||||
|
Loading…
Reference in New Issue
Block a user