@verdaccio/ui-components 3.0.0-next.0 → 3.0.0-next.2

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/build/components/ActionBar/ActionBar.js +6 -2
  3. package/build/components/ActionBar/ActionBarAction.js +15 -7
  4. package/build/components/Author/Author.js +15 -7
  5. package/build/components/Author/styles.js +7 -23
  6. package/build/components/CopyClipboard/CopyToClipBoard.js +11 -10
  7. package/build/components/Deprecated/Deprecated.js +11 -19
  8. package/build/components/Engines/Engines.js +7 -7
  9. package/build/components/Install/Install.js +7 -4
  10. package/build/components/Install/InstallListItem.js +25 -37
  11. package/build/components/Link/Link.js +5 -2
  12. package/build/components/Package/Package.js +14 -7
  13. package/build/components/RawViewer/RawViewer.js +0 -1
  14. package/build/components/Readme/Readme.js +11 -26
  15. package/build/components/Readme/Readme.js.map +1 -1
  16. package/build/components/Readme/ReadmeDark.js +46 -0
  17. package/build/components/Readme/ReadmeLight.js +46 -0
  18. package/build/components/Readme/github-markdown-dark.css +1015 -0
  19. package/build/components/Readme/github-markdown-light.css +1014 -0
  20. package/build/components/SettingsMenu/SettingsMenu.js +16 -3
  21. package/build/components/SideBarTittle/SideBarTittle.js +5 -4
  22. package/build/components/Versions/HistoryList.js +32 -4
  23. package/build/components/Versions/Versions.js +16 -2
  24. package/build/components/Versions/__partials__/data.json +1 -0
  25. package/build/components/Versions/__partials__/deprecated-versions.json +175 -0
  26. package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js +1 -0
  27. package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js +2 -1
  28. package/build/src/__mocks__/react-markdown.d.ts +2 -2
  29. package/build/src/components/Author/styles.d.ts +0 -4
  30. package/build/src/components/CopyClipboard/CopyToClipBoard.d.ts +1 -1
  31. package/build/src/components/Deprecated/Deprecated.d.ts +0 -1
  32. package/build/src/components/Heading/Heading.d.ts +1 -1
  33. package/build/src/components/Icons/DevsIcons/CommonJS.d.ts +2 -2
  34. package/build/src/components/Icons/DevsIcons/ES6Module.d.ts +2 -2
  35. package/build/src/components/Icons/DevsIcons/Git.d.ts +2 -2
  36. package/build/src/components/Icons/DevsIcons/NodeJS.d.ts +2 -2
  37. package/build/src/components/Icons/DevsIcons/TypeScript.d.ts +2 -2
  38. package/build/src/components/Icons/Earth.d.ts +2 -2
  39. package/build/src/components/Icons/FileBinary.d.ts +2 -2
  40. package/build/src/components/Icons/Law.d.ts +2 -2
  41. package/build/src/components/Icons/License.d.ts +2 -2
  42. package/build/src/components/Icons/Managers/Npm.d.ts +2 -2
  43. package/build/src/components/Icons/Managers/Pnpm.d.ts +2 -2
  44. package/build/src/components/Icons/Managers/Yarn.d.ts +2 -2
  45. package/build/src/components/Icons/SvgIcon.d.ts +1 -1
  46. package/build/src/components/Icons/Time.d.ts +2 -2
  47. package/build/src/components/Icons/Version.d.ts +2 -2
  48. package/build/src/components/Install/InstallListItem.d.ts +2 -0
  49. package/build/src/components/Link/Link.d.ts +1 -1
  50. package/build/src/components/LoginDialog/LoginDialog.stories.d.ts +2 -2
  51. package/build/src/components/LoginDialog/LoginDialogForm.d.ts +1 -1
  52. package/build/src/components/LoginDialog/LoginDialogFormError.d.ts +1 -1
  53. package/build/src/components/MenuItem/MenuItem.d.ts +1 -1
  54. package/build/src/components/Readme/Readme.d.ts +0 -1
  55. package/build/src/components/Readme/ReadmeDark.d.ts +5 -0
  56. package/build/src/components/Readme/ReadmeLight.d.ts +5 -0
  57. package/build/src/components/Search/AutoComplete/styles.d.ts +1 -1
  58. package/build/src/components/Search/Search.stories.d.ts +2 -2
  59. package/build/src/components/Search/styles.d.ts +1 -1
  60. package/build/src/components/TextField/TextField.d.ts +1 -1
  61. package/build/src/components/Versions/HistoryList.d.ts +1 -0
  62. package/build/src/sections/Footer/Footer.d.ts +2 -2
  63. package/build/src/sections/Header/LanguageSwitch.d.ts +2 -2
  64. package/build/src/sections/Header/styles.d.ts +1 -1
  65. package/build/src/store/models/login.d.ts +1 -0
  66. package/build/src/types/packageMeta.d.ts +1 -0
  67. package/build/src/utils/index.d.ts +1 -0
  68. package/build/src/utils/loadable.d.ts +2 -2
  69. package/build/src/utils/token.d.ts +1 -0
  70. package/build/store/models/download.js +0 -1
  71. package/build/store/models/login.js +17 -7
  72. package/build/utils/index.js +22 -0
  73. package/build/utils/token.js +35 -0
  74. package/package.json +14 -11
  75. package/src/components/ActionBar/ActionBar.stories.tsx +1 -1
  76. package/src/components/ActionBar/ActionBar.test.tsx +17 -10
  77. package/src/components/ActionBar/ActionBar.tsx +16 -12
  78. package/src/components/ActionBar/ActionBarAction.tsx +15 -10
  79. package/src/components/Author/Author.tsx +13 -4
  80. package/src/components/Author/styles.ts +0 -6
  81. package/src/components/CopyClipboard/CopyToClipBoard.tsx +4 -3
  82. package/src/components/Deprecated/Deprecated.tsx +6 -19
  83. package/src/components/Engines/Engines.tsx +5 -5
  84. package/src/components/Install/Install.test.tsx +29 -37
  85. package/src/components/Install/Install.tsx +15 -4
  86. package/src/components/Install/InstallListItem.tsx +46 -30
  87. package/src/components/Link/Link.tsx +10 -3
  88. package/src/components/Package/Package.tsx +10 -2
  89. package/src/components/RawViewer/RawViewer.tsx +1 -6
  90. package/src/components/Readme/Readme.tsx +10 -21
  91. package/src/components/Readme/ReadmeDark.tsx +32 -0
  92. package/src/components/Readme/ReadmeLight.tsx +32 -0
  93. package/src/components/Readme/github-markdown-dark.css +1015 -0
  94. package/src/components/Readme/github-markdown-light.css +1014 -0
  95. package/src/components/SettingsMenu/SettingsMenu.tsx +23 -4
  96. package/src/components/SideBarTittle/SideBarTittle.tsx +1 -0
  97. package/src/components/Versions/HistoryList.tsx +29 -1
  98. package/src/components/Versions/Versions.test.tsx +16 -1
  99. package/src/components/Versions/Versions.tsx +17 -1
  100. package/src/components/Versions/__partials__/data.json +1 -0
  101. package/src/components/Versions/__partials__/deprecated-versions.json +175 -0
  102. package/src/providers/AppConfigurationProvider/AppConfigurationProvider.tsx +1 -0
  103. package/src/providers/PersistenceSettingProvider/PersistenceSettingProvider.tsx +2 -0
  104. package/src/store/models/download.ts +0 -1
  105. package/src/store/models/login.test.ts +38 -0
  106. package/src/store/models/login.ts +12 -6
  107. package/src/types/packageMeta.ts +1 -0
  108. package/src/utils/index.ts +1 -0
  109. package/src/utils/token.test.ts +54 -0
  110. package/src/utils/token.ts +33 -0
