22 |

23 |
Welcome to the Strimzi UI
24 | {showVersion && isComplete &&
{`Version: ${version}`}
}
25 | {children}
26 |
27 | );
28 | };
29 |
30 | export { Home };
31 |
--------------------------------------------------------------------------------
/client/Panels/Home/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Strimzi authors.
3 | * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
4 | */
5 | export { Home } from './Home';
6 |
--------------------------------------------------------------------------------
/client/Panels/Home/style.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Strimzi authors.
3 | * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
4 | */
5 |
6 | .home {
7 | align-items: center;
8 | color: #182c46;
9 | display: flex;
10 | flex-direction: column;
11 | font-family: 'Nunito', 'Open Sans', sans-serif;
12 | height: 98vh;
13 | justify-content: center;
14 | }
15 |
--------------------------------------------------------------------------------
/client/Panels/README.md:
--------------------------------------------------------------------------------
1 | # Panels
2 |
3 | A `Panel` component represents a top level element of a UI - the primary/significant capability of a page. A `Panel`s responsibility is not only to compose `Element` and `Group` components to implement the required UI, but to own and manage activities such as data fetching, state reduction, integration with the wider UI and so on. For example, a `Panel` would on mount make a request for and own the response for a piece of data, and while this request is happening, swap in and out `Group` and or `Element` components to represent the loading/error/success states.
4 |
5 | ## Test approach
6 |
7 | Bootstrap should be tested in a behavioural manor. See [Behavioural Driven Development](../../docs/Test.md#style-of-test).
8 |
9 | ## Expected files
10 |
11 | For a given Panel component `Topics`, the expected files are as follows:
12 |
13 | ```
14 | Panels/
15 | index.ts
16 | types.ts
17 | Topics/
18 | index.ts
19 | README.md
20 | View.ts
21 | Model.ts
22 | Styling.scss
23 | Topics.feature
24 | Topics.steps.ts
25 | Topics.assets.ts
26 | Topics.types.ts
27 | ```
28 |
29 | Where:
30 |
31 | - index.ts acts as a barrel file, exporting the public API of this component/component bundle.
32 | - types.ts acts as a barrel file, exporting all the public types of each context
33 | - README.md is the readme for this component, detailing design choices and usage
34 | - View.ts is the view logic for this component
35 | - Model.ts (_optional_) is the model (business) logic for this component
36 | - Styling.scss (_optional_) is the styling for this component
37 | - Topics.feature is the test definition file for this page
38 | - Topics.steps.ts are the steps for the feature definition
39 | - Topics.assets.ts are the test assets for this page
40 | - Topics.types.ts are the types for this page
41 |
42 | ## Components
43 |
44 | Components to be added here on implementation, with summary of purpose/usage and a link to it's README.
45 |
--------------------------------------------------------------------------------
/client/Panels/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Strimzi authors.
3 | * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
4 | */
5 | export * from './Error404';
6 | export * from './Home';
7 |
--------------------------------------------------------------------------------
/client/Queries/Config/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Strimzi authors.
3 | * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
4 | */
5 | import gql from 'graphql-tag';
6 |
7 | export const GET_CONFIG = gql`
8 | query {
9 | client {
10 | about {
11 | version
12 | }
13 | }
14 | featureFlags {
15 | client {
16 | Home {
17 | showVersion
18 | }
19 | Pages {
20 | PlaceholderHome
21 | }
22 | }
23 | }
24 | }
25 | `;
26 |
--------------------------------------------------------------------------------
/client/Queries/README.md:
--------------------------------------------------------------------------------
1 | # Queries
2 |
3 | This directory is home to all GraphQL queries. These should be imported by the appropriate models and exposed via a hook.
4 |
5 | ## File Structure
6 |
7 | - Queries
8 | - query set (e.g. topics)
9 | - index.ts - containing all gql queries for that set
10 |
11 | ## Examples
12 |
13 | ### API
14 |
15 | ```typescript
16 | // topics/index.ts
17 |
18 | import gql from 'graphql-tag';
19 |
20 | export const GET_TOPICS = gql`
21 | query {
22 | ...
23 | }
24 | `;
25 |
26 | export const TOPIC_SUBSCRIPTION = gql`
27 | subscription {
28 | ...
29 | }
30 | `;
31 |
32 | export const CREATE_TOPIC = gql`
33 | mutation {
34 | ...
35 | }
36 | `;
37 | ```
38 |
39 | ```typescript
40 | // useTopic.hook.ts
41 |
42 | import { CREATE_TOPIC, TOPIC_SUBSCRIPTION, GET_TOPICS } from 'Queries/topics';
43 | import { useMutation, useQuery, useSubscription } from '@apollo/client';
44 |
45 | const useTopic = () => {
46 | const [createTopic, { data }] = useMutation(CREATE_TOPIC);
47 | const getTopics = () => useQuery(GET_TOPICS);
48 | const topicsSubscription = () =>
49 | useSubscription(TOPIC_SUBSCRIPTION, {}, true);
50 | return {
51 | addTopic,
52 | getTopics,
53 | topicsSubscription,
54 | };
55 | };
56 |
57 | export default useTopic;
58 | ```
59 |
60 | ```typescript
61 | // topics.model.ts
62 |
63 | import { useTopic } from 'Hooks';
64 |
65 | const TopicModel = () => {
66 | const { addTopic, getTopics, topicSubscription } = useTopic();
67 |
68 | // pass these as props to view
69 | const { loading, error, data } = getTopics();
70 | const { sub_loading, sub_error, sub_data } = topicsSubscription();
71 | ...
72 | };
73 | ```
74 |
75 | ### Config
76 |
77 | When fetching config, a context will need to be provided so that Apollo goes to the correct server.
78 |
79 | ```typescript
80 | // config/index.ts
81 |
82 | import gql from 'graphql-tag';
83 |
84 | const GET_CONFIG = gql`
85 | query {
86 | ...
87 | }
88 | `;
89 | ```
90 |
91 | ```typescript
92 | // config.hook.ts
93 |
94 | import { GET_CONFIG } from 'Queries/topics';
95 | import { useQuery } from '@apollo/client';
96 |
97 | const useConfig = () => {
98 | const getConfig = () =>
99 | useQuery(GET_CONFIG, {
100 | context: {
101 | purpose: 'config',
102 | },
103 | });
104 | return getConfig;
105 | };
106 | ```
107 |
--------------------------------------------------------------------------------
/client/README.md:
--------------------------------------------------------------------------------
1 | # Client
2 |
3 | This directory contains all client code for the Strimzi UI - ie code which is sent to a user's browser. A summary of contents can be found below:
4 |
5 | - [Bootstrap](./Bootstrap/README.md) - code and React components which are responsible for bootstrapping the UI
6 | - [Contexts](./Contexts/README.md) - state management code
7 | - [Elements](./Elements/README.md) - presentational React components
8 | - [Groups](./Groups/README.md) - React components which are combine and compose `Element` components
9 | - [Hooks](./Hooks/README.md) - custom reusable React Hooks
10 | - [Images](./Images/README.md) - images used across the UI
11 | - [Pages](./Pages/README.md) - metadata used to describe the pages shown in the UI
12 | - [Panels](./Panels/README.md) - section/page level components
13 | - [Queries](./Queries/README.md) - GraphQL request definitions (Queries, Mutations etc)
14 | - [Utils](./Utils/README.md) - common utility code used across the client UI
15 | - `tsconfig.json` - Typescript config for this codebase
16 | - `jest.config.js` - Jest config for this codebase.
17 |
18 | ## Configuration options
19 |
20 | The client codebase will include a significant number of configuration options, all of which [can be found here](../config/README.md). These values will be retrieved and made available via the [`ConfigFeatureFlag`](./Contexts/ConfigFeatureFlag/README.md) context at runtime, along with feature flag state.
21 |
22 | The below table details the top level items, and what they contain:
23 |
24 | | Configuration | Content |
25 | | ------------- | --------------------------------------------------------------------------- |
26 | | about | Key value pairs containing metadata about the UI - eg the version of the UI |
27 |
--------------------------------------------------------------------------------
/client/Utils/README.md:
--------------------------------------------------------------------------------
1 | # Utils
2 |
3 | This directory contains client utility code. It also is responsible for importing (and testing) of any general utility code from the root level `utils` folder, in the context of the client.
4 |
5 | Currently provided utilities are provided by utility type follows:
6 |
7 | - [`sanitise`](./sanitise/README.md) - set of helper functions to sanitise user input
8 | - [`window`](./window/README.md) - functions for interacting with the `Window` global object
9 |
--------------------------------------------------------------------------------
/client/Utils/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Strimzi authors.
3 | * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
4 | */
5 | export * from './sanitise/sanitise';
6 | export * from './window/window';
7 |
--------------------------------------------------------------------------------
/client/Utils/sanitise/README.md:
--------------------------------------------------------------------------------
1 | # sanitise
2 |
3 | A set of helper functions to sanitise/validate user input before said input is used across the UI.
4 |
5 | ## Functions available
6 |
7 | - `sanitiseUrlParams` - takes a given URL parameter type, eg `window.search`, and returns an object containing key value pairs of those parameters. If either the key or value do not pass a sanatisation check, they will be omitted from the returned object. Allowed characters are alphanumeric, as well as `.`,`,`,`_`,`-` and `=` characters.
8 |
9 | Example usage, where `window.search` is `param=true¶m2=false