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

mendersoftware / gui / 944676341

pending completion
944676341

Pull #3875

gitlab-ci

mzedel
chore: aligned snapshots with updated design

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

4469 of 6446 branches covered (69.33%)

230 of 266 new or added lines in 43 files covered. (86.47%)

1712 existing lines in 161 files now uncovered.

8406 of 10170 relevant lines covered (82.65%)

196.7 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 = {
187✔
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
    show: true
40
  },
41
  userSettings: {
42
    columnSelection: [],
43
    onboarding: {}
44
  }
45
};
46

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

190
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