Skip to content

Commit 7749882

Browse files
authored
Merge pull request #124 from lumapps/chore/search-template-settings
Feat/DIS-1165 - Add settings to search template
2 parents cf341b0 + 018e050 commit 7749882

File tree

12 files changed

+83
-6
lines changed

12 files changed

+83
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ _site
1010
versionBump.json
1111
config.trans.js
1212
.idea
13+
template-search-extension/bundle.zip

template-search-extension/src/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ const links = {
5959
/**
6060
* The components available for your extensions
6161
* 'content' : For the Widget content itself (required)
62-
* 'settings' : For your widget settings
62+
* 'settings' : For your search settings that will be used in a Tab context
6363
* 'globalSettings' : For global settings used by platform admin.
6464
*/
65-
const components = ['content'];
65+
const components = ['content', 'settings', 'global_settings'];
6666

6767
// Whether the extension is public or not in the marketplace.
6868
const isPublic = true;
@@ -78,7 +78,7 @@ const whitelist = [];
7878
// do not change the following unless you know what you are doing
7979
const config = {
8080
availability,
81-
category: 'search',
81+
category: 'widget',
8282
components,
8383
description,
8484
extensionId,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Do not modify unless you know what you are doing
33
*/
4-
import { Search } from './widget/Search';
4+
import { Search } from './search/Search';
55

66
export { Search };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Do not modify unless you know what you are doing
3+
*/
4+
export { SearchGlobalSettings } from './search/SearchGlobalSettings';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Do not modify unless you know what you are doing
3+
*/
4+
export { SearchSettings } from './search/SearchSettings';

template-search-extension/src/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import { Provider } from 'react-redux';
4-
54
import { Playground, store } from '@lumapps-extensions-playground/devenv';
65

76
import '@lumx/core/lumx.css';
87

98
import config from './config.js';
9+
import { SearchSettings } from './index.settings';
10+
import { SearchGlobalSettings } from './index.global_settings';
1011

1112
ReactDOM.render(
1213
<React.StrictMode>
1314
<Provider store={store}>
1415
<Playground
15-
config={config as import('lumapps-sdk-js').ExtensionConfig}
16+
config={config as any}
17+
SettingsComponent={SearchSettings}
18+
GlobalSettingsComponent={SearchGlobalSettings}
1619
/>
1720
</Provider>
1821
</React.StrictMode>,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { GlobalSettingsComponent, useExportProps } from 'lumapps-sdk-js';
3+
import { TextField } from '@lumx/react';
4+
5+
import { SampleSearchGlobalParams } from './types';
6+
import { DEFAULT_GLOBAL_SETTINGS } from './constants';
7+
8+
type SearchGlobalSettings = GlobalSettingsComponent<SampleSearchGlobalParams>;
9+
10+
/**
11+
* Render the widget Picsum settings form.
12+
*
13+
* @param {Object} props The settings component properties.
14+
*/
15+
export const SearchGlobalSettings: SearchGlobalSettings = ({ properties = DEFAULT_GLOBAL_SETTINGS, exportProp }) => {
16+
const [currentBaseUrl, setCurrentBaseUrl] = React.useState(properties.baseUrl || DEFAULT_GLOBAL_SETTINGS.baseUrl);
17+
18+
useExportProps(currentBaseUrl, 'baseUrl', properties, exportProp);
19+
20+
return (
21+
<TextField
22+
label="Base URL"
23+
value={currentBaseUrl}
24+
onChange={setCurrentBaseUrl}
25+
/>
26+
);
27+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { TextField } from '@lumx/react';
3+
import { SettingsComponent, useExportProps } from 'lumapps-sdk-js';
4+
5+
import { SampleSearchGlobalParams, SampleSearchParams } from './types';
6+
import { DEFAULT_GLOBAL_SETTINGS, DEFAULT_SETTINGS } from './constants';
7+
8+
type SearchSettingsProps = SettingsComponent<SampleSearchGlobalParams, SampleSearchParams>;
9+
10+
export const SearchSettings: SearchSettingsProps = ({ exportProp, properties = DEFAULT_SETTINGS, globalProperties }) => {
11+
const [currentSearchId, setCurrentSearchId] = React.useState(properties.searchId || DEFAULT_SETTINGS.searchId);
12+
13+
useExportProps(currentSearchId, 'searchId', properties, exportProp);
14+
15+
return (
16+
<TextField
17+
label={`Search identifier for "${globalProperties?.baseUrl || DEFAULT_GLOBAL_SETTINGS.baseUrl}"`}
18+
value={currentSearchId}
19+
onChange={setCurrentSearchId}
20+
/>
21+
);
22+
};

0 commit comments

Comments
 (0)