connect workspace member's project roles to assigned

This commit is contained in:
rahulramesha 2023-12-07 19:37:47 +05:30
parent d1b41bfbd0
commit 2e7c16a9d8
7 changed files with 37 additions and 10 deletions

View File

@ -10,6 +10,7 @@ import { IIssue } from "types";
import { EIssueActions } from "../../types";
import { BaseKanBanRoot } from "../base-kanban-root";
import { EProjectStore } from "store/command-palette.store";
import { EUserWorkspaceRoles } from "constants/workspace";
export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
const router = useRouter();
@ -18,6 +19,7 @@ export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
const {
workspaceProfileIssues: profileIssuesStore,
workspaceProfileIssuesFilter: profileIssueFiltersStore,
workspaceMember: { currentWorkspaceUserProjectsRole },
issueKanBanView: issueKanBanViewStore,
} = 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 (
<BaseKanBanRoot
issueActions={issueActions}
@ -43,6 +51,7 @@ export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
showLoader={true}
QuickActions={ProjectIssueQuickActions}
currentStore={EProjectStore.PROFILE}
canEditPropertiesBasedOnProject={canEditPropertiesBasedOnProject}
/>
);
});

View File

@ -12,14 +12,18 @@ import { EIssueActions } from "../../types";
import { BaseListRoot } from "../base-list-root";
import { IProjectStore } from "store/project";
import { EProjectStore } from "store/command-palette.store";
import { EUserWorkspaceRoles } from "constants/workspace";
export const ProfileIssuesListLayout: FC = observer(() => {
const router = useRouter();
const { workspaceSlug, userId } = router.query as { workspaceSlug: string; userId: string };
// store
const { workspaceProfileIssuesFilter: profileIssueFiltersStore, workspaceProfileIssues: profileIssuesStore } =
useMobxStore();
const {
workspaceProfileIssuesFilter: profileIssueFiltersStore,
workspaceProfileIssues: profileIssuesStore,
workspaceMember: { currentWorkspaceUserProjectsRole },
} = useMobxStore();
const issueActions = {
[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 canEditPropertiesBasedOnProject = (projectId: string) => {
const currentProjectRole = currentWorkspaceUserProjectsRole && currentWorkspaceUserProjectsRole[projectId];
console.log(
projectId,
currentWorkspaceUserProjectsRole,
!!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER
);
return !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
};
return (
<BaseListRoot
issueFilterStore={profileIssueFiltersStore}
@ -44,6 +59,7 @@ export const ProfileIssuesListLayout: FC = observer(() => {
issueActions={issueActions}
getProjects={getProjects}
currentStore={EProjectStore.PROFILE}
canEditPropertiesBasedOnProject={canEditPropertiesBasedOnProject}
/>
);
});

View File

@ -16,6 +16,7 @@ import { IIssueUnGroupedStructure } from "store/issue";
import { EIssueActions } from "../types";
import { EFilterType, TUnGroupedIssues } from "store/issues/types";
import { EUserWorkspaceRoles } from "constants/workspace";
type Props = {
type?: TStaticViewTypes | null;
@ -35,6 +36,7 @@ export const AllIssueLayoutRoot: React.FC<Props> = observer((props) => {
globalViews: { fetchAllGlobalViews },
workspaceGlobalIssues: { loader, getIssues, getIssuesIds, fetchIssues, updateIssue, removeIssue },
workspaceGlobalIssuesFilter: { currentView, issueFilters, fetchFilters, updateFilters, setCurrentView },
workspaceMember: { currentWorkspaceUserProjectsRole },
} = useMobxStore();
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 isEditingAllowedBasedOnProject = false;
if (!projectId) return false;
return isEditingAllowedBasedOnProject;
const currentProjectRole = currentWorkspaceUserProjectsRole && currentWorkspaceUserProjectsRole[projectId];
return !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
};
const issuesResponse = getIssues;

View File

@ -27,11 +27,8 @@ export const ProfileIssuesPage = observer((props: IProfileIssuesPage) => {
const {
workspaceProfileIssues: { loader, getIssues, fetchIssues },
workspaceProfileIssuesFilter: { issueFilters, fetchFilters },
workspaceMember: { currentWorkspaceUserProjectsRole },
}: RootStore = useMobxStore();
console.log("currentWorkspaceUserProjectsRole", currentWorkspaceUserProjectsRole);
useSWR(
workspaceSlug && userId ? `CURRENT_WORKSPACE_PROFILE_ISSUES_${workspaceSlug}_${userId}_${type}` : null,
async () => {

View File

@ -233,8 +233,8 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
let _issues = { ...this.issues };
if (!_issues) _issues = {};
if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} };
_issues[userId][this.currentUserIssueTab][userId] = {
..._issues[userId][this.currentUserIssueTab][userId],
_issues[userId][this.currentUserIssueTab][issueId] = {
..._issues[userId][this.currentUserIssueTab][issueId],
...data,
};

View File

@ -56,6 +56,7 @@ export class WorkspaceMemberStore implements IWorkspaceMemberStore {
// observables
members: observable.ref,
memberInvitations: observable.ref,
workspaceUserProjectsRole: observable.ref,
// actions
fetchWorkspaceUserProjectsRole: action,
fetchWorkspaceMembers: action,

View File

@ -163,7 +163,7 @@ export interface IUserProfileProjectSegregation {
}
export interface IUserProjectsRole {
[project_id: string]: boolean;
[project_id: string]: number;
}
// export interface ICurrentUser {