From a6567bbce42a79c1cd62d7e21c5d4936f0911dd8 Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Thu, 9 Nov 2023 00:35:12 +0530 Subject: [PATCH] fix: workspace members store added and implemented across the app (#2732) * fix: minor changes * fix: workspace members store added and implemnted across the app --- web/components/headers/global-issues.tsx | 3 +- .../roots/global-view-root.tsx | 3 +- .../issue-layouts/properties/assignee.tsx | 20 +- .../roots/global-view-layout-root.tsx | 3 +- .../roots/project-layout-root.tsx | 13 +- .../issue-peek-overview/activity/card.tsx | 2 +- .../project/create-project-modal.tsx | 8 +- .../project/settings/features-list.tsx | 9 +- .../confirm-workspace-member-remove.tsx | 9 +- .../send-workspace-invitation-modal.tsx | 64 ++-- .../workspace/settings/members-list-item.tsx | 34 +-- .../workspace/settings/members-list.tsx | 65 ++--- .../workspace/settings/workspace-details.tsx | 41 ++- web/components/workspace/sidebar-dropdown.tsx | 39 ++- web/components/workspace/views/form.tsx | 10 +- web/constants/crisp.tsx | 5 +- web/layouts/auth-layout/user-wrapper.tsx | 11 +- web/layouts/auth-layout/workspace-wrapper.tsx | 17 +- web/pages/[workspaceSlug]/analytics.tsx | 26 +- .../me/profile/preferences.tsx | 10 +- .../[workspaceSlug]/settings/members.tsx | 39 ++- web/pages/create-workspace.tsx | 20 +- web/pages/onboarding/index.tsx | 13 +- web/store/project/project.store.ts | 8 +- web/store/root.ts | 11 +- web/store/workspace/index.ts | 1 + web/store/workspace/workspace-member.store.ts | 274 ++++++++++++++++++ web/store/workspace/workspace.store.ts | 123 -------- 28 files changed, 529 insertions(+), 352 deletions(-) create mode 100644 web/store/workspace/workspace-member.store.ts diff --git a/web/components/headers/global-issues.tsx b/web/components/headers/global-issues.tsx index 7c41ba327..5be966906 100644 --- a/web/components/headers/global-issues.tsx +++ b/web/components/headers/global-issues.tsx @@ -41,6 +41,7 @@ export const GlobalIssuesHeader: React.FC = observer((props) => { globalViewFilters: globalViewFiltersStore, workspaceFilter: workspaceFilterStore, workspace: workspaceStore, + workspaceMember: { workspaceMembers }, project: projectStore, } = useMobxStore(); @@ -145,7 +146,7 @@ export const GlobalIssuesHeader: React.FC = observer((props) => { handleFiltersUpdate={handleFiltersUpdate} layoutDisplayFiltersOptions={ISSUE_DISPLAY_FILTERS_BY_LAYOUT.my_issues.spreadsheet} labels={workspaceStore.workspaceLabels ?? undefined} - members={workspaceStore.workspaceMembers?.map((m) => m.member) ?? undefined} + members={workspaceMembers?.map((m) => m.member) ?? undefined} projects={workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : undefined} /> diff --git a/web/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx b/web/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx index ad1712b55..9bc94b0c9 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx @@ -22,6 +22,7 @@ export const GlobalViewsAppliedFiltersRoot = observer(() => { globalViewFilters: globalViewFiltersStore, project: projectStore, workspace: workspaceStore, + workspaceMember: { workspaceMembers }, } = useMobxStore(); const viewDetails = globalViewId ? globalViewsStore.globalViewDetails[globalViewId.toString()] : undefined; @@ -101,7 +102,7 @@ export const GlobalViewsAppliedFiltersRoot = observer(() => { handleClearAllFilters={handleClearAllFilters} handleRemoveFilter={handleRemoveFilter} labels={workspaceStore.workspaceLabels ?? undefined} - members={workspaceStore.workspaceMembers?.map((m) => m.member)} + members={workspaceMembers?.map((m) => m.member)} projects={workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : undefined} /> {storedFilters && viewDetails && areFiltersDifferent(storedFilters, viewDetails.query_data.filters ?? {}) && ( diff --git a/web/components/issues/issue-layouts/properties/assignee.tsx b/web/components/issues/issue-layouts/properties/assignee.tsx index 6b95b7e1d..c3d550055 100644 --- a/web/components/issues/issue-layouts/properties/assignee.tsx +++ b/web/components/issues/issue-layouts/properties/assignee.tsx @@ -39,18 +39,19 @@ export const IssuePropertyAssignee: React.FC = observer( multiple = false, noLabelBorder = false, } = props; - - const { workspace: workspaceStore, project: projectStore } = useMobxStore(); + // store + const { + workspace: workspaceStore, + project: projectStore, + workspaceMember: { workspaceMembers, fetchWorkspaceMembers }, + } = useMobxStore(); const workspaceSlug = workspaceStore?.workspaceSlug; - + // states const [query, setQuery] = useState(""); - const [referenceElement, setReferenceElement] = useState(null); const [popperElement, setPopperElement] = useState(null); const [isLoading, setIsLoading] = useState(false); - const workspaceMembers = workspaceSlug ? workspaceStore?.workspaceMembers : undefined; - const fetchProjectMembers = () => { setIsLoading(true); if (workspaceSlug && projectId) @@ -59,10 +60,9 @@ export const IssuePropertyAssignee: React.FC = observer( projectStore.fetchProjectMembers(workspaceSlug, projectId).then(() => setIsLoading(false)); }; - const fetchWorkspaceMembers = () => { + const getWorkspaceMembers = () => { setIsLoading(true); - if (workspaceSlug) - workspaceSlug && workspaceStore.fetchWorkspaceMembers(workspaceSlug).then(() => setIsLoading(false)); + if (workspaceSlug) workspaceSlug && fetchWorkspaceMembers(workspaceSlug).then(() => setIsLoading(false)); }; const options = (workspaceMembers ?? [])?.map((member) => ({ @@ -151,7 +151,7 @@ export const IssuePropertyAssignee: React.FC = observer( className={`flex items-center justify-between gap-1 w-full text-xs ${ disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80" } ${buttonClassName}`} - onClick={() => !workspaceMembers && fetchWorkspaceMembers()} + onClick={() => !workspaceMembers && getWorkspaceMembers()} > {label} {!hideDropdownArrow && !disabled &&