- Notifications
You must be signed in to change notification settings - Fork278
[Feat]: Improve Profile Dropdown, and Workspaces Page using "myorg" endpoint#1787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
29 commits Select commitHold shift + click to select a range
035fc26
redesign profile dropdown
iamfarana42f83c
testing workspaces endpoint
iamfaran8b40672
fix profile dropdown
iamfaran98695fb
setup redux, sagas for the new myorg endpoint
iamfaran35b7c68
fix profile dropdown create workspace issue
iamfarana5d372a
test
iamfaran1b63471
fix params
iamfaran049d372
make currentOrg selector
iamfarana902532
add page size param
iamfaran7709d58
replace orgs data with myorg for dropdown
iamfarane202fcb
remove dispatch from the profile dropdown
iamfaran818fdf8
Merge branch 'dev' of github.com:lowcoder-org/lowcoder into profileDr…
iamfaranf851353
fetch 10 workspaces initially
iamfaran9ea107b
add pagination and filtering for the dropdown
iamfaran28a2101
refactor profile dropdown
iamfaran0d59610
fix debouncing
iamfaranc7edbd1
fix loading when search
iamfaran238698d
fix shrinking issues when page 1 to page 2
iamfaran0611910
add antD loader in UI
iamfaranffa7757
fix delete sync
iamfaran96acd6a
fix sync after edit
iamfarandb11f0e
add pagination/filtering for the Workspaces page
iamfaran2f291f7
add selector for the current org
iamfaranb3abc61
add active indicator in the workspaces page
iamfaran23fcbf9
add the ability to switch workspaces from workspaces page
iamfarancd92f7c
disable row click on switch
iamfaran73a64b4
fix switch org button
iamfaran763bd98
Merge branch 'dev' of github.com:lowcoder-org/lowcoder into feat/myor…
iamfaran24e04c0
Merge branch 'dev' into feat/myorg-endpoint
raheeliftikhar5File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
28 changes: 27 additions & 1 deletionclient/packages/lowcoder/src/api/userApi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletionsclient/packages/lowcoder/src/constants/reduxActionConstants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsclient/packages/lowcoder/src/i18n/locales/en.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
288 changes: 288 additions & 0 deletionsclient/packages/lowcoder/src/pages/common/WorkspaceSection.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,288 @@ | ||
import React from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import styled from 'styled-components'; | ||
import { Input, Pagination, Spin } from 'antd'; | ||
import { User } from 'constants/userConstants'; | ||
import { switchOrg, createOrgAction } from 'redux/reduxActions/orgActions'; | ||
import { selectSystemConfig } from 'redux/selectors/configSelectors'; | ||
import { showSwitchOrg } from '@lowcoder-ee/pages/common/customerService'; | ||
import { useWorkspaceManager } from 'util/useWorkspaceManager'; | ||
import { trans } from 'i18n'; | ||
import { | ||
AddIcon, | ||
CheckoutIcon, | ||
SearchIcon, | ||
} from 'lowcoder-design'; | ||
import { ORGANIZATION_SETTING } from 'constants/routesURL'; | ||
import history from 'util/history'; | ||
import { Org } from 'constants/orgConstants'; | ||
// Styled Components | ||
const WorkspaceSection = styled.div` | ||
padding: 8px 0; | ||
`; | ||
const SectionHeader = styled.div` | ||
padding: 8px 16px; | ||
font-size: 12px; | ||
font-weight: 500; | ||
color: #8b8fa3; | ||
text-transform: uppercase; | ||
letter-spacing: 0.5px; | ||
`; | ||
const SearchContainer = styled.div` | ||
padding: 8px 12px; | ||
border-bottom: 1px solid #f0f0f0; | ||
`; | ||
const StyledSearchInput = styled(Input)` | ||
.ant-input { | ||
border: 1px solid #e1e3eb; | ||
border-radius: 6px; | ||
font-size: 13px; | ||
&:focus { | ||
border-color: #4965f2; | ||
box-shadow: 0 0 0 2px rgba(73, 101, 242, 0.1); | ||
} | ||
} | ||
`; | ||
const WorkspaceList = styled.div` | ||
max-height: 200px; | ||
overflow-y: auto; | ||
&::-webkit-scrollbar { | ||
width: 4px; | ||
} | ||
&::-webkit-scrollbar-track { | ||
background: #f1f1f1; | ||
} | ||
&::-webkit-scrollbar-thumb { | ||
background: #c1c1c1; | ||
border-radius: 2px; | ||
} | ||
&::-webkit-scrollbar-thumb:hover { | ||
background: #a8a8a8; | ||
} | ||
`; | ||
const WorkspaceItem = styled.div<{ isActive?: boolean }>` | ||
display: flex; | ||
align-items: center; | ||
padding: 10px 16px; | ||
cursor: pointer; | ||
transition: background-color 0.2s; | ||
background-color: ${props => props.isActive ? '#f0f5ff' : 'transparent'}; | ||
&:hover { | ||
background-color: ${props => props.isActive ? '#f0f5ff' : '#f8f9fa'}; | ||
} | ||
`; | ||
const WorkspaceName = styled.div` | ||
flex: 1; | ||
font-size: 13px; | ||
color: #222222; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
`; | ||
const ActiveIcon = styled(CheckoutIcon)` | ||
width: 16px; | ||
height: 16px; | ||
color: #4965f2; | ||
margin-left: 8px; | ||
`; | ||
const CreateWorkspaceItem = styled.div` | ||
display: flex; | ||
align-items: center; | ||
padding: 12px 16px; | ||
cursor: pointer; | ||
transition: background-color 0.2s; | ||
font-size: 13px; | ||
color: #4965f2; | ||
font-weight: 500; | ||
&:hover { | ||
background-color: #f0f5ff; | ||
color: #3651d4; | ||
} | ||
svg { | ||
width: 16px; | ||
height: 16px; | ||
margin-right: 10px; | ||
color: #4965f2; | ||
} | ||
&:hover svg { | ||
color: #3651d4; | ||
} | ||
`; | ||
const EmptyState = styled.div` | ||
padding: 20px 16px; | ||
text-align: center; | ||
color: #8b8fa3; | ||
font-size: 13px; | ||
`; | ||
const PaginationContainer = styled.div` | ||
padding: 12px 16px; | ||
border-top: 1px solid #f0f0f0; | ||
display: flex; | ||
justify-content: center; | ||
.ant-pagination { | ||
margin: 0; | ||
.ant-pagination-item { | ||
min-width: 24px; | ||
height: 24px; | ||
line-height: 22px; | ||
font-size: 12px; | ||
margin-right: 4px; | ||
} | ||
.ant-pagination-prev, | ||
.ant-pagination-next { | ||
min-width: 24px; | ||
height: 24px; | ||
line-height: 22px; | ||
margin-right: 4px; | ||
} | ||
.ant-pagination-item-link { | ||
font-size: 11px; | ||
} | ||
} | ||
`; | ||
const LoadingContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 24px 16px; | ||
`; | ||
// Component Props | ||
interface WorkspaceSectionProps { | ||
user: User; | ||
isDropdownOpen: boolean; | ||
onClose: () => void; | ||
} | ||
// Main Component | ||
export default function WorkspaceSectionComponent({ | ||
user, | ||
isDropdownOpen, | ||
onClose | ||
}: WorkspaceSectionProps) { | ||
const dispatch = useDispatch(); | ||
const sysConfig = useSelector(selectSystemConfig); | ||
// Use our custom hook | ||
const { | ||
searchTerm, | ||
currentPage, | ||
totalCount, | ||
isLoading, | ||
displayWorkspaces, | ||
handleSearchChange, | ||
handlePageChange, | ||
pageSize, | ||
} = useWorkspaceManager({}); | ||
// Early returns for better performance | ||
if (!showSwitchOrg(user, sysConfig)) return null; | ||
// Event handlers | ||
const handleOrgSwitch = (orgId: string) => { | ||
if (user.currentOrgId !== orgId) { | ||
dispatch(switchOrg(orgId)); | ||
} | ||
onClose(); | ||
}; | ||
const handleCreateOrg = () => { | ||
dispatch(createOrgAction(user.orgs)); | ||
history.push(ORGANIZATION_SETTING); | ||
onClose(); | ||
}; | ||
return ( | ||
<WorkspaceSection> | ||
<SectionHeader>{trans("profile.switchOrg")}</SectionHeader> | ||
{/* Search Input - Only show if more than 3 workspaces */} | ||
<SearchContainer> | ||
<StyledSearchInput | ||
placeholder="Search workspaces..." | ||
value={searchTerm} | ||
onChange={(e) => handleSearchChange(e.target.value)} | ||
prefix={<SearchIcon style={{ color: "#8b8fa3" }} />} | ||
size="small" | ||
/> | ||
</SearchContainer> | ||
{/* Workspace List */} | ||
<WorkspaceList> | ||
{isLoading ? ( | ||
<LoadingContainer> | ||
<Spin size="small" /> | ||
</LoadingContainer> | ||
) : displayWorkspaces.length > 0 ? ( | ||
displayWorkspaces.map((org: Org) => ( | ||
<WorkspaceItem | ||
key={org.id} | ||
isActive={user.currentOrgId === org.id} | ||
onClick={() => handleOrgSwitch(org.id)} | ||
> | ||
<WorkspaceName title={org.name}>{org.name}</WorkspaceName> | ||
{user.currentOrgId === org.id && <ActiveIcon />} | ||
</WorkspaceItem> | ||
)) | ||
) : ( | ||
<EmptyState> | ||
{searchTerm.trim() | ||
? "No workspaces found" | ||
: "No workspaces available" | ||
} | ||
</EmptyState> | ||
)} | ||
</WorkspaceList> | ||
{/* Pagination - Only show when needed */} | ||
{totalCount > pageSize && !isLoading && ( | ||
<PaginationContainer> | ||
<Pagination | ||
current={currentPage} | ||
total={totalCount} | ||
pageSize={pageSize} | ||
size="small" | ||
showSizeChanger={false} | ||
showQuickJumper={false} | ||
showTotal={(total, range) => | ||
`${range[0]}-${range[1]} of ${total}` | ||
} | ||
onChange={handlePageChange} | ||
simple={totalCount > 100} // Simple mode for large datasets | ||
/> | ||
</PaginationContainer> | ||
)} | ||
{/* Create Workspace Button */} | ||
<CreateWorkspaceItem onClick={handleCreateOrg}> | ||
<AddIcon /> | ||
{trans("profile.createOrg")} | ||
</CreateWorkspaceItem> | ||
</WorkspaceSection> | ||
); | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.