cozy-ui 128.6.0 → 128.7.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 +7 -0
- package/package.json +1 -1
- 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/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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [128.7.0](https://github.com/cozy/cozy-ui/compare/v128.6.0...v128.7.0) (2025-09-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add Storage component ([76c74ed](https://github.com/cozy/cozy-ui/commit/76c74ed))
|
|
7
|
+
|
|
1
8
|
# [128.6.0](https://github.com/cozy/cozy-ui/compare/v128.5.0...v128.6.0) (2025-09-08)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -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
|
|
@@ -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
|
+
};
|