Skip to content

Commit d43894e

Browse files
authored
feat: rework web header for mobile, add new settings and raw manifest button (verdaccio#3129)
* feat: rework header, dialogs and new raw mode * chore: add test for raw button and hide download tarball * chore: add test hide footer * chore: add docs to config files * chore: add changeset * chore: enable raw by default
1 parent 8ea7129 commit d43894e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2736
-830
lines changed

.changeset/orange-flowers-cover.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
'@verdaccio/config': minor
3+
'@verdaccio/types': minor
4+
'@verdaccio/ui-theme': minor
5+
---
6+
7+
feat: rework web header for mobile, add new settings and raw manifest button
8+
9+
### New set of variables to hide features
10+
11+
Add set of new variables that allow hide different parts of the UI, buttons, footer or download tarballs. _All are
12+
enabled by default_.
13+
14+
```yaml
15+
# login: true <-- already exist but worth the reminder
16+
# showInfo: true
17+
# showSettings: true
18+
# In combination with darkMode you can force specific theme
19+
# showThemeSwitch: true
20+
# showFooter: true
21+
# showSearch: true
22+
# showDownloadTarball: true
23+
```
24+
25+
> If you disable `showThemeSwitch` and force `darkMode: true` the local storage settings would be
26+
> ignored and force all themes to the one in the configuration file.
27+
28+
Future could be extended to
29+
30+
### Raw button to display manifest package
31+
32+
A new experimental feature (enabled by default), button named RAW to be able navigate on the package manifest directly on the ui, kudos to [react-json-view](https://www.npmjs.com/package/react-json-view) that allows an easy integration, not configurable yet until get more feedback.
33+
34+
```yaml
35+
showRaw: true
36+
```
37+
38+
#### Rework header buttons
39+
40+
- The header has been rework, the mobile was not looking broken.
41+
- Removed info button in the header and moved to a dialog
42+
- Info dialog now contains more information about the project, license and the aid content for Ukrania now is inside of the info modal.
43+
- Separate settings and info to avoid collapse too much info (for mobile still need some work)

packages/config/src/conf/default.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ web:
2020
# convert your UI to the dark side
2121
# darkMode: true
2222
# html_cache: true
23+
# by default all features are displayed
24+
# login: true
25+
# showInfo: true
26+
# showSettings: true
27+
# In combination with darkMode you can force specific theme
28+
# showThemeSwitch: true
29+
# showFooter: true
30+
# showSearch: true
31+
# showRaw: true
32+
# showDownloadTarball: true
2333
# HTML tags injected after manifest <scripts/>
2434
# scriptsBodyAfter:
2535
# - '<script type="text/javascript" src="https://my.company.com/customJS.min.js"></script>'

packages/config/src/conf/docker.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ web:
2626
# convert your UI to the dark side
2727
# darkMode: true
2828
# html_cache: true
29+
# by default all features are displayed
30+
# login: true
31+
# showInfo: true
32+
# showSettings: true
33+
# In combination with darkMode you can force specific theme
34+
# showThemeSwitch: true
35+
# showFooter: true
36+
# showSearch: true
37+
# showRaw: true
38+
# showDownloadTarball: true
2939
# HTML tags injected after manifest <scripts/>
3040
# scriptsBodyAfter:
3141
# - '<script type="text/javascript" src="https://my.company.com/customJS.min.js"></script>'

packages/core/types/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ declare module '@verdaccio/types' {
4343
// deprecated
4444
basename?: string;
4545
scope?: string;
46+
showInfo?: boolean;
47+
showSettings?: boolean;
48+
showSearch?: boolean;
49+
showFooter?: boolean;
50+
showThemeSwitch?: boolean;
51+
showDownloadTarball?: boolean;
52+
showRaw?: boolean;
4653
base: string;
4754
primaryColor?: string;
4855
version?: string;

packages/plugins/ui-theme/jest/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = Object.assign({}, config, {
3030
'\\.(png)$': '<rootDir>/jest/identity.js',
3131
'\\.(svg)$': '<rootDir>/jest/unit/empty.ts',
3232
'\\.(jpg)$': '<rootDir>/jest/unit/empty.ts',
33+
'\\.(md)$': '<rootDir>/jest/unit/empty-string.ts',
3334
'github-markdown-css': '<rootDir>/jest/identity.js',
3435
// note: this section has to be on sync with webpack configuration
3536
'verdaccio-ui/components/(.*)': '<rootDir>/src/components/$1',
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 'empty string module';

packages/plugins/ui-theme/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"node-mocks-http": "1.11.0",
5858
"normalize.css": "8.0.1",
5959
"react-markdown": "8.0.0",
60+
"react-json-view": "1.21.3",
6061
"remark-gfm": "3.0.1",
6162
"optimize-css-assets-webpack-plugin": "6.0.1",
6263
"ora": "5.4.1",
@@ -71,6 +72,7 @@
7172
"react-redux": "7.2.6",
7273
"redux": "4.1.2",
7374
"rimraf": "3.0.2",
75+
"raw-loader": "4.0.2",
7476
"msw": "0.36.5",
7577
"style-loader": "3.3.1",
7678
"stylelint": "14.6.0",

packages/plugins/ui-theme/src/App/App.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,19 @@ describe('<App />', () => {
118118
expect(store.getState().packages.response).toHaveLength(1);
119119
}, 10000);
120120
});
121+
122+
describe('footer', () => {
123+
test('should display the Header component', () => {
124+
renderWithStore(<App />, store);
125+
expect(screen.getByTestId('footer')).toBeInTheDocument();
126+
});
127+
128+
test('should not display the Header component', () => {
129+
window.__VERDACCIO_BASENAME_UI_OPTIONS = {
130+
showFooter: false,
131+
};
132+
renderWithStore(<App />, store);
133+
expect(screen.queryByTestId('footer')).toBeFalsy();
134+
});
135+
});
121136
});

packages/plugins/ui-theme/src/App/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Loading from 'verdaccio-ui/components/Loading';
77
import StyleBaseline from 'verdaccio-ui/design-tokens/StyleBaseline';
88
import loadDayJSLocale from 'verdaccio-ui/design-tokens/load-dayjs-locale';
99
import { Theme } from 'verdaccio-ui/design-tokens/theme';
10+
import { useConfig } from 'verdaccio-ui/providers/config';
1011

1112
import '../i18n/config';
1213
import AppRoute, { history } from './AppRoute';
@@ -27,10 +28,11 @@ const StyledBoxContent = styled(Box)<{ theme?: Theme }>(({ theme }) => ({
2728
}));
2829

2930
const App: React.FC = () => {
31+
const { configOptions } = useConfig();
32+
3033
useEffect(() => {
3134
loadDayJSLocale();
3235
}, []);
33-
3436
return (
3537
<Suspense fallback={<Loading />}>
3638
<StyleBaseline />
@@ -42,7 +44,7 @@ const App: React.FC = () => {
4244
<AppRoute />
4345
</StyledBoxContent>
4446
</Router>
45-
<Footer />
47+
{configOptions.showFooter && <Footer />}
4648
</>
4749
</StyledBox>
4850
</Suspense>

packages/plugins/ui-theme/src/App/Footer/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Footer = () => {
1818
const { t } = useTranslation();
1919
const { configOptions } = useConfig();
2020
return (
21-
<Wrapper>
21+
<Wrapper data-testid="footer">
2222
<Inner>
2323
<Left>
2424
<Trans components={[<Love />]} i18nKey="footer.made-with-love-on" />

0 commit comments

Comments
 (0)