Commit graph

44 commits

Author SHA1 Message Date
Subho
ddcf092678 Add empty dependency array to useEffect hook
This limits the file watch listener to only attach once and not on every
render which is unnecessary.
2024-07-12 15:33:11 +02:00
Martin Pitt
745b4ab8e8 Convert to TypeScript
This needs the usual "I know the `app` element exists" annotation, plus
dealing with a non-existing /etc/hostname (in which case the watch will
return `null`, and we shouldn't poke that into a `string` state).
2024-07-11 11:18:23 -04:00
Martin Pitt
4bbb291281 Convert Application to a functional component
This makes properties and state type-safe, i.e. work better for
TypeScript projects.

Also close the file watch properly after the component unmounts. That
should never happen in practice for *this case*, but this is
example/model code, so let's be correct.
2024-07-11 11:18:23 -04:00
Martin Pitt
6af3331d7a Sort imports 2024-07-11 11:18:23 -04:00
Martin Pitt
39e0f576ca package.json: Update to React 18
Update to the new root creation function.
2023-07-18 11:49:55 +02:00
Katerina Koukiou
12a648b6e4 patternfly-5-overrides should be auto-imported by the page.scss file
page.scss sould be imported by all pages.
2023-05-25 22:42:37 +02:00
Martin Pitt
dc5a514625 Drop obsolete pf-m-redhat-font class 2023-05-24 08:58:49 +02:00
Cockpit Project
b2bdaac5b2 Makefile: Update Cockpit lib to 947f1753867e3924b9617aaace936225
Update to PF5 and the new cockpit lib API.

Closes #646
2023-05-04 15:24:01 +02:00
Subho
1c30b49d3d
Move from webpack to esbuild bundler 2023-04-12 10:23:20 +02:00
Katerina Koukiou
d2e6145ae1 Use whole path in patternfly imports
Otherwise we rely on treeshaking mechanisms to remove unused code, thus
making our bundle size more vulnerable to bundler's ability to drop dead
code.
2023-02-23 16:36:08 +01:00
shawly
681366e990 Add dark-theme-support
Fixes #610
2023-02-13 07:45:49 +01:00
Martin Pitt
b3a9565668 build: don't move pkg/lib/ to src/lib/
Keep pkg/lib in the same location as it is in the cockpit repository,
and adjust the include path accordingly.

This makes the production of the .pot file somewhat more deterministic:
previously, it would either include or not include the strings from
pkg/lib depending on if it had been checked out or not.  Now it never
includes them.

Cherry-picked from cockpit-podman commit a70630be2139a.
2022-06-30 09:49:07 +02:00
Martin Pitt
67c1c065e9 package.json: Drop core-js
starter-kit does not use it directly, and none of our derived projects
have it.
2021-11-29 10:58:57 +01:00
Martin Pitt
4171293c48 Drop unused version numbers from package.json and manifest
This field was introduced in
https://github.com/cockpit-project/cockpit/pull/4964 as "purely
informational for now", and isn't even parsed by cockpit.

package.json's version would only be relevant for publishing NPM
modules, but cockpit pages are not that.

Neither starter-kit itself nor our derived projects like cockpit-podman
or cockpit-composer have ever maintained these two fields, so just get
rid of them.

This makes the git tag the single source of truth for the version
number.

Fixes #200
2021-02-25 07:50:55 +01:00
Martin Pitt
bb06422996
Use Cockpit webpack helpers from cockpit.git
Drop the cockpit-po-plugin.js and sassc-loader.js code copies, and check
them out from a stable cockpit tag, similarly to how we already get the
PatternFly CSS.
2021-01-22 16:04:35 +01:00
Martin Pitt
e418cba057 cockpit-po-plugin: Fix crash with plural forms
Declare the `pos` variable. Fixes regression introduced in commit
7f6ef51c12.

Add plural forms to German translations to exercise this code path.
2021-01-07 08:53:23 +01:00
Martin Pitt
7f6ef51c12
Build translations with webpack
Convert the `po2json` script into a webpack plugin, and integrate the
(now trivial) po.empty.js template.

This is the last step for building the entire dist/ directory with
`npm run build` (i.e. a tool that web developers are familiar with),
and not having a split webpack+make toolchain any more.
2021-01-05 14:52:59 +01:00
Martin Pitt
bb15952fc4 Simplify po.js inclusion
There is no need to jump between directories and even invoke a glob --
the po.<LANG>.js files are right next to index.js.
2021-01-04 14:01:59 +01:00
Martin Pitt
50ef8a9362
webpack: Show sassc errors
`stdio` is not a valid value for the `stdio` option. This led to sassc's
stdout/err to be hidden, and thus it did not show error messages.

Closes #403

[1] https://nodejs.org/api/child_process.html#child_process_options_stdio
2020-12-16 17:49:02 +01:00
Martin Pitt
233b5cfe04 Use sassc instead of node-sass
node-sass is a compiled ELF module, which is problematic for
distributions that want to rebuild everything from source. The sassc CLI
program is packaged everywhere, and both use the same libsass library.

So drop node-sass and sass-loader, and replace it with a simple loader
wrapper around sassc.

This also saves 122 npm packages (16 MB in node_modules/).

Closes #382
2020-10-28 14:49:52 +01:00
Martin Pitt
6f8cd78783 Use standard "translate" marker in HTML
Cockpit's test-static-code complains about `translatable`, so let's use
the correct attribute to avoid spreading it further.
2020-09-29 13:50:31 +03:00
Martin Pitt
080b20af94
Ensure application CSS has priority over library CSS
Import our application CSS as the very last thing, so that it can
properly override  PatternFly variables. Before, our application CSS
could land in the first third of dist/index.css *before* PatternFly's
definitions, so that the latter overrode the former [1].

This is a long-standing bug in mini-css-extract-plugin ([2] and
countless things that point to it) with `NODE_ENV=production` builds.

As a workaround, make sure that app.scss is the absolutely last imported
CSS, instead of "almost last". It is still conceptually correct for the
application CSS to be able to override patternfly-4-overrides.scss.

Closes #362
[1] https://github.com/martinpitt/performance-graphs/issues/10
[2] https://github.com/webpack-contrib/mini-css-extract-plugin/issues/188
2020-09-08 18:53:12 +02:00
Katerina Koukiou
203604a463 Copy patternfly import files from cockpit project automatically
Closes #357
2020-09-08 17:14:34 +02:00
Martin Pitt
2bb8e01d2d
Port to PatternFly 4.x
Closes #343
2020-07-21 10:33:48 +02:00
Katerina Koukiou
96514e279e
main: Stop importing patternfly.css
* Stop importing cockpit's base1/patternfly.css

This is deprecated API and will be dropped at some point, in favor
of projects shipping their own CSS.

Install and import the styles from PF4 now.

* Use webpack based string replacement for removing the font-face rules from PF4

Doing the seddery in Makefile breaks `npm run build`, webpack watching,
and is generally brittle.
Do the font replacement hacking with `string-replace-loader`, which fits into webpack much more nicely.

There is still some potential simplification by not duplicating the
entire scss loader chain.

Co-authored-by: Martin Pitt <martin@piware.de>

Closes #315
2020-05-28 10:01:31 +02:00
Martin Pitt
8fab928dcb Update babel to 7.5, and actually enable polyfills
@babel/polyfill is deprecated in ≥ 7.4 [1], and we never actually used
it as we forgot to import it [2]. Move to core-js/stable.

[1] https://babeljs.io/blog/2019/03/19/7.4.0#migration-from-core-js-2
[2] https://babeljs.io/docs/en/babel-polyfill#usage-in-node-browserify-webpack
2019-07-17 17:43:01 +02:00
Martin Pitt
1fc1923021 Rename *.es6 to *.js
*.es6 isn't standard naming, that was just an old cockpit-ism. All files
are treated as ES6.
2019-07-17 17:43:01 +02:00
Martin Pitt
077eba3ede Update to current eslint
This has a new rule `quote-props`, adjust the code accordingly:

    29:24  error  Unnecessarily quoted property 'hostname' found  quote-props
    32:29  error  Unnecessarily quoted property 'hostname' found  quote-props
2019-07-17 17:43:01 +02:00
Bogdan Mustiata
2a2f99b6f0 React to hostname changes
Closes #94
2019-01-29 12:18:43 +01:00
Martin Pitt
8a73531374 Use full React instead of react-lite
This is the direction we are going in Cockpit, as react-lite falls
behind with API development and debuggability.

Closes #43
2018-08-29 00:40:16 +02:00
Martin Pitt
9fa5c6ab05 Properly initialize state of Application
This will otherwise crash with React 16.
2018-08-29 00:40:16 +02:00
Martin Pitt
133badfa3d Enable a lot of eslint options and plugins
Taken rules from Cockpit, which have been proven to be effective for
finding bugs and keeping clean code, and sensible (not taking
unreasonable effort to satisfy).

Fix code layout in app.jsx accordingly.

Closes #39
2018-08-28 22:57:52 +02:00
Martin Pitt
3922333029 Use eslint for everything
eslint is much more powerful and flexible than jshint, and we don't want
to promote writing new projects with pre-ES6 code.

As a side effect, this also avoids downloading PhantomJS (see
https://github.com/jshint/jshint/issues/3318), thereby cutting down
node_modules/ from 470 MB to 210 MB.
2018-08-28 22:57:52 +02:00
Lars Karlitski
7260f5c01f Add scss example
Closes #26
2018-06-22 11:15:57 +02:00
Martin Pitt
7ce7b2b40b Add i18n support
Make the "Running on.." string translatable and copy the extraction and
conversion of JSX and PO files from Cockpit.
2018-06-19 14:40:45 +02:00
Martin Pitt
1edb6a070b Remove some instances of "starter kit"
Rename some files and change some identifiers to be neutral to the
application name. This makes it simpler to change everything to a proper
name when cloning this project.

Document in the README how to find the remaining places to change.

Closes #20
2018-05-04 19:19:29 +02:00
Lars Karlitski
fb3ce721b2 Use proper es6 import syntax 2017-10-18 19:12:56 +02:00
Lars Karlitski
8ff4b33bb5 Clean up StarterKit view
And show the contents of `/etc/hostname` to make sure cockpit.js is
loaded correctly.
2017-10-18 16:42:54 +02:00
Lars Karlitski
ce7a2d3870 Remove the index.js indirection
Make index.es6 the main entry point.
2017-10-18 16:42:54 +02:00
Lars Karlitski
dd765787e8 Remove all remaining mentions of "subscriptions" 2017-10-18 16:42:54 +02:00
Dominik Perpeet
a01820e565 Add more sample content to subscriptions page 2017-07-26 10:33:14 +02:00
Lars Karlitski
e14982020a Add Vagrantfile
A simple Vagrant VM based on fedora 25 cloud. It syncs `dist` to
`/usr/local/share/cockpit/<dirname>` on the VM.

Also decrease the minimum required version in `manifest.json` to match
the one that's currently in fedora 25.
2017-07-11 17:13:10 +02:00
Dominik Perpeet
2f49b57064 Add sample page 2017-06-20 07:41:52 -04:00
Sean Toner
811e3eebe0 initial commit. Created a basic webpack.config.js file, some basic .babelrc settings, and some notes on the build 2017-06-20 07:41:52 -04:00