Skip to content

Commit b02eb7c

Browse files
committed
Improve system documentation
1 parent cfcba5c commit b02eb7c

28 files changed

+620
-124
lines changed

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Code of Conduct for STAC-Admin Interface
1+
# STAC-Manager 📡 📄 — Code of Conduct
22

33
## Our Pledge
44

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Contributing to STAC-Admin Interface
1+
# STAC-Manager 📡 📄 — Contributing
22

3-
First off, thank you for considering contributing to the STAC-Admin Interface! People like you make the open-source community a great place to learn, inspire, and create.
3+
First off, thank you for considering contributing to the STAC-Manager Interface! People like you make the open-source community a great place to learn, inspire, and create.
44

55
## How to Contribute
66

@@ -32,4 +32,4 @@ Our project adheres to a code of conduct. By participating, you are expected to
3232
## Getting Help
3333
If you need help, feel free to create an issue or contact the project maintainers.
3434

35-
Thank you for contributing to the STAC-Admin Interface!
35+
Thank you for contributing to the STAC-Manager Interface!

DEVELOPMENT.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# STAC-Manager 📡 📄 — Development
2+
3+
## Installation and Usage
4+
The steps below will walk you through setting up your own instance of the project.
5+
6+
### Install Project Dependencies
7+
To set up the development environment for this website, you'll need to install the following on your system:
8+
9+
- [Node](http://nodejs.org/) v20 (To manage multiple node versions we recommend [nvm](https://github.com/creationix/nvm))
10+
11+
### Install Application Dependencies
12+
13+
If you use [`nvm`](https://github.com/creationix/nvm), activate the desired Node version:
14+
15+
```
16+
nvm install
17+
```
18+
19+
Install Node modules:
20+
21+
```
22+
npm install
23+
```
24+
25+
### Running the App
26+
27+
To run the client app in development mode:
28+
```
29+
npm run plugins:build
30+
npm run client:serve
31+
```
32+
33+
If you're going to work on the form builder plugin system as well, you may want to run the watch mode on the packages:
34+
```
35+
npm run plugins:watch
36+
```
37+
38+
### Building for Production
39+
Build the app for production:
40+
```
41+
npm run all:build
42+
```
43+
This bundles the app in production mode, optimizing the build for performance. The build is minified, and filenames include hashes.
44+
45+
## Contributing
46+
Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

README.md

+8-49
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# STAC-Manager :satellite: :page_facing_up:
1+
# STAC-Manager 📡 📄
22

33
## Introduction
44
The STAC-Manager is a tool designed for managing the values of a STAC (SpatioTemporal Asset Catalog) collection and its items. This interface provides a user-friendly way to modify and update the properties of collections and items within a STAC catalog.
@@ -10,55 +10,14 @@ It contains the stac-manager web app along with the form build plugin system tha
1010

1111
All the packages are located in the `packages` directory structured as follows:
1212

13-
- `@stac-manager/client` - STAC-Manager web app.
14-
- `@stac-manager/data-core` - Core functionality of the form builder plugin system.
15-
- `@stac-manager/data-widgets` - Form components to be used by the form builder plugin system, when custom ones are not provided.
16-
- `@stac-manager/data-plugins` - Data plugins for the forms. Each plugin defines how a section of the data structure is displayed and edited.
13+
- [`@stac-manager/client`](./packages/client) - STAC-Manager web app.
14+
- [`@stac-manager/data-core`](./packages/data-core) - Core functionality of the form builder plugin system.
15+
- [`@stac-manager/data-widgets`](./packages/data-widgets) - Form components to be used by the form builder plugin system, when custom ones are not provided.
16+
- [`@stac-manager/data-plugins`](./packages/data-plugins) - Data plugins for the forms. Each plugin defines how a section of the data structure is displayed and edited.
1717

18-
## Installation and Usage
19-
The steps below will walk you through setting up your own instance of the project.
18+
## Development & Technical Documentation
2019

21-
### Install Project Dependencies
22-
To set up the development environment for this website, you'll need to install the following on your system:
23-
24-
- [Node](http://nodejs.org/) v20 (To manage multiple node versions we recommend [nvm](https://github.com/creationix/nvm))
25-
26-
### Install Application Dependencies
27-
28-
If you use [`nvm`](https://github.com/creationix/nvm), activate the desired Node version:
29-
30-
```
31-
nvm install
32-
```
33-
34-
Install Node modules:
35-
36-
```
37-
npm install
38-
```
39-
40-
### Running the App
41-
42-
To run the client app in development mode:
43-
```
44-
npm run plugins:build
45-
npm run client:serve
46-
```
47-
48-
If you're going to work on the form builder plugin system as well, you may want to run the watch mode on the packages:
49-
```
50-
npm run plugins:watch
51-
```
52-
53-
### Building for Production
54-
Build the app for production:
55-
```
56-
npm run all:build
57-
```
58-
This bundles the app in production mode, optimizing the build for performance. The build is minified, and filenames include hashes.
59-
60-
## Contributing
61-
Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
20+
To set up the project for development, follow the instructions in the [development documentation](./DEVELOPMENT.md) and get familiar with the app architecture and the plugin system by reading the [technical documentation](./docs/README.md).
6221

6322
## License
64-
This project is licensed under the MIT license - see the LICENSE.md file for details.
23+
This project is licensed under the MIT license - see the LICENSE.md file for details.

docs/CUSTOM_CLIENT.md

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# STAC-Manager 📡 📄 — Custom app
2+
3+
If you're not using the STAC-Manager client app and want to build your own app using the plugin system, the following guide will help you set up the plugin system in your project.
4+
5+
## Provider
6+
7+
Wrap the `PluginConfigProvider` around the `App` component to provide the plugins with the configuration.
8+
9+
```tsx
10+
import { PluginConfigProvider } from '@stac-manager/data-core';
11+
12+
<PluginConfigProvider config={config}>
13+
<App />
14+
</PluginConfigProvider>
15+
```
16+
17+
## Config
18+
19+
The config object should contain a list of plugins to use for the collections and items, as well as the widget configuration (which widgets to use for which field types).
20+
21+
```js
22+
{
23+
collectionPlugins: [
24+
new PluginOne(),
25+
new PluginTwo(),
26+
],
27+
itemPlugins: [
28+
new PluginTwoB(),
29+
],
30+
31+
'ui:widget': {
32+
'customWidget': CustomWidgetComponent,
33+
}
34+
}
35+
```
36+
37+
It is possible to extend the default widget configuration with the `extendPluginConfig` function. The default configuration already defines the widgets for the basic field types.
38+
39+
```ts
40+
import { extendPluginConfig } from '@stac-manager/data-core';
41+
import { defaultPluginWidgetConfig } from '@stac-manager/data-widgets';
42+
43+
export const config = extendPluginConfig(defaultPluginWidgetConfig, {
44+
collectionPlugins: [],
45+
itemPlugins: [],
46+
47+
'ui:widget': {}
48+
});
49+
```
50+
51+
## From
52+
53+
The plugin system is responsible for dynamically generating forms based on a schema definition and uses [Formik](https://formik.org/) to handle the form state. Wrapping the plugins with a formik form is responsibility of the app, not the plugin system.
54+
55+
Below there's a minimal example of all that's needed to use the plugin system.
56+
```tsx
57+
import React from 'react';
58+
import {
59+
PluginBox,
60+
useCollectionPlugins,
61+
validatePluginsFieldsData,
62+
WidgetRenderer
63+
} from '@stac-manager/data-core';
64+
import { Formik } from 'formik';
65+
66+
export function EditForm() {
67+
// Change this to the initial data of the form. Could come from an API if
68+
// editing an existing form.
69+
const initialData = {};
70+
71+
// The useCollectionPlugins takes the initial data and initializes all the
72+
// plugins by calling their init method. Which plugins are used is defined in
73+
// the config file passed to the PluginConfigProvider.
74+
// Once that's done prepares the form data by calling enterData on each plugin
75+
// and prepares the toOutData function that will be used to convert the form
76+
// data back to the original data structure by calling each plugin's exitData
77+
// method.
78+
// All this process is asynchronous and the isLoading flag will be true until
79+
// all everything are ready.
80+
// NOTE: If items are being edited, useItemPlugins would be used instead.
81+
const { plugins, formData, toOutData, isLoading } =
82+
useCollectionPlugins(initialData);
83+
84+
return (
85+
<div>
86+
{isLoading ? (
87+
<p>Loading plugins...</p>
88+
) : (
89+
// STAC-Manager uses Formik for form handling, therefore the form
90+
// must be wrapped in a Formik component.
91+
<Formik
92+
validateOnChange={false}
93+
enableReinitialize
94+
initialValues={formData}
95+
onSubmit={(values, actions) => {
96+
// Once the form is submitted, the toOutData function must be called
97+
// to convert the form data back to the original data structure.
98+
const exitData = toOutData(values);
99+
}}
100+
validate={(values) => {
101+
// validatePluginsFieldsData is a helper function that validates the
102+
// form data against the plugins schema.
103+
const [, error] = validatePluginsFieldsData(plugins, values);
104+
if (error) return error;
105+
}}
106+
>
107+
{({ handleSubmit }) => (
108+
<form onSubmit={handleSubmit}>
109+
{plugins.map((plugin) => (
110+
// Each plugin is wrapped in a headless PluginBox component that
111+
// does some plugin validation and provides each plugin with a
112+
// PluginProvider context which enables access to the plugin's
113+
// info through usePlugin hook.
114+
<PluginBox key={plugin.name} plugin={plugin}>
115+
{({ field }) => (
116+
<div>
117+
<h2>{plugin.name}</h2>
118+
{
119+
// The WidgetRenderer component is used to render the
120+
// plugin's fields. It will render the correct widget
121+
// based on the field type provided in the field prop.
122+
// Since this is the root object, the pointer prop is
123+
// an empty string.
124+
}
125+
<WidgetRenderer pointer='' field={field} />
126+
</div>
127+
)}
128+
</PluginBox>
129+
))}
130+
</form>
131+
)}
132+
</Formik>
133+
)}
134+
</div>
135+
);
136+
}
137+
```

0 commit comments

Comments
 (0)