Skip to content

Commit

Permalink
sort by time
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Jul 17, 2024
1 parent 1b798a3 commit 370c9e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const WORKSPACE_LIST_CARD_DESCRIPTIOIN = i18n.translate('workspace.list.card.des
'Workspaces are dedicated environments for organizing and collaborating on your data, dashboards, and analytics workflows. Each Workspace acts as a self-contained space with its own set of saved objects and access controls.',
});

const MAX_ITEM_IN_LIST = 6;
const MAX_ITEM_IN_LIST = 5;

export interface WorkspaceListCardProps {
core: CoreStart;
Expand Down Expand Up @@ -94,9 +94,7 @@ export class WorkspaceListCard extends Component<WorkspaceListCardProps, Workspa
private loadWorkspaceListItems() {
if (this.state.filter === 'viewed') {
this.setState({
workspaceList: this.state.recentWorkspaces
.sort()
.reverse()
workspaceList: _.sortBy(this.state.recentWorkspaces, ['visitTime'])
.filter((ws) => this.state.availiableWorkspaces.some((a) => a.name === ws.workspaceName))
.slice(0, MAX_ITEM_IN_LIST)
.map((ws) => ({
Expand All @@ -107,7 +105,7 @@ export class WorkspaceListCard extends Component<WorkspaceListCardProps, Workspa
});
} else if (this.state.filter === 'updated') {
this.setState({
workspaceList: this.state.availiableWorkspaces
workspaceList: _.sortBy(this.state.availiableWorkspaces, ['lastUpdatedTime'])
.sort()
.reverse()
.slice(0, MAX_ITEM_IN_LIST)
Expand Down Expand Up @@ -205,18 +203,20 @@ export class WorkspaceListCard extends Component<WorkspaceListCardProps, Workspa
) : (
<EuiDescriptionList
type="column"
titleProps={{ style: { width: '70%' } }}
descriptionProps={{ style: { width: '30%' } }}
listItems={workspaceList.map((workspace) => ({
title: (
<EuiLink
onClick={() => {
this.handleSwitchWorkspace(workspace.id);

Check warning on line 212 in src/plugins/workspace/public/components/service_card/workspace_list_card.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/workspace/public/components/service_card/workspace_list_card.tsx#L212

Added line #L212 was not covered by tests
}}
>
{workspace.name}
<EuiText size="s">{workspace.name}</EuiText>
</EuiLink>
),
description: (
<EuiText color="subdued" className="eui-textRight">
<EuiText size="s" color="subdued" className="eui-textRight">
{moment(workspace.time).fromNow()}
</EuiText>
),
Expand Down

0 comments on commit 370c9e7

Please sign in to comment.