Skip to content

Commit

Permalink
Showing 4 changed files with 31 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.4.1-rc.6](https://github.com/zextras/carbonio-shell-ui/compare/v0.4.1-rc.5...v0.4.1-rc.6) (2022-03-07)


### Features

* changed behaviour of new button for search and settings modules ([a49d589](https://github.com/zextras/carbonio-shell-ui/commit/a49d589781da33ae83389d26647ce9b8d91af60b))

### [0.4.1-rc.5](https://github.com/zextras/carbonio-shell-ui/compare/v0.4.1-rc.4...v0.4.1-rc.5) (2022-03-04)


4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zextras/carbonio-shell-ui",
"version": "0.4.1-rc.5",
"version": "0.4.1-rc.6",
"description": "The Zextras Carbonio web client",
"main": "dist/zapp-shell.bundle.js",
"types": "./types/index.d.ts",
25 changes: 21 additions & 4 deletions src/shell/creation-button.tsx
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import React, { FC, useMemo } from 'react';
import React, { FC, useCallback, useMemo, useState } from 'react';
import { reduce, groupBy } from 'lodash';
import { MultiButton } from '@zextras/carbonio-design-system';
import { MultiButton, Button, Dropdown } from '@zextras/carbonio-design-system';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
import { useActions } from '../store/integrations/hooks';
@@ -43,16 +43,23 @@ export const CreationButton: FC<{ activeRoute?: AppRoute }> = ({ activeRoute })
const [t] = useTranslation();
const location = useLocation();
const actions = useActions({ activeRoute, location }, ACTION_TYPES.NEW);
const [open, setOpen] = useState(false);
const primaryAction = useMemo(
() =>
actions?.find?.(
(a) => (a.group === activeRoute?.id || a.group === activeRoute?.app) && a.primary
) ?? actions?.find?.((a) => a.primary),
),
[actions, activeRoute?.app, activeRoute?.id]
);
const secondaryActions = useSecondaryActions(actions, activeRoute);

return (
const onClose = useCallback(() => {
setOpen(false);
}, []);
const onOpen = useCallback(() => {
setOpen(true);
}, []);
return primaryAction ? (
<MultiButton
style={{ height: '42px' }}
background="primary"
@@ -61,5 +68,15 @@ export const CreationButton: FC<{ activeRoute?: AppRoute }> = ({ activeRoute })
items={secondaryActions}
disabled={!primaryAction || primaryAction?.disabled}
/>
) : (
<Dropdown items={secondaryActions} onClose={onClose} onOpen={onOpen}>
<Button
style={{ height: '42px' }}
background="primary"
items={secondaryActions}
label={t('new', 'New')}
icon={open ? 'ChevronUp' : 'ChevronDown'}
/>
</Dropdown>
);
};

0 comments on commit 7f36d63

Please sign in to comment.