• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 963124858

pending completion
963124858

Pull #3870

gitlab-ci

mzedel
chore: cleaned up left over onboarding tooltips & aligned with updated design

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3870: MEN-5413

4368 of 6355 branches covered (68.73%)

91 of 118 new or added lines in 22 files covered. (77.12%)

1753 existing lines in 162 files now uncovered.

8246 of 10042 relevant lines covered (82.12%)

193.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.62
/src/js/reducers/userReducer.js
1
// Copyright 2019 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import * as UserConstants from '../constants/userConstants';
15

16
export const initialState = {
185✔
17
  byId: {},
18
  currentUser: null,
19
  customColumns: [],
20
  jwtToken: null,
21
  qrCode: null,
22
  globalSettings: {
23
    id_attribute: undefined,
24
    previousFilters: [],
25
    previousPhases: [],
26
    retries: 0
27
  },
28
  showHelptips: true,
29
  permissionSetsById: {
30
    ...UserConstants.defaultPermissionSets
31
  },
32
  rolesById: {
33
    ...UserConstants.rolesById
34
  },
35
  tooltips: {
36
    byId: {
37
      // <id>: { readState: <read|unread> } // this object is getting enhanced by the tooltip texts in the app constants
38
    }
39
  },
40
  userSettings: {
41
    columnSelection: [],
42
    onboarding: {}
43
  }
44
};
45

46
const userReducer = (state = initialState, action) => {
185✔
47
  switch (action.type) {
2,700!
48
    case UserConstants.RECEIVED_QR_CODE:
49
      return {
3✔
50
        ...state,
51
        qrCode: action.value
52
      };
53
    case UserConstants.SUCCESSFULLY_LOGGED_IN:
54
      return {
3✔
55
        ...state,
56
        jwtToken: action.value
57
      };
58
    case UserConstants.RECEIVED_USER_LIST:
59
      return {
10✔
60
        ...state,
61
        byId: { ...action.users }
62
      };
63
    case UserConstants.RECEIVED_ACTIVATION_CODE:
64
      return {
2✔
65
        ...state,
66
        activationCode: action.code
67
      };
68
    case UserConstants.RECEIVED_USER:
69
      return {
7✔
70
        ...state,
71
        byId: {
72
          ...state.byId,
73
          [action.user.id]: {
74
            ...action.user
75
          }
76
        },
77
        currentUser: action.user.id
78
      };
79
    case UserConstants.CREATED_USER:
80
      // the new user gets a 0 as id, since this will be overwritten by the retrieved userlist anyway + there is no way to know the id before
81
      return {
3✔
82
        ...state,
83
        byId: {
84
          ...state.byId,
85
          0: action.user
86
        }
87
      };
88
    case UserConstants.REMOVED_USER: {
89
      // eslint-disable-next-line no-unused-vars
90
      const { [action.userId]: removedUser, ...byId } = state.byId;
2✔
91
      return {
2✔
92
        ...state,
93
        byId,
94
        currentUser: state.currentUser === action.userId ? null : state.currentUser
2!
95
      };
96
    }
97
    case UserConstants.UPDATED_USER:
98
      return {
13✔
99
        ...state,
100
        byId: {
101
          ...state.byId,
102
          [action.userId]: {
103
            ...state.byId[action.userId],
104
            ...action.user
105
          }
106
        }
107
      };
108
    case UserConstants.RECEIVED_PERMISSION_SETS:
109
      return {
4✔
110
        ...state,
111
        permissionSetsById: action.value
112
      };
113
    case UserConstants.RECEIVED_ROLES:
114
    case UserConstants.REMOVED_ROLE:
115
      return {
9✔
116
        ...state,
117
        rolesById: action.value
118
      };
119
    case UserConstants.CREATED_ROLE:
120
    case UserConstants.UPDATED_ROLE:
121
      return {
4✔
122
        ...state,
123
        rolesById: {
124
          ...state.rolesById,
125
          [action.roleId]: {
126
            ...state.rolesById[action.roleId],
127
            ...action.role
128
          }
129
        }
130
      };
131
    case UserConstants.SET_CUSTOM_COLUMNS:
132
      return {
8✔
133
        ...state,
134
        customColumns: action.value
135
      };
136
    case UserConstants.SET_GLOBAL_SETTINGS:
137
      return {
11✔
138
        ...state,
139
        settingsInitialized: true,
140
        globalSettings: {
141
          ...state.globalSettings,
142
          ...action.settings
143
        }
144
      };
145
    case UserConstants.SET_USER_SETTINGS:
146
      return {
39✔
147
        ...state,
148
        userSettingsInitialized: true,
149
        userSettings: {
150
          ...state.userSettings,
151
          ...action.settings
152
        }
153
      };
154
    case UserConstants.SET_SHOW_HELP:
155
      return {
3✔
156
        ...state,
157
        showHelptips: action.show
158
      };
159
    case UserConstants.SET_SHOW_CONNECT_DEVICE:
160
      return {
2✔
161
        ...state,
162
        showConnectDeviceDialog: action.show
163
      };
164
    case UserConstants.SET_TOOLTIP_STATE:
UNCOV
165
      return {
×
166
        ...state,
167
        tooltips: {
168
          ...state.tooltips,
169
          byId: {
170
            ...state.tooltips.byId,
171
            [action.id]: action.value
172
          }
173
        }
174
      };
175
    case UserConstants.SET_TOOLTIPS_STATE:
176
      return {
1✔
177
        ...state,
178
        tooltips: {
179
          ...state.tooltips,
180
          byId: action.value
181
        }
182
      };
183
    default:
184
      return state;
2,576✔
185
  }
186
};
187

188
export default userReducer;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc