cozy-ui 128.6.0 → 128.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/react/Layout/Layout.md +25 -6
- package/react/Nav/index.jsx +43 -0
- package/react/Storage/Readme.md +46 -0
- package/react/Storage/StorageButton.jsx +34 -0
- package/react/Storage/StorageProgress.jsx +52 -0
- package/react/Storage/index.jsx +41 -0
- package/react/Storage/locales/en.json +7 -0
- package/react/Storage/locales/fr.json +7 -0
- package/react/Storage/locales/index.jsx +7 -0
- package/transpiled/react/Nav/index.d.ts +6 -0
- package/transpiled/react/Nav/index.js +49 -0
- package/transpiled/react/Storage/StorageButton.d.ts +4 -0
- package/transpiled/react/Storage/StorageButton.js +36 -0
- package/transpiled/react/Storage/StorageProgress.d.ts +5 -0
- package/transpiled/react/Storage/StorageProgress.js +50 -0
- package/transpiled/react/Storage/index.d.ts +14 -0
- package/transpiled/react/Storage/index.js +32 -0
- package/transpiled/react/Storage/locales/index.d.ts +6 -0
- package/transpiled/react/Storage/locales/index.js +18 -0
- package/transpiled/react/deprecated/Menus/index.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [128.8.0](https://github.com/cozy/cozy-ui/compare/v128.7.0...v128.8.0) (2025-09-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **NavDesktopDropdown:** introduce NavDesktopDropdown component for enhanced navigation item management ([3cb8a44](https://github.com/cozy/cozy-ui/commit/3cb8a44))
|
|
7
|
+
|
|
8
|
+
# [128.7.0](https://github.com/cozy/cozy-ui/compare/v128.6.0...v128.7.0) (2025-09-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Add Storage component ([76c74ed](https://github.com/cozy/cozy-ui/commit/76c74ed))
|
|
14
|
+
|
|
1
15
|
# [128.6.0](https://github.com/cozy/cozy-ui/compare/v128.5.0...v128.6.0) (2025-09-08)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/react/Layout/Layout.md
CHANGED
|
@@ -4,6 +4,7 @@ The Layout component brings a strong context for apps with any screen resolution
|
|
|
4
4
|
* `<Content />` is the main content or your app.
|
|
5
5
|
* ⚠️ Secondary `<NavItem />` are not visible on mobile and tablets
|
|
6
6
|
* `<NavDesktopLimiter />` is a component that allows you to limit the number of visible items in a list and toggle between showing a limited view and displaying all items.
|
|
7
|
+
* `<NavDesktopDropdown />` is a component that allows you to show / hide the items in a list when the number of items exceeds a defined limit
|
|
7
8
|
|
|
8
9
|
### NavDesktopLimiter
|
|
9
10
|
|
|
@@ -16,17 +17,24 @@ It can be used to wrap any list of React elements, automatically providing funct
|
|
|
16
17
|
* **children**: React.ReactNode (required) - The list items or elements that **NavDesktopLimiter** will manage.
|
|
17
18
|
* **max**: number (optional) - The maximum number of items to display initially. Default is **5**.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
### NavDesktopDropdown
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
The **NavDesktopDropdown** component is designed to manage the display of nav items efficiently, allowing users to toggle between showing a collapsed view and displaying all items. This component enhances the UI/UX by providing a clean and intuitive way to handle dropdowns with many items.
|
|
23
|
+
|
|
24
|
+
It can be used to wrap any list of React elements, automatically providing functionality to limit the number of displayed elements based on the `limit` prop (defaulting to **5**). Users can toggle the dropdown to show or hide the items as needed.
|
|
25
|
+
|
|
26
|
+
**Props**:
|
|
27
|
+
|
|
28
|
+
* **label**: string (required) - The label for the dropdown.
|
|
29
|
+
* **children**: React.ReactNode (required) - The list items or elements that **NavDesktopDropdown** will manage.
|
|
30
|
+
* **defaultOpen**: boolean (optional) - Determines whether the dropdown is open by default. Default is **true**.
|
|
31
|
+
* **limit**: number (optional) - The maximum number of items to display before enabling collapsing. Default is **5**.
|
|
24
32
|
|
|
25
33
|
```jsx
|
|
26
34
|
import { useState } from 'react'
|
|
27
35
|
import { Layout, Main, Content } from 'cozy-ui/transpiled/react/Layout'
|
|
28
36
|
import Sidebar from 'cozy-ui/transpiled/react/Sidebar'
|
|
29
|
-
import Nav, { NavItem, NavIcon, NavText, genNavLink, NavDesktopLimiter } from 'cozy-ui/transpiled/react/Nav'
|
|
37
|
+
import Nav, { NavItem, NavIcon, NavText, genNavLink, NavDesktopLimiter, NavDesktopDropdown } from 'cozy-ui/transpiled/react/Nav'
|
|
30
38
|
import cx from 'classnames'
|
|
31
39
|
import isEqual from 'lodash/isEqual'
|
|
32
40
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
@@ -83,7 +91,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
83
91
|
}
|
|
84
92
|
}))
|
|
85
93
|
|
|
86
|
-
const initialVariants = [{ monoColumn: false, withTopBar: true, longContent: true }]
|
|
94
|
+
const initialVariants = [{ monoColumn: false, withTopBar: true, longContent: true, moreThanMax: true }]
|
|
87
95
|
const [active, setActive] = useState(['Section 1', 'Subsection 1'])
|
|
88
96
|
const [showDialog, setShowDialog] = useState(isTesting() ? true : false)
|
|
89
97
|
const styles = useStyles()
|
|
@@ -130,6 +138,17 @@ const SideBar = ({ variant }) => {
|
|
|
130
138
|
<NavText>Section 3</NavText>
|
|
131
139
|
</NavLink>
|
|
132
140
|
</NavItem>
|
|
141
|
+
<NavDesktopDropdown label="Section 4" max={5}>
|
|
142
|
+
{
|
|
143
|
+
Array.from(Array(variant.moreThanMax ? 6 : 3).keys()).map(i => (
|
|
144
|
+
<NavItem secondary key={i}>
|
|
145
|
+
<NavLink>
|
|
146
|
+
<NavText>Subsection {i}</NavText>
|
|
147
|
+
</NavLink>
|
|
148
|
+
</NavItem>
|
|
149
|
+
))
|
|
150
|
+
}
|
|
151
|
+
</NavDesktopDropdown>
|
|
133
152
|
</Nav>
|
|
134
153
|
</Sidebar>
|
|
135
154
|
)
|
package/react/Nav/index.jsx
CHANGED
|
@@ -3,9 +3,11 @@ import React, { Children, isValidElement, useState, forwardRef } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import withNavLocales from './locales/withNavLocales'
|
|
5
5
|
import styles from './styles.styl'
|
|
6
|
+
import DropdownText from '../DropdownText'
|
|
6
7
|
import Icon from '../Icon'
|
|
7
8
|
import BottomIcon from '../Icons/Bottom'
|
|
8
9
|
import TopIcon from '../Icons/Top'
|
|
10
|
+
import ListItem from '../ListItem'
|
|
9
11
|
import useBreakpoints from '../providers/Breakpoints'
|
|
10
12
|
import { useI18n } from '../providers/I18n'
|
|
11
13
|
|
|
@@ -116,5 +118,46 @@ const _NavDesktopLimiter = ({ children, max = 5 }) => {
|
|
|
116
118
|
|
|
117
119
|
export const NavDesktopLimiter = withNavLocales(_NavDesktopLimiter)
|
|
118
120
|
|
|
121
|
+
export const NavDesktopDropdown = ({
|
|
122
|
+
label,
|
|
123
|
+
children,
|
|
124
|
+
defaultOpen = true,
|
|
125
|
+
limit = 5
|
|
126
|
+
}) => {
|
|
127
|
+
const { isDesktop } = useBreakpoints()
|
|
128
|
+
const [open, setOpen] = useState(defaultOpen)
|
|
129
|
+
const isActivated =
|
|
130
|
+
Children.toArray(children).filter(isValidElement).length > limit
|
|
131
|
+
|
|
132
|
+
const innerIconProps = {
|
|
133
|
+
rotate: open ? 0 : -90,
|
|
134
|
+
...(!isActivated && { className: 'u-dn' })
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!isDesktop) return null
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<>
|
|
141
|
+
<ListItem size="small" className={isActivated ? 'u-c-pointer' : ''}>
|
|
142
|
+
<DropdownText
|
|
143
|
+
variant="subtitle2"
|
|
144
|
+
color="textSecondary"
|
|
145
|
+
innerIconProps={innerIconProps}
|
|
146
|
+
onClick={() => {
|
|
147
|
+
if (!isActivated) {
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
setOpen(!open)
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
{label}
|
|
154
|
+
</DropdownText>
|
|
155
|
+
</ListItem>
|
|
156
|
+
|
|
157
|
+
{open && <>{children}</>}
|
|
158
|
+
</>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
119
162
|
export default Nav
|
|
120
163
|
Nav.NavItem = NavItem
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
```jsx
|
|
2
|
+
import Storage from 'cozy-ui/transpiled/react/Storage'
|
|
3
|
+
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
4
|
+
|
|
5
|
+
const client = {
|
|
6
|
+
store: {
|
|
7
|
+
getState: () => {},
|
|
8
|
+
subscribe: () => {},
|
|
9
|
+
unsubscribe: () => {}
|
|
10
|
+
},
|
|
11
|
+
getInstanceOptions: () => {},
|
|
12
|
+
query: () => {},
|
|
13
|
+
getQueryFromState: queryName => {
|
|
14
|
+
if (queryName === 'io.cozy.settings/io.cozy.settings.instance') {
|
|
15
|
+
return {
|
|
16
|
+
data: {
|
|
17
|
+
uuid: "uid123"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
} else if (queryName === 'io.cozy.settings/io.cozy.settings.context') {
|
|
21
|
+
return {
|
|
22
|
+
data: {
|
|
23
|
+
manager_url: "http://manager-url/",
|
|
24
|
+
enable_premium_links: true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} else if (queryName === 'io.cozy.settings/io.cozy.settings.disk-usage') {
|
|
28
|
+
return {
|
|
29
|
+
data: {
|
|
30
|
+
used: "500000000",
|
|
31
|
+
quota: "1000000000"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
;
|
|
39
|
+
|
|
40
|
+
<DemoProvider client={client}>
|
|
41
|
+
<div className="u-p-1-half u-maw-5">
|
|
42
|
+
<Storage onlyDesktop={false} />
|
|
43
|
+
</div>
|
|
44
|
+
</DemoProvider>
|
|
45
|
+
|
|
46
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useInstanceInfo } from 'cozy-client'
|
|
5
|
+
import { buildPremiumLink } from 'cozy-client/dist/models/instance'
|
|
6
|
+
|
|
7
|
+
import { locales } from './locales'
|
|
8
|
+
import Button from '../Buttons'
|
|
9
|
+
import Icon from '../Icon'
|
|
10
|
+
import TwakeWorkplaceIcon from '../Icons/TwakeWorkplace'
|
|
11
|
+
import { useI18n, useExtendI18n } from '../providers/I18n'
|
|
12
|
+
|
|
13
|
+
const StorageButton = ({ className }) => {
|
|
14
|
+
useExtendI18n(locales)
|
|
15
|
+
const { t } = useI18n()
|
|
16
|
+
const instanceInfo = useInstanceInfo()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Button
|
|
20
|
+
className={cx('u-bdrs-4', className)}
|
|
21
|
+
variant="secondary"
|
|
22
|
+
label={t('Storage.increase')}
|
|
23
|
+
startIcon={<Icon icon={TwakeWorkplaceIcon} size={22} />}
|
|
24
|
+
size="small"
|
|
25
|
+
height="auto"
|
|
26
|
+
fullWidth
|
|
27
|
+
component="a"
|
|
28
|
+
target="_blank"
|
|
29
|
+
href={buildPremiumLink(instanceInfo)}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default StorageButton
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { useInstanceInfo } from 'cozy-client'
|
|
4
|
+
import { makeDiskInfos } from 'cozy-client/dist/models/instance'
|
|
5
|
+
|
|
6
|
+
import { locales } from './locales'
|
|
7
|
+
import Icon from '../Icon'
|
|
8
|
+
import CloudIcon from '../Icons/Cloud'
|
|
9
|
+
import { LinearProgress } from '../Progress'
|
|
10
|
+
import Typography from '../Typography'
|
|
11
|
+
import { useI18n, useExtendI18n } from '../providers/I18n'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Show remaining disk space with a progress bar
|
|
15
|
+
*/
|
|
16
|
+
const StorageProgress = () => {
|
|
17
|
+
useExtendI18n(locales)
|
|
18
|
+
const { t } = useI18n()
|
|
19
|
+
|
|
20
|
+
const { diskUsage } = useInstanceInfo()
|
|
21
|
+
|
|
22
|
+
const { humanDiskQuota, humanDiskUsage, percentUsage } = makeDiskInfos(
|
|
23
|
+
diskUsage.data?.used,
|
|
24
|
+
diskUsage.data?.quota
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<div className="u-flex u-flex-items-center">
|
|
30
|
+
<Icon
|
|
31
|
+
className="u-mr-half"
|
|
32
|
+
icon={CloudIcon}
|
|
33
|
+
size={24}
|
|
34
|
+
color="var(--iconTextColor)"
|
|
35
|
+
/>
|
|
36
|
+
<Typography variant="caption">{t('Storage.title')}</Typography>
|
|
37
|
+
</div>
|
|
38
|
+
<LinearProgress
|
|
39
|
+
className="u-mv-half"
|
|
40
|
+
variant="determinate"
|
|
41
|
+
value={parseInt(percentUsage)}
|
|
42
|
+
/>
|
|
43
|
+
<Typography variant="caption">
|
|
44
|
+
{t('Storage.availability', {
|
|
45
|
+
smart_count: (humanDiskQuota - humanDiskUsage).toFixed(2)
|
|
46
|
+
})}
|
|
47
|
+
</Typography>
|
|
48
|
+
</>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default StorageProgress
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useInstanceInfo } from 'cozy-client'
|
|
5
|
+
import { shouldDisplayOffers } from 'cozy-client/dist/models/instance'
|
|
6
|
+
import { isFlagshipApp } from 'cozy-device-helper'
|
|
7
|
+
|
|
8
|
+
import StorageButton from './StorageButton'
|
|
9
|
+
import StorageProgress from './StorageProgress'
|
|
10
|
+
import useBreakpoints from '../providers/Breakpoints'
|
|
11
|
+
|
|
12
|
+
const Storage = ({ onlyDesktop }) => {
|
|
13
|
+
const { isDesktop, isMobile } = useBreakpoints()
|
|
14
|
+
const instanceInfo = useInstanceInfo()
|
|
15
|
+
|
|
16
|
+
if (onlyDesktop && !isDesktop) return null
|
|
17
|
+
|
|
18
|
+
const showStorageButton =
|
|
19
|
+
instanceInfo.isLoaded &&
|
|
20
|
+
!isFlagshipApp() &&
|
|
21
|
+
!isMobile &&
|
|
22
|
+
shouldDisplayOffers(instanceInfo)
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<StorageProgress />
|
|
27
|
+
{showStorageButton && <StorageButton className="u-mt-1" />}
|
|
28
|
+
</>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Storage.propTypes = {
|
|
33
|
+
/** Component enabled only for desktop. Using `false` will enable it for mobile and tablet also. */
|
|
34
|
+
onlyDesktop: PropTypes.bool
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Storage.defaultProps = {
|
|
38
|
+
onlyDesktop: true
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default Storage
|
|
@@ -23,6 +23,12 @@ export function NavIcon({ className, icon }: {
|
|
|
23
23
|
icon: any;
|
|
24
24
|
}): JSX.Element;
|
|
25
25
|
export const NavDesktopLimiter: any;
|
|
26
|
+
export function NavDesktopDropdown({ label, children, defaultOpen, limit }: {
|
|
27
|
+
label: any;
|
|
28
|
+
children: any;
|
|
29
|
+
defaultOpen?: boolean | undefined;
|
|
30
|
+
limit?: number | undefined;
|
|
31
|
+
}): JSX.Element | null;
|
|
26
32
|
export default Nav;
|
|
27
33
|
import React from "react";
|
|
28
34
|
declare function Nav({ className, children }: {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
5
|
var _excluded = ["className", "children", "secondary"],
|
|
5
6
|
_excluded2 = ["to", "children"];
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
6
12
|
import cx from 'classnames';
|
|
7
13
|
import React, { Children, isValidElement, useState, forwardRef } from 'react';
|
|
8
14
|
import withNavLocales from "cozy-ui/transpiled/react/Nav/locales/withNavLocales";
|
|
@@ -16,9 +22,11 @@ var styles = {
|
|
|
16
22
|
"c-nav-item-secondary": "styles__c-nav-item-secondary___k14rf",
|
|
17
23
|
"c-nav-limiter": "styles__c-nav-limiter___3oxQU"
|
|
18
24
|
};
|
|
25
|
+
import DropdownText from "cozy-ui/transpiled/react/DropdownText";
|
|
19
26
|
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
27
|
import BottomIcon from "cozy-ui/transpiled/react/Icons/Bottom";
|
|
21
28
|
import TopIcon from "cozy-ui/transpiled/react/Icons/Top";
|
|
29
|
+
import ListItem from "cozy-ui/transpiled/react/ListItem";
|
|
22
30
|
import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
23
31
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
24
32
|
export var NavItem = function NavItem(_ref) {
|
|
@@ -136,5 +144,46 @@ var _NavDesktopLimiter = function _NavDesktopLimiter(_ref7) {
|
|
|
136
144
|
};
|
|
137
145
|
|
|
138
146
|
export var NavDesktopLimiter = withNavLocales(_NavDesktopLimiter);
|
|
147
|
+
export var NavDesktopDropdown = function NavDesktopDropdown(_ref8) {
|
|
148
|
+
var label = _ref8.label,
|
|
149
|
+
children = _ref8.children,
|
|
150
|
+
_ref8$defaultOpen = _ref8.defaultOpen,
|
|
151
|
+
defaultOpen = _ref8$defaultOpen === void 0 ? true : _ref8$defaultOpen,
|
|
152
|
+
_ref8$limit = _ref8.limit,
|
|
153
|
+
limit = _ref8$limit === void 0 ? 5 : _ref8$limit;
|
|
154
|
+
|
|
155
|
+
var _useBreakpoints2 = useBreakpoints(),
|
|
156
|
+
isDesktop = _useBreakpoints2.isDesktop;
|
|
157
|
+
|
|
158
|
+
var _useState3 = useState(defaultOpen),
|
|
159
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
160
|
+
open = _useState4[0],
|
|
161
|
+
setOpen = _useState4[1];
|
|
162
|
+
|
|
163
|
+
var isActivated = Children.toArray(children).filter(isValidElement).length > limit;
|
|
164
|
+
|
|
165
|
+
var innerIconProps = _objectSpread({
|
|
166
|
+
rotate: open ? 0 : -90
|
|
167
|
+
}, !isActivated && {
|
|
168
|
+
className: 'u-dn'
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (!isDesktop) return null;
|
|
172
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItem, {
|
|
173
|
+
size: "small",
|
|
174
|
+
className: isActivated ? 'u-c-pointer' : ''
|
|
175
|
+
}, /*#__PURE__*/React.createElement(DropdownText, {
|
|
176
|
+
variant: "subtitle2",
|
|
177
|
+
color: "textSecondary",
|
|
178
|
+
innerIconProps: innerIconProps,
|
|
179
|
+
onClick: function onClick() {
|
|
180
|
+
if (!isActivated) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setOpen(!open);
|
|
185
|
+
}
|
|
186
|
+
}, label)), open && /*#__PURE__*/React.createElement(React.Fragment, null, children));
|
|
187
|
+
};
|
|
139
188
|
export default Nav;
|
|
140
189
|
Nav.NavItem = NavItem;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useInstanceInfo } from 'cozy-client';
|
|
4
|
+
import { buildPremiumLink } from 'cozy-client/dist/models/instance';
|
|
5
|
+
import { locales } from "cozy-ui/transpiled/react/Storage/locales";
|
|
6
|
+
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
7
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
8
|
+
import TwakeWorkplaceIcon from "cozy-ui/transpiled/react/Icons/TwakeWorkplace";
|
|
9
|
+
import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
10
|
+
|
|
11
|
+
var StorageButton = function StorageButton(_ref) {
|
|
12
|
+
var className = _ref.className;
|
|
13
|
+
useExtendI18n(locales);
|
|
14
|
+
|
|
15
|
+
var _useI18n = useI18n(),
|
|
16
|
+
t = _useI18n.t;
|
|
17
|
+
|
|
18
|
+
var instanceInfo = useInstanceInfo();
|
|
19
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
20
|
+
className: cx('u-bdrs-4', className),
|
|
21
|
+
variant: "secondary",
|
|
22
|
+
label: t('Storage.increase'),
|
|
23
|
+
startIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
24
|
+
icon: TwakeWorkplaceIcon,
|
|
25
|
+
size: 22
|
|
26
|
+
}),
|
|
27
|
+
size: "small",
|
|
28
|
+
height: "auto",
|
|
29
|
+
fullWidth: true,
|
|
30
|
+
component: "a",
|
|
31
|
+
target: "_blank",
|
|
32
|
+
href: buildPremiumLink(instanceInfo)
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default StorageButton;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useInstanceInfo } from 'cozy-client';
|
|
3
|
+
import { makeDiskInfos } from 'cozy-client/dist/models/instance';
|
|
4
|
+
import { locales } from "cozy-ui/transpiled/react/Storage/locales";
|
|
5
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
6
|
+
import CloudIcon from "cozy-ui/transpiled/react/Icons/Cloud";
|
|
7
|
+
import { LinearProgress } from "cozy-ui/transpiled/react/Progress";
|
|
8
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
9
|
+
import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
10
|
+
/**
|
|
11
|
+
* Show remaining disk space with a progress bar
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
var StorageProgress = function StorageProgress() {
|
|
15
|
+
var _diskUsage$data, _diskUsage$data2;
|
|
16
|
+
|
|
17
|
+
useExtendI18n(locales);
|
|
18
|
+
|
|
19
|
+
var _useI18n = useI18n(),
|
|
20
|
+
t = _useI18n.t;
|
|
21
|
+
|
|
22
|
+
var _useInstanceInfo = useInstanceInfo(),
|
|
23
|
+
diskUsage = _useInstanceInfo.diskUsage;
|
|
24
|
+
|
|
25
|
+
var _makeDiskInfos = makeDiskInfos((_diskUsage$data = diskUsage.data) === null || _diskUsage$data === void 0 ? void 0 : _diskUsage$data.used, (_diskUsage$data2 = diskUsage.data) === null || _diskUsage$data2 === void 0 ? void 0 : _diskUsage$data2.quota),
|
|
26
|
+
humanDiskQuota = _makeDiskInfos.humanDiskQuota,
|
|
27
|
+
humanDiskUsage = _makeDiskInfos.humanDiskUsage,
|
|
28
|
+
percentUsage = _makeDiskInfos.percentUsage;
|
|
29
|
+
|
|
30
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "u-flex u-flex-items-center"
|
|
32
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
33
|
+
className: "u-mr-half",
|
|
34
|
+
icon: CloudIcon,
|
|
35
|
+
size: 24,
|
|
36
|
+
color: "var(--iconTextColor)"
|
|
37
|
+
}), /*#__PURE__*/React.createElement(Typography, {
|
|
38
|
+
variant: "caption"
|
|
39
|
+
}, t('Storage.title'))), /*#__PURE__*/React.createElement(LinearProgress, {
|
|
40
|
+
className: "u-mv-half",
|
|
41
|
+
variant: "determinate",
|
|
42
|
+
value: parseInt(percentUsage)
|
|
43
|
+
}), /*#__PURE__*/React.createElement(Typography, {
|
|
44
|
+
variant: "caption"
|
|
45
|
+
}, t('Storage.availability', {
|
|
46
|
+
smart_count: (humanDiskQuota - humanDiskUsage).toFixed(2)
|
|
47
|
+
})));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default StorageProgress;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default Storage;
|
|
2
|
+
declare function Storage({ onlyDesktop }: {
|
|
3
|
+
onlyDesktop: any;
|
|
4
|
+
}): JSX.Element | null;
|
|
5
|
+
declare namespace Storage {
|
|
6
|
+
namespace propTypes {
|
|
7
|
+
const onlyDesktop: PropTypes.Requireable<boolean>;
|
|
8
|
+
}
|
|
9
|
+
namespace defaultProps {
|
|
10
|
+
const onlyDesktop_1: boolean;
|
|
11
|
+
export { onlyDesktop_1 as onlyDesktop };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useInstanceInfo } from 'cozy-client';
|
|
4
|
+
import { shouldDisplayOffers } from 'cozy-client/dist/models/instance';
|
|
5
|
+
import { isFlagshipApp } from 'cozy-device-helper';
|
|
6
|
+
import StorageButton from "cozy-ui/transpiled/react/Storage/StorageButton";
|
|
7
|
+
import StorageProgress from "cozy-ui/transpiled/react/Storage/StorageProgress";
|
|
8
|
+
import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
9
|
+
|
|
10
|
+
var Storage = function Storage(_ref) {
|
|
11
|
+
var onlyDesktop = _ref.onlyDesktop;
|
|
12
|
+
|
|
13
|
+
var _useBreakpoints = useBreakpoints(),
|
|
14
|
+
isDesktop = _useBreakpoints.isDesktop,
|
|
15
|
+
isMobile = _useBreakpoints.isMobile;
|
|
16
|
+
|
|
17
|
+
var instanceInfo = useInstanceInfo();
|
|
18
|
+
if (onlyDesktop && !isDesktop) return null;
|
|
19
|
+
var showStorageButton = instanceInfo.isLoaded && !isFlagshipApp() && !isMobile && shouldDisplayOffers(instanceInfo);
|
|
20
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StorageProgress, null), showStorageButton && /*#__PURE__*/React.createElement(StorageButton, {
|
|
21
|
+
className: "u-mt-1"
|
|
22
|
+
}));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
Storage.propTypes = {
|
|
26
|
+
/** Component enabled only for desktop. Using `false` will enable it for mobile and tablet also. */
|
|
27
|
+
onlyDesktop: PropTypes.bool
|
|
28
|
+
};
|
|
29
|
+
Storage.defaultProps = {
|
|
30
|
+
onlyDesktop: true
|
|
31
|
+
};
|
|
32
|
+
export default Storage;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var en = {
|
|
2
|
+
Storage: {
|
|
3
|
+
title: "Storage",
|
|
4
|
+
availability: "%{smart_count} GB available",
|
|
5
|
+
increase: "Increase the space"
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var fr = {
|
|
9
|
+
Storage: {
|
|
10
|
+
title: "Stockage",
|
|
11
|
+
availability: "%{smart_count} Go disponible",
|
|
12
|
+
increase: "Augmenter l'espace"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export var locales = {
|
|
16
|
+
en: en,
|
|
17
|
+
fr: fr
|
|
18
|
+
};
|
|
@@ -12,11 +12,11 @@ declare var _default: React.ComponentType<Pick<Pick<PropTypes.InferProps<{
|
|
|
12
12
|
component: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
13
13
|
/** placement for the popover */
|
|
14
14
|
placement: PropTypes.Requireable<string>;
|
|
15
|
-
}>, "disabled" | "
|
|
15
|
+
}>, "disabled" | "component" | "placement">> & Partial<Pick<{
|
|
16
16
|
disabled: boolean;
|
|
17
17
|
component: null;
|
|
18
18
|
placement: string;
|
|
19
|
-
}, never>>, "disabled" | "
|
|
19
|
+
}, never>>, "disabled" | "component" | "placement"> & import("@material-ui/styles/withStyles/withStyles").StyledComponentProps<"root" | "paper">>;
|
|
20
20
|
export default _default;
|
|
21
21
|
export { MenuButton };
|
|
22
22
|
import PropTypes from "prop-types";
|