@@ -2,5 +2,5 @@ import React from 'react';
2
2
  export declare const CustomRouterLink: import("@emotion/styled").StyledComponent<import("react-router-dom").LinkProps<unknown> & React.RefAttributes<HTMLAnchorElement> & {
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  }, {}, {}>;
5
- declare const Link: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<HTMLAnchorElement>>;
5
+ declare const Link: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
6
6
  export default Link;
@@ -1,10 +1,10 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
6
  export declare const OpenLoginDialog: {
7
- render: (args: any) => JSX.Element;
7
+ render: (args: any) => React.JSX.Element;
8
8
  argTypes: {
9
9
  open: boolean;
10
10
  };
@@ -8,5 +8,5 @@ interface Props {
8
8
  onSubmit: (formValues: FormValues) => void;
9
9
  error?: LoginError;
10
10
  }
11
- declare const LoginDialogForm: React.MemoExoticComponent<({ onSubmit, error }: Props) => JSX.Element>;
11
+ declare const LoginDialogForm: React.MemoExoticComponent<({ onSubmit, error }: Props) => React.JSX.Element>;
12
12
  export default LoginDialogForm;
@@ -7,5 +7,5 @@ export interface FormValues {
7
7
  interface Props {
8
8
  error: LoginError;
9
9
  }
10
- declare const LoginDialogFormError: React.MemoExoticComponent<({ error }: Props) => JSX.Element>;
10
+ declare const LoginDialogFormError: React.MemoExoticComponent<({ error }: Props) => React.JSX.Element>;
11
11
  export default LoginDialogFormError;
@@ -5,5 +5,5 @@ type MenuItemRef = HTMLElementTagNameMap[HTMLElementTagName];
5
5
  interface Props extends Omit<MenuItemProps, 'component'> {
6
6
  component?: HTMLElementTagName;
7
7
  }
8
- declare const MenuItem: React.ForwardRefExoticComponent<Pick<Props, keyof Props> & React.RefAttributes<MenuItemRef>>;
8
+ declare const MenuItem: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<MenuItemRef>>;
9
9
  export default MenuItem;
@@ -1,4 +1,3 @@
1
- import 'github-markdown-css';
2
1
  import 'highlight.js/styles/default.css';
3
2
  import React from 'react';
4
3
  import { Props } from './types';
@@ -0,0 +1,5 @@
1
+ import 'highlight.js/styles/default.css';
2
+ import React from 'react';
3
+ import { Props } from './types';
4
+ declare const Readme: React.FC<Props>;
5
+ export default Readme;
@@ -0,0 +1,5 @@
1
+ import 'highlight.js/styles/default.css';
2
+ import React from 'react';
3
+ import { Props } from './types';
4
+ declare const Readme: React.FC<Props>;
5
+ export default Readme;
@@ -6,7 +6,7 @@ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
6
6
  theme?: import("@emotion/react").Theme | undefined;
7
7
  as?: import("react").ElementType<any> | undefined;
8
8
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
9
- export declare const StyledTextField: import("@emotion/styled").StyledComponent<(((Pick<import("@mui/material").OutlinedTextFieldProps, keyof import("@mui/material").OutlinedTextFieldProps> | Pick<import("@mui/material").FilledTextFieldProps, keyof import("@mui/material").FilledTextFieldProps> | Pick<import("@mui/material").StandardTextFieldProps, keyof import("@mui/material").StandardTextFieldProps>) & import("react").RefAttributes<HTMLDivElement>) & {
9
+ export declare const StyledTextField: import("@emotion/styled").StyledComponent<(((Omit<import("@mui/material").OutlinedTextFieldProps, "ref"> | Omit<import("@mui/material").FilledTextFieldProps, "ref"> | Omit<import("@mui/material").StandardTextFieldProps, "ref">) & import("react").RefAttributes<HTMLDivElement>) & {
10
10
  theme?: import("@emotion/react").Theme | undefined;
11
11
  }) & {
12
12
  theme?: import("@mui/material").Theme | undefined;
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
6
  export declare const SearchByQuery: {
7
- render: (args: any) => JSX.Element;
7
+ render: (args: any) => React.JSX.Element;
8
8
  };
@@ -2,7 +2,7 @@
2
2
  export interface InputFieldProps {
3
3
  color: string;
4
4
  }
5
- export declare const StyledTextField: import("@emotion/styled").StyledComponent<(((Pick<import("@mui/material").OutlinedTextFieldProps, keyof import("@mui/material").OutlinedTextFieldProps> | Pick<import("@mui/material").FilledTextFieldProps, keyof import("@mui/material").FilledTextFieldProps> | Pick<import("@mui/material").StandardTextFieldProps, keyof import("@mui/material").StandardTextFieldProps>) & import("react").RefAttributes<HTMLDivElement>) & {
5
+ export declare const StyledTextField: import("@emotion/styled").StyledComponent<(((Omit<import("@mui/material").OutlinedTextFieldProps, "ref"> | Omit<import("@mui/material").FilledTextFieldProps, "ref"> | Omit<import("@mui/material").StandardTextFieldProps, "ref">) & import("react").RefAttributes<HTMLDivElement>) & {
6
6
  theme?: import("@emotion/react").Theme | undefined;
7
7
  }) & {
8
8
  theme?: import("@mui/material").Theme | undefined;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- declare const TextField: React.ForwardRefExoticComponent<(Pick<import("@mui/material/TextField").OutlinedTextFieldProps, keyof import("@mui/material/TextField").OutlinedTextFieldProps> | Pick<import("@mui/material/TextField").FilledTextFieldProps, keyof import("@mui/material/TextField").FilledTextFieldProps> | Pick<import("@mui/material/TextField").StandardTextFieldProps, keyof import("@mui/material/TextField").StandardTextFieldProps>) & React.RefAttributes<HTMLDivElement>>;
2
+ declare const TextField: React.ForwardRefExoticComponent<(Omit<import("@mui/material/TextField").OutlinedTextFieldProps, "ref"> | Omit<import("@mui/material/TextField").FilledTextFieldProps, "ref"> | Omit<import("@mui/material/TextField").StandardTextFieldProps, "ref">) & React.RefAttributes<HTMLDivElement>>;
3
3
  export default TextField;
@@ -5,5 +5,6 @@ interface Props {
5
5
  packageName: string;
6
6
  time: Time;
7
7
  }
8
+ export declare function filterDeprecated(versions: Versions): {};
8
9
  declare const VersionsHistoryList: React.FC<Props>;
9
10
  export default VersionsHistoryList;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare const Footer: () => JSX.Element;
1
+ import React from 'react';
2
+ declare const Footer: () => React.JSX.Element;
3
3
  export default Footer;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare const CardSelected: import("@emotion/styled").StyledComponent<any, {}, {}>;
3
3
  export declare const CardUnSelected: import("@emotion/styled").StyledComponent<any, {}, {}>;
4
- declare const LanguageSwitch: () => JSX.Element;
4
+ declare const LanguageSwitch: () => React.JSX.Element;
5
5
  export default LanguageSwitch;
@@ -27,7 +27,7 @@ export declare const SearchWrapper: import("@emotion/styled").StyledComponent<{
27
27
  as?: import("react").ElementType<any> | undefined;
28
28
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
29
29
  export declare const NavBar: import("@emotion/styled").StyledComponent<any, {}, {}>;
30
- export declare const StyledLink: import("@emotion/styled").StyledComponent<Pick<any, string | number | symbol> & import("react").RefAttributes<HTMLAnchorElement> & {
30
+ export declare const StyledLink: import("@emotion/styled").StyledComponent<Omit<any, "ref"> & import("react").RefAttributes<HTMLAnchorElement> & {
31
31
  theme?: import("@emotion/react").Theme | undefined;
32
32
  } & {
33
33
  theme?: import("@mui/material").Theme | undefined;
@@ -13,6 +13,7 @@ export type LoginResponse = {
13
13
  export type LoginBody = {
14
14
  error?: LoginError;
15
15
  } & LoginResponse;
16
+ export declare function getDefaultUserState(): LoginBody;
16
17
  /**
17
18
  *
18
19
  * @category Model
@@ -71,6 +71,7 @@ export interface Version {
71
71
  license?: string;
72
72
  main?: string;
73
73
  keywords?: string[];
74
+ deprecated?: string;
74
75
  }
75
76
  export interface Author {
76
77
  name?: string;
@@ -3,3 +3,4 @@ export * as utils from './utils';
3
3
  export { getCLIChangePassword, getCLISBerryYamlRegistry, getCLISetConfigRegistry, getCLISetRegistry, } from './cli-utils';
4
4
  export { default as loadable } from './loadable';
5
5
  export { Route } from './routes';
6
+ export * from './token';
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  /**
3
3
  * With the combination of a bundler, enable to code split a package.
4
4
  *
@@ -8,5 +8,5 @@
8
8
  ```
9
9
  @category HOC
10
10
  */
11
- declare const _default: (importCallback: any) => (props: any) => JSX.Element;
11
+ declare const _default: (importCallback: any) => (props: any) => React.JSX.Element;
12
12
  export default _default;
@@ -0,0 +1 @@
1
+ export declare function isTokenExpire(token: string | null): boolean;
@@ -19,7 +19,6 @@ const download = (0, _core.createModel)()({
19
19
  async getTarball({
20
20
  link
21
21
  }) {
22
- // const basePath = state.configuration.config.base;
23
22
  try {
24
23
  const fileStream = await _api.default.request(link, 'GET', {
25
24
  headers: {
@@ -3,9 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.login = exports.HEADERS = void 0;
6
+ exports.HEADERS = void 0;
7
+ exports.getDefaultUserState = getDefaultUserState;
8
+ exports.login = void 0;
7
9
  var _core = require("@rematch/core");
8
10
  var _i18next = _interopRequireDefault(require("i18next"));
11
+ var _utils = require("../../utils");
9
12
  var _api = _interopRequireDefault(require("../api"));
10
13
  var _storage = _interopRequireDefault(require("../storage"));
11
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -13,12 +16,19 @@ const HEADERS = {
13
16
  JSON: 'application/json'
14
17
  };
15
18
  exports.HEADERS = HEADERS;
16
- const token = _storage.default.getItem('token');
17
- const username = _storage.default.getItem('username');
18
- const defaultUserState = {
19
- token,
20
- username
21
- };
19
+ function getDefaultUserState() {
20
+ const token = _storage.default.getItem('token');
21
+ const username = _storage.default.getItem('username');
22
+ const defaultUserState = (0, _utils.isTokenExpire)(token) ? {
23
+ token: null,
24
+ username: null
25
+ } : {
26
+ token,
27
+ username
28
+ };
29
+ return defaultUserState;
30
+ }
31
+ const defaultUserState = getDefaultUserState();
22
32
 
23
33
  /**
24
34
  *
@@ -3,6 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ url: true,
8
+ utils: true,
9
+ getCLIChangePassword: true,
10
+ getCLISBerryYamlRegistry: true,
11
+ getCLISetConfigRegistry: true,
12
+ getCLISetRegistry: true,
13
+ loadable: true,
14
+ Route: true
15
+ };
6
16
  Object.defineProperty(exports, "Route", {
7
17
  enumerable: true,
8
18
  get: function () {
@@ -47,6 +57,18 @@ exports.utils = _utils;
47
57
  var _cliUtils = require("./cli-utils");
48
58
  var _loadable = _interopRequireDefault(require("./loadable"));
49
59
  var _routes = require("./routes");
60
+ var _token = require("./token");
61
+ Object.keys(_token).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
64
+ if (key in exports && exports[key] === _token[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _token[key];
69
+ }
70
+ });
71
+ });
50
72
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
73
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
52
74
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isTokenExpire = isTokenExpire;
7
+ var _jsBase = require("js-base64");
8
+ var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
9
+ var _isString = _interopRequireDefault(require("lodash/isString"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function isTokenExpire(token) {
12
+ if (!(0, _isString.default)(token)) {
13
+ return true;
14
+ }
15
+ const [, payload] = token.split('.');
16
+ if (!payload) {
17
+ return true;
18
+ }
19
+ let exp;
20
+ try {
21
+ exp = JSON.parse(_jsBase.Base64.decode(payload)).exp;
22
+ } catch (error) {
23
+ // eslint-disable-next-line no-console
24
+ console.error('Invalid token:', error, token);
25
+ return true;
26
+ }
27
+ if (!exp || !(0, _isNumber.default)(exp)) {
28
+ return true;
29
+ }
30
+ // Report as expire before (real expire time - 30s)
31
+ const jsTimestamp = exp * 1000 - 30000;
32
+ const expired = Date.now() >= jsTimestamp;
33
+ return expired;
34
+ }
35
+ //# sourceMappingURL=token.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/ui-components",
3
- "version": "3.0.0-next.0",
3
+ "version": "3.0.0-next.2",
4
4
  "description": "theme ui component",
5
5
  "author": "Juan Picado <juanpicado19@gmail.com>",
6
6
  "license": "MIT",
@@ -12,20 +12,21 @@
12
12
  "@emotion/styled": "^11.10.6",
13
13
  "@fontsource/material-icons": "^4.5.4",
14
14
  "@fontsource/roboto": "^4.5.8",
15
- "@mui/icons-material": "5.13.7",
16
- "@mui/material": "5.13.7",
17
- "@mui/styles": "5.13.7",
18
- "@mui/system": "5.13.7",
15
+ "@mui/icons-material": "5.14.13",
16
+ "@mui/material": "5.14.13",
17
+ "@mui/styles": "5.14.13",
18
+ "@mui/system": "5.14.13",
19
19
  "@rematch/core": "2.2.0",
20
20
  "@rematch/loading": "2.1.2",
21
21
  "@rematch/persist": "2.1.2",
22
22
  "country-flag-icons": "1.5.5",
23
23
  "dayjs": "1.11.7",
24
24
  "dompurify": "2.4.5",
25
- "github-markdown-css": "5.2.0",
26
25
  "highlight.js": "11.7.0",
27
26
  "history": "4.10.1",
27
+ "classnames": "2.3.2",
28
28
  "i18next": "20.6.1",
29
+ "js-base64": "3.7.5",
29
30
  "localstorage-memory": "1.0.3",
30
31
  "lodash": "4.17.21",
31
32
  "marked": "4.3.0",
@@ -45,7 +46,7 @@
45
46
  "validator": "13.9.0"
46
47
  },
47
48
  "devDependencies": {
48
- "@babel/core": "^7.20.7",
49
+ "@babel/core": "^7.23.0",
49
50
  "@emotion/babel-plugin": "11.10.6",
50
51
  "@emotion/jest": "11.10.5",
51
52
  "@storybook/addon-actions": "^6.5.15",
@@ -56,15 +57,16 @@
56
57
  "@storybook/manager-webpack5": "^6.5.15",
57
58
  "@storybook/react": "^6.5.15",
58
59
  "@storybook/testing-library": "^0.0.13",
59
- "@testing-library/dom": "8.19.1",
60
- "@testing-library/jest-dom": "5.16.5",
61
- "@testing-library/react": "13.4.0",
60
+ "@testing-library/dom": "9.3.3",
61
+ "@testing-library/jest-dom": "6.1.3",
62
+ "@testing-library/react": "14.0.0",
62
63
  "@types/hast": "^2.0.0",
63
64
  "@types/react-router": "^5.1.20",
64
65
  "@types/unist": "^2.0.0",
65
- "@verdaccio/types": "12.0.0-next.0",
66
+ "@verdaccio/types": "12.0.0-next.1",
66
67
  "babel-loader": "^8.3.0",
67
68
  "mockdate": "3.0.5",
69
+ "typescript": "4.9.4",
68
70
  "msw": "0.49.3"
69
71
  },
70
72
  "msw": {
@@ -77,6 +79,7 @@
77
79
  "type-check": "tsc --noEmit -p tsconfig.build.json",
78
80
  "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
79
81
  "build:js": "babel src/ --out-dir build/ --copy-files --no-copy-ignored --extensions \".ts,.tsx\" --source-maps --ignore \"src/**/*.stories.tsx\" --ignore \"src/**/*.test.tsx\" --ignore \"src/**/*.test.ts\"",
82
+ "watch": "babel src/ --out-dir build/ --watch --copy-files --no-copy-ignored --extensions \".ts,.tsx\" --source-maps --ignore \"src/**/*.stories.tsx\" --ignore \"src/**/*.test.tsx\" --ignore \"src/**/*.test.ts\"",
80
83
  "build": "pnpm run build:js && pnpm run build:types",
81
84
  "start": "start-storybook -p 6006 -s ./public",
82
85
  "build-storybook": "build-storybook"
@@ -20,7 +20,7 @@ const packageMeta = {
20
20
  dist: {
21
21
  fileCount: 0,
22
22
  unpackedSize: 0,
23
- tarball: 'https://registry.verdaccio.org/storybook/-/storybook-0.2.0.tgz',
23
+ tarball: 'https://registry.npmjs.org/verdaccio/-/verdaccio-5.26.0.tgz',
24
24
  },
25
25
  homepage: 'https://verdaccio.org',
26
26
  bugs: {
@@ -1,7 +1,13 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { store } from '../../store/store';
4
- import { cleanup, fireEvent, renderWithStore, screen } from '../../test/test-react-testing-library';
4
+ import {
5
+ cleanup,
6
+ fireEvent,
7
+ renderWithStore,
8
+ screen,
9
+ waitFor,
10
+ } from '../../test/test-react-testing-library';
5
11
  import ActionBar from './ActionBar';
6
12
 
7
13
  const defaultPackageMeta = {
@@ -27,8 +33,10 @@ describe('<ActionBar /> component', () => {
27
33
  });
28
34
 
29
35
  test('should render the component in default state', () => {
30
- const { container } = renderWithStore(<ActionBar packageMeta={defaultPackageMeta} />, store);
31
- expect(container.firstChild).toMatchSnapshot();
36
+ renderWithStore(<ActionBar packageMeta={defaultPackageMeta} />, store);
37
+ expect(screen.getByTestId('download-tarball-btn')).toBeInTheDocument();
38
+ expect(screen.getByTestId('BugReportIcon')).toBeInTheDocument();
39
+ expect(screen.getByTestId('HomeIcon')).toBeInTheDocument();
32
40
  });
33
41
 
34
42
  test('when there is no action bar data', () => {
@@ -45,8 +53,10 @@ describe('<ActionBar /> component', () => {
45
53
  },
46
54
  };
47
55
 
48
- const { container } = renderWithStore(<ActionBar packageMeta={packageMeta} />, store);
49
- expect(container.firstChild).toMatchSnapshot();
56
+ renderWithStore(<ActionBar packageMeta={packageMeta} />, store);
57
+ expect(screen.queryByTestId('download-tarball-btn')).not.toBeInTheDocument();
58
+ expect(screen.queryByTestId('BugReportIcon')).not.toBeInTheDocument();
59
+ expect(screen.queryByTestId('HomeIcon')).not.toBeInTheDocument();
50
60
  });
51
61
 
52
62
  test('when there is a button to download a tarball', () => {
@@ -59,11 +69,10 @@ describe('<ActionBar /> component', () => {
59
69
  expect(screen.getByLabelText('action-bar-action.raw')).toBeTruthy();
60
70
  });
61
71
 
62
- test('when click button to raw manifest open a dialog with viewver', () => {
72
+ test('when click button to raw manifest open a dialog with viewer', async () => {
63
73
  renderWithStore(<ActionBar packageMeta={defaultPackageMeta} showRaw={true} />, store);
64
74
  fireEvent.click(screen.getByLabelText('action-bar-action.raw'));
65
- // TODO: fix this part
66
- // expect(screen.getByTestId('raw-viewver-dialog')).toBeInTheDocument();
75
+ await waitFor(() => expect(screen.getByTestId('rawViewer--dialog')).toBeInTheDocument());
67
76
  });
68
77
 
69
78
  test('should not display download tarball button', () => {
@@ -78,8 +87,6 @@ describe('<ActionBar /> component', () => {
78
87
 
79
88
  test('when there is a button to open an issue', () => {
80
89
  renderWithStore(<ActionBar packageMeta={defaultPackageMeta} />, store);
81
- // TODO: should be visible by text
82
- // expect(screen.getByLabelText('action-bar-action.open-an-issue')).toBeTruthy();
83
90
  expect(screen.getByTestId('BugReportIcon')).toBeInTheDocument();
84
91
  });
85
92
  });
@@ -1,4 +1,6 @@
1
+ /* eslint-disable verdaccio/jsx-spread */
1
2
  import Box from '@mui/material/Box';
3
+ import Stack from '@mui/material/Stack';
2
4
  import React, { useState } from 'react';
3
5
 
4
6
  import { url } from '../../utils';
@@ -40,18 +42,20 @@ const ActionBar: React.FC<Props> = ({ showRaw, showDownloadTarball = true, packa
40
42
 
41
43
  return (
42
44
  <Box alignItems="center" display="flex" marginBottom="14px">
43
- {actions.map((action) => (
44
- <ActionBarAction key={action.type} {...action} />
45
- ))}
46
- {isRawViewerOpen && (
47
- <RawViewer
48
- isOpen={isRawViewerOpen}
49
- onClose={() => {
50
- setIsRawViewerOpen(false);
51
- }}
52
- packageMeta={packageMeta}
53
- />
54
- )}
45
+ <Stack direction="row" spacing={1}>
46
+ {actions.map((action) => (
47
+ <ActionBarAction key={action.type} {...action} />
48
+ ))}
49
+ {isRawViewerOpen && (
50
+ <RawViewer
51
+ isOpen={isRawViewerOpen}
52
+ onClose={() => {
53
+ setIsRawViewerOpen(false);
54
+ }}
55
+ packageMeta={packageMeta}
56
+ />
57
+ )}
58
+ </Stack>
55
59
  </Box>
56
60
  );
57
61
  };
@@ -3,25 +3,21 @@ import BugReportIcon from '@mui/icons-material/BugReport';
3
3
  import DownloadIcon from '@mui/icons-material/CloudDownload';
4
4
  import HomeIcon from '@mui/icons-material/Home';
5
5
  import RawOnIcon from '@mui/icons-material/RawOn';
6
+ import CircularProgress from '@mui/material/CircularProgress';
6
7
  import FabMUI from '@mui/material/Fab';
7
8
  import Tooltip from '@mui/material/Tooltip';
8
9
  import React, { useCallback } from 'react';
9
10
  import { useTranslation } from 'react-i18next';
10
- import { useDispatch } from 'react-redux';
11
+ import { useDispatch, useSelector } from 'react-redux';
11
12
 
12
13
  import { Theme } from '../../Theme';
13
- import { Dispatch } from '../../store/store';
14
+ import { Dispatch, RootState } from '../../store/store';
14
15
  import { Link } from '../Link';
15
16
 
16
17
  export const Fab = styled(FabMUI)<{ theme?: Theme }>(({ theme }) => ({
17
18
  backgroundColor:
18
19
  theme?.palette.mode === 'light' ? theme?.palette.primary.main : theme?.palette.cyanBlue,
19
20
  color: theme?.palette.white,
20
- marginRight: 10,
21
- ':hover': {
22
- color: theme?.palette.mode === 'light' ? theme?.palette.primary.main : theme?.palette.cyanBlue,
23
- background: theme?.palette.white,
24
- },
25
21
  }));
26
22
 
27
23
  type ActionType = 'VISIT_HOMEPAGE' | 'OPEN_AN_ISSUE' | 'DOWNLOAD_TARBALL' | 'RAW_DATA';
@@ -36,6 +32,7 @@ export interface ActionBarActionProps {
36
32
  const ActionBarAction: React.FC<ActionBarActionProps> = ({ type, link, action }) => {
37
33
  const { t } = useTranslation();
38
34
  const dispatch = useDispatch<Dispatch>();
35
+ const isLoading = useSelector((state: RootState) => state?.loading?.models.download);
39
36
 
40
37
  const handleDownload = useCallback(async () => {
41
38
  dispatch.download.getTarball({ link });
@@ -65,9 +62,17 @@ const ActionBarAction: React.FC<ActionBarActionProps> = ({ type, link, action })
65
62
  case 'DOWNLOAD_TARBALL':
66
63
  return (
67
64
  <Tooltip title={t('action-bar-action.download-tarball') as string}>
68
- <Fab data-testid="download-tarball-btn" onClick={handleDownload} size="small">
69
- <DownloadIcon />
70
- </Fab>
65
+ {isLoading ? (
66
+ <CircularProgress sx={{ marginX: 0 }}>
67
+ <Fab data-testid="download-tarball-btn" onClick={handleDownload} size="small">
68
+ <DownloadIcon />
69
+ </Fab>
70
+ </CircularProgress>
71
+ ) : (
72
+ <Fab data-testid="download-tarball-btn" onClick={handleDownload} size="small">
73
+ <DownloadIcon />
74
+ </Fab>
75
+ )}
71
76
  </Tooltip>
72
77
  );
73
78
  case 'RAW_DATA':
@@ -1,11 +1,13 @@
1
+ import { Typography } from '@mui/material';
1
2
  import Avatar from '@mui/material/Avatar';
2
3
  import List from '@mui/material/List';
4
+ import { useTheme } from '@mui/styles';
3
5
  import i18next from 'i18next';
4
6
  import React, { FC } from 'react';
5
7
  import { useTranslation } from 'react-i18next';
6
8
 
7
9
  import { url } from '../../utils';
8
- import { AuthorListItem, AuthorListItemText, StyledText } from './styles';
10
+ import { AuthorListItem, StyledText } from './styles';
9
11
 
10
12
  export function getAuthorName(authorName?: string): string {
11
13
  if (!authorName) {
@@ -26,6 +28,8 @@ export function getAuthorName(authorName?: string): string {
26
28
  const Author: FC<{ packageMeta }> = ({ packageMeta }) => {
27
29
  const { t } = useTranslation();
28
30
 
31
+ const theme = useTheme();
32
+
29
33
  if (!packageMeta) {
30
34
  return null;
31
35
  }
@@ -37,8 +41,13 @@ const Author: FC<{ packageMeta }> = ({ packageMeta }) => {
37
41
  }
38
42
 
39
43
  const { email, name } = author;
40
-
41
- const avatarComponent = <Avatar alt={author.name} src={author.avatar} />;
44
+ const avatarComponent = (
45
+ <Avatar
46
+ alt={author.name}
47
+ src={author.avatar}
48
+ sx={{ width: 40, height: 40, marginRight: theme.spacing(1) }}
49
+ />
50
+ );
42
51
 
43
52
  return (
44
53
  <List subheader={<StyledText variant={'subtitle1'}>{t('sidebar.author.title')}</StyledText>}>
@@ -50,7 +59,7 @@ const Author: FC<{ packageMeta }> = ({ packageMeta }) => {
50
59
  {avatarComponent}
51
60
  </a>
52
61
  )}
53
- {name && <AuthorListItemText primary={getAuthorName(name)} />}
62
+ {name && <Typography variant="subtitle2">{getAuthorName(name)}</Typography>}
54
63
  </AuthorListItem>
55
64
  </List>
56
65
  );
@@ -1,7 +1,6 @@
1
1
  import styled from '@emotion/styled';
2
2
  import { Typography } from '@mui/material';
3
3
  import ListItem from '@mui/material/ListItem';
4
- import ListItemText from '@mui/material/ListItemText';
5
4
 
6
5
  import { Theme } from '../../Theme';
7
6
 
@@ -15,8 +14,3 @@ export const AuthorListItem = styled(ListItem)({
15
14
  backgroundColor: 'transparent',
16
15
  },
17
16
  });
18
-
19
- export const AuthorListItemText = styled(ListItemText)({
20
- padding: '0 10px',
21
- margin: 0,
22
- });