change code after CR
authorJanicki Artur <artur.janicki@contractors.roche.com>
Tue, 16 Oct 2018 08:25:40 +0000 (10:25 +0200)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Tue, 16 Oct 2018 08:25:40 +0000 (10:25 +0200)
Feature #13827

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

src/index.tsx
src/models/search-bar.ts
src/store/search-bar/search-bar-actions.ts
src/views-components/form-fields/search-bar-form-fields.tsx
src/views-components/search-bar/search-bar-advanced-properties-view.tsx
src/views-components/search-bar/search-bar-advanced-view.tsx

index c8dba0d2b3be4e8d06e1938305a503e86aaf28c8..0fc72217ba13bed4e0c4a7f23e3acd5897d8936e 100644 (file)
@@ -115,6 +115,7 @@ const initListener = (history: History, store: RootStore, services: ServiceRepos
             initWebSocket(config, services.authService, store);
             await store.dispatch(loadWorkbench());
             addRouteChangeHandlers(history, store);
+            // ToDo: move to searchBar component
             store.dispatch(initAdvanceFormProjectsTree());
         }
     };
index c118fd5712addf7e8d970f1bb60a870745e32caf..4df5c38f2527278babfa187210681d89310685cb 100644 (file)
@@ -17,8 +17,8 @@ export type SearchBarAdvanceFormData = {
 } & PropertyValues;
 
 export interface PropertyValues {
-    propertyKey: string;
-    propertyValue: string;
+    key: string;
+    value: string;
 }
 
 export enum ClusterObjectType {
index da6889353b814d792962c267f41de6153601a321..4ecf0ff438b3821e4b5d69086b8bb26552de1f9a 100644 (file)
@@ -99,16 +99,16 @@ const getFilters = (filterName: string, searchValue: string): string => {
 };
 
 export const initAdvanceFormProjectsTree = () => 
-    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch<any>(initUserProject(SEARCH_BAR_ADVANCE_FORM_PICKER_ID));
     };
 
 export const changeAdvanceFormProperty = (property: string, value: PropertyValues[] | string = '') => 
-    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(change(SEARCH_BAR_ADVANCE_FORM_NAME, property, value));
     };
 
 export const updateAdvanceFormProperties = (propertyValues: PropertyValues) => 
-    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(arrayPush(SEARCH_BAR_ADVANCE_FORM_NAME, 'properties', propertyValues));
     };
\ No newline at end of file
index 4159775b2422914cf2b7e6586fa0b2d6f47714e3..fbb2cbac1eea7b3820d79ca7f03ec059f4d48cd7 100644 (file)
@@ -62,13 +62,13 @@ export const SearchBarDataToField = () =>
 
 export const SearchBarKeyField = () => 
     <Field
-        name='propertyKey'
+        name='key'
         component={TextField}
         label="Key" />;
 
 export const SearchBarValueField = () => 
     <Field
-        name='propertyValue'
+        name='value'
         component={TextField}
         label="Value" />;
 
index 5e2acb7584930726408343daadda68daf0427dd0..01fc6a1ad91e3931ead66b9f87114849fb12d547 100644 (file)
@@ -18,12 +18,9 @@ import { ArvadosTheme } from '~/common/custom-theme';
 import { SearchBarKeyField, SearchBarValueField } from '~/views-components/form-fields/search-bar-form-fields';
 import { Chips } from '~/components/chips/chips';
 
-type CssRules = 'root' | 'label' | 'button';
+type CssRules = 'label' | 'button';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
-    root: {
-
-    },
     label: {
         color: theme.palette.grey["500"],
         fontSize: '0.8125rem',
@@ -55,7 +52,7 @@ type SearchBarAdvancedPropertiesViewProps = SearchBarAdvancedPropertiesViewDataP
 const selector = formValueSelector(SEARCH_BAR_ADVANCE_FORM_NAME);
 const mapStateToProps = (state: RootState) => {
     return {
-        propertyValues: selector(state, 'propertyKey', 'propertyValue')
+        propertyValues: selector(state, 'key', 'value')
     };
 };
 
@@ -65,18 +62,16 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
     },
     addProp: (propertyValues: PropertyValues) => {
         dispatch<any>(updateAdvanceFormProperties(propertyValues));
-        dispatch<any>(changeAdvanceFormProperty('propertyKey'));
-        dispatch<any>(changeAdvanceFormProperty('propertyValue'));
+        dispatch<any>(changeAdvanceFormProperty('key'));
+        dispatch<any>(changeAdvanceFormProperty('value'));
     },
     getAllFields: (fields: any) => {
         return fields.getAll() || [];
     }
 });
 
-export const SearchBarAdvancedPropertiesView = 
-    connect(mapStateToProps, mapDispatchToProps)
-
-    (withStyles(styles)(
+export const SearchBarAdvancedPropertiesView = connect(mapStateToProps, mapDispatchToProps)(
+    withStyles(styles)(
         ({ classes, fields, propertyValues, setProps, addProp, getAllFields }: SearchBarAdvancedPropertiesViewProps) =>
             <Grid container item xs={12} spacing={16}>
                 <Grid item xs={2} className={classes.label}>Properties</Grid>
@@ -99,7 +94,7 @@ export const SearchBarAdvancedPropertiesView =
                     <Chips values={getAllFields(fields)} 
                         deletable
                         onChange={setProps} 
-                        getLabel={(field: PropertyValues) => `${field.propertyKey}: ${field.propertyValue}`} />
+                        getLabel={(field: PropertyValues) => `${field.key}: ${field.value}`} />
                 </Grid>
             </Grid>
     )
index 4ffcbccd982afcf9120b75afccae6861ff5aec81..1a836a0fea9a8146dc2fdda876f44401b019620f 100644 (file)
@@ -79,7 +79,6 @@ export const SearchBarAdvancedView = compose(
     reduxForm<SearchBarAdvanceFormData, SearchBarAdvancedViewActionProps>({
         form: SEARCH_BAR_ADVANCE_FORM_NAME,
         onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => {
-            console.log('data: ', data);
             dispatch<any>(saveQuery(data));
             dispatch(reset(SEARCH_BAR_ADVANCE_FORM_NAME));
         }