diff --git a/DEV_GUIDELINES.md b/DEV_GUIDELINES.md new file mode 100644 index 0000000..462a17f --- /dev/null +++ b/DEV_GUIDELINES.md @@ -0,0 +1,10 @@ +## Adding new config key + +1. Edit utils/init/initialConfig.json +2. Edit client/src/interfaces/Config.ts +3. Edit client/src/utility/templateObjects/configTemplate.ts + +If config value will be used in a form: + +4. Edit client/src/interfaces/Forms.ts +5. Edit client/src/utility/templateObjects/settingsTemplate.ts \ No newline at end of file diff --git a/client/src/components/SearchBar/SearchBar.tsx b/client/src/components/SearchBar/SearchBar.tsx index b6a981f..a535c19 100644 --- a/client/src/components/SearchBar/SearchBar.tsx +++ b/client/src/components/SearchBar/SearchBar.tsx @@ -5,7 +5,7 @@ import { connect } from 'react-redux'; import { createNotification } from '../../store/actions'; // Typescript -import { NewNotification } from '../../interfaces'; +import { Config, GlobalState, NewNotification } from '../../interfaces'; // CSS import classes from './SearchBar.module.css'; @@ -16,16 +16,20 @@ import { searchParser, urlParser, redirectUrl } from '../../utility'; interface ComponentProps { createNotification: (notification: NewNotification) => void; setLocalSearch: (query: string) => void; + config: Config; + loading: boolean; } const SearchBar = (props: ComponentProps): JSX.Element => { - const { setLocalSearch, createNotification } = props; + const { setLocalSearch, createNotification, config, loading } = props; const inputRef = useRef(document.createElement('input')); useEffect(() => { - inputRef.current.focus(); - }, []); + if (!loading && !config.disableAutofocus) { + inputRef.current.focus(); + } + }, [config]); const clearSearch = () => { inputRef.current.value = ''; @@ -78,4 +82,11 @@ const SearchBar = (props: ComponentProps): JSX.Element => { ); }; -export default connect(null, { createNotification })(SearchBar); +const mapStateToProps = (state: GlobalState) => { + return { + config: state.config.config, + loading: state.config.loading, + }; +}; + +export default connect(mapStateToProps, { createNotification })(SearchBar); diff --git a/client/src/components/Settings/SearchSettings/SearchSettings.tsx b/client/src/components/Settings/SearchSettings/SearchSettings.tsx index a403fa6..d05def5 100644 --- a/client/src/components/Settings/SearchSettings/SearchSettings.tsx +++ b/client/src/components/Settings/SearchSettings/SearchSettings.tsx @@ -121,6 +121,18 @@ const SearchSettings = (props: Props): JSX.Element => { + + + + diff --git a/client/src/interfaces/Config.ts b/client/src/interfaces/Config.ts index 1b60ca7..88f1d5c 100644 --- a/client/src/interfaces/Config.ts +++ b/client/src/interfaces/Config.ts @@ -20,4 +20,5 @@ export interface Config { kubernetesApps: boolean; unpinStoppedApps: boolean; useAmericanDate: boolean; + disableAutofocus: boolean; } diff --git a/client/src/interfaces/Forms.ts b/client/src/interfaces/Forms.ts index 411ce90..6e144bb 100644 --- a/client/src/interfaces/Forms.ts +++ b/client/src/interfaces/Forms.ts @@ -9,6 +9,7 @@ export interface SearchForm { hideSearch: boolean; defaultSearchProvider: string; searchSameTab: boolean; + disableAutofocus: boolean; } export interface OtherSettingsForm { diff --git a/client/src/utility/templateObjects/configTemplate.ts b/client/src/utility/templateObjects/configTemplate.ts index 4d4843f..a6f590a 100644 --- a/client/src/utility/templateObjects/configTemplate.ts +++ b/client/src/utility/templateObjects/configTemplate.ts @@ -22,4 +22,5 @@ export const configTemplate: Config = { kubernetesApps: false, unpinStoppedApps: false, useAmericanDate: false, + disableAutofocus: false, }; diff --git a/client/src/utility/templateObjects/settingsTemplate.ts b/client/src/utility/templateObjects/settingsTemplate.ts index 05bc887..30fa871 100644 --- a/client/src/utility/templateObjects/settingsTemplate.ts +++ b/client/src/utility/templateObjects/settingsTemplate.ts @@ -28,4 +28,5 @@ export const searchSettingsTemplate: SearchForm = { hideSearch: false, searchSameTab: false, defaultSearchProvider: 'l', + disableAutofocus: false, }; diff --git a/utils/init/initialConfig.json b/utils/init/initialConfig.json index f6b57a3..11a839a 100644 --- a/utils/init/initialConfig.json +++ b/utils/init/initialConfig.json @@ -18,5 +18,7 @@ "dockerApps": false, "dockerHost": "localhost", "kubernetesApps": false, - "unpinStoppedApps": false + "unpinStoppedApps": false, + "useAmericanDate": false, + "disableAutofocus": false }