Skip to content

Commit

Permalink
update collapse button position
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Apr 9, 2024
1 parent ed42c8a commit 18f63b8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { notificationServiceMock } from '../notifications/notifications_service.
import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock';
import { ChromeService } from './chrome_service';
import { getAppInfo } from '../application/utils';
import { workspacesServiceMock } from '../mocks';

class FakeApp implements App {
public title: string;
Expand Down Expand Up @@ -70,6 +71,7 @@ function defaultStartDeps(availableApps?: App[]) {
injectedMetadata: injectedMetadataServiceMock.createStartContract(),
notifications: notificationServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
workspaces: workspacesServiceMock.createStartContract(),
};

if (availableApps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const WorkspaceOverview = () => {
} = useOpenSearchDashboards<CoreStart & { workspaceClient: WorkspaceClient }>();

const [isModalVisible, setIsModalVisible] = useState(false);
const [isStartWorkingVisible, setIsStartWorkingVisible] = useState(true);
const [isGettingStartVisible, setIsStartWorkingVisible] = useState(true);
const isPermissionEnabled = application.capabilities.workspaces.permissionEnabled;

const currentWorkspace = useObservable(workspaces.currentWorkspace$);
Expand All @@ -56,6 +56,10 @@ export const WorkspaceOverview = () => {
return getStartCards.filter((card) => !card.appId || featureFilter({ id: card.appId }));
}, [currentWorkspace]);

if (!currentWorkspace) {
return null;
}

const pageTitle = (
<EuiFlexGroup gutterSize="none" alignItems="baseline" justifyContent="flexStart">
<EuiFlexItem grow={false}>{currentWorkspace?.name}</EuiFlexItem>
Expand All @@ -77,15 +81,15 @@ export const WorkspaceOverview = () => {

const userList = allUserAndGroup.slice(0, 3).map((user) => {
return (
<EuiFlexItem key="user">
<EuiFlexItem key={user}>
<EuiAvatar size="m" name={user} />
</EuiFlexItem>
);
});
if (allUserAndGroup.length > 3) {
userList.push(
<EuiFlexItem key="more">
<EuiText>+{allUserAndGroup.length - 3}</EuiText>
<EuiText size="m">+{allUserAndGroup.length - 3}</EuiText>
</EuiFlexItem>
);
}
Expand Down Expand Up @@ -121,18 +125,34 @@ export const WorkspaceOverview = () => {
},
];

if (!currentWorkspace) {
return null;
const collapseButton = (
<EuiBadge
color="#fff"
style={{ backgroundColor: 'transparent', padding: '8px' }}
iconType={isGettingStartVisible ? 'arrowUp' : 'arrowDown'}
iconSide="right"
onClickAriaLabel="Click to toggle start working cards"
onClick={() => {
setIsStartWorkingVisible(!isGettingStartVisible);
}}
>
{isGettingStartVisible ? 'collapse' : 'expand'}
</EuiBadge>
);

let rightSideItems: ReactNode[] = userGroupsList ? [userGroupsList] : [];
if (!isGettingStartVisible) {
rightSideItems = [collapseButton, ...rightSideItems];
}

return (
<EuiPage>
<EuiPageBody>
<EuiPageHeader
pageTitle={pageTitle}
rightSideItems={userGroupsList ? [userGroupsList] : undefined}
rightSideItems={rightSideItems.length ? rightSideItems : undefined}
>
{isStartWorkingVisible ? (
{isGettingStartVisible ? (
<>
<EuiTitle size="s">
<p>
Expand Down Expand Up @@ -169,25 +189,13 @@ export const WorkspaceOverview = () => {
</EuiFlexGroup>
</>
) : null}
<EuiFlexGroup>
<EuiFlexItem />
<EuiFlexItem grow={false}>
<EuiBadge
color="#fff"
style={{ backgroundColor: 'transparent' }}
iconType={isStartWorkingVisible ? 'arrowUp' : 'arrowDown'}
iconSide="right"
onClickAriaLabel="Click to toggle start working cards"
onClick={() => {
setIsStartWorkingVisible(!isStartWorkingVisible);
}}
>
{isStartWorkingVisible ? 'collapse' : 'expand'}
</EuiBadge>
</EuiFlexItem>
</EuiFlexGroup>
{isGettingStartVisible ? (
<EuiFlexGroup>
<EuiFlexItem />
<EuiFlexItem grow={false}>{collapseButton}</EuiFlexItem>
</EuiFlexGroup>
) : null}
</EuiPageHeader>
<EuiSpacer />
<EuiPageContent>
<EuiTabbedContent
tabs={tabs}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/workspace/public/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Workspace plugin', () => {
await workspacePlugin.setup(setupMock, {
savedObjectsManagement: savedObjectManagementSetupMock,
});
expect(setupMock.application.register).toBeCalledTimes(5);
expect(setupMock.application.register).toBeCalledTimes(3);
expect(WorkspaceClientMock).toBeCalledTimes(1);
expect(workspaceClientMock.enterWorkspace).toBeCalledTimes(0);
expect(savedObjectManagementSetupMock.columns.register).toBeCalledTimes(1);
Expand Down

0 comments on commit 18f63b8

Please sign in to comment.