Skip to content

Commit 1a4a512

Browse files
committed
Remove unused fields from user profile
These jupyterhub-related fields are no longer included by jupyter-server v2, and are not really used for anything
1 parent 7bf6679 commit 1a4a512

File tree

16 files changed

+94
-201
lines changed

16 files changed

+94
-201
lines changed

src/components/cylc/workflow/Toolbar.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
180180
</v-avatar>
181181
<v-menu activator="parent">
182182
<v-card :title="user.username">
183-
<v-card-subtitle v-if="user.admin">
184-
Admin
185-
</v-card-subtitle>
186183
<v-card-text>
187184
<v-btn
188185
to="/user-profile"

src/lang/en-GB/UserProfile.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
2-
"tableHeader": "Your Profile",
3-
"tableSubHeader": "This is a read-only view of your user",
2+
"title": "Settings",
3+
"yourProfile": "Your Profile",
44
"username": "Username",
5-
"administrator": "Administrator",
6-
"groups": "Groups",
7-
"created": "Created",
85
"permissions": "Authorized Operations"
96
}

src/lang/pt-BR/UserProfile.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
2-
"tableHeader": "Seu perfil de Usuário",
3-
"tableSubHeader": "Esta é a lista (modo leitura) do perfil do seu usuário",
2+
"title": "Configurações",
3+
"yourProfile": "Seu perfil de Usuário",
44
"username": "Nome de Usuário",
5-
"administrator": "Administrador",
6-
"groups": "Grupos",
7-
"created": "Criado",
85
"permissions": "Operações Autorizadas"
96
}

src/model/User.model.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
33
*
44
* This program is free software: you can redistribute it and/or modify
@@ -15,33 +15,37 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
/**
19-
* @typedef {object} User
20-
* @property {string} username - user name
21-
* @property {string[]} groups - user groups
22-
* @property {string} created - date when the user was created
23-
* @property {boolean} admin - whether the user is an administrator or not
24-
* @property {string} server - server URL
25-
* @property {string} owner - UIS owner
26-
* @property {string[]} permissions - list of permissions
27-
* @property {string} mode - single or multi user mode
28-
* @property {string} initials - user initials
29-
*/
3018
export default class User {
31-
constructor (username, groups, created, admin, server, owner, permissions, mode, initials) {
32-
// the authenticated user
33-
// (full info only available when authenticated via the hub)
19+
constructor ({ username, owner, permissions, mode, initials, color }) {
20+
/**
21+
* @type {string}
22+
*/
3423
this.username = username
35-
this.groups = groups
36-
this.created = created
37-
this.admin = admin
38-
this.server = server || '?' // server can be unset
39-
// the UIS owner
40-
// (i.e. the user who's workflows we are looking at)
41-
// (this might not be the authenticated user for multi-user setups)
24+
/**
25+
* the UIS owner (i.e. the user who's workflows we are looking at)
26+
* (this might not be the authenticated user for multi-user setups)
27+
* @type {string}
28+
*/
4229
this.owner = owner
30+
/**
31+
* list of permissions
32+
* @type {string[]}
33+
*/
4334
this.permissions = permissions
35+
/**
36+
* single or multi user mode
37+
* @type {string}
38+
*/
4439
this.mode = mode
40+
/**
41+
* user initials
42+
* @type {string}
43+
*/
4544
this.initials = initials
45+
/**
46+
* user avatar color if set
47+
* @type {string | null}
48+
*/
49+
this.color = color
4650
}
4751
}

src/services/mock/json-server.cjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ server.ws('/subscriptions', (ws) => {
5151
* Render a response. This can be used to customize outputs,
5252
* map response parameters to other values.
5353
* @see https://www.rahulpnath.com/blog/setting-up-a-fake-rest-api-using-json-server/
54-
* @param req - express HTTP request
55-
* @param res - express HTTP response
54+
* @param {import('express').Request} req - express HTTP request
55+
* @param {import('express').Response} res - express HTTP response
5656
*/
5757
router.render = async (req, res) => {
5858
// This is the original response.
@@ -65,11 +65,12 @@ router.render = async (req, res) => {
6565
} else {
6666
responseData = await graphql.handleGraphQLRequest(req)
6767
}
68+
// NB: json-server returns 404 for requests that are not in the router
69+
// but we have dynamic requests for the /graphql endpoint (i.e. no single
70+
// data response) hence the status(200) below.
71+
res.status(200)
6872
}
69-
// NB: json-server returns 404 for requests that are not in db.json, but
70-
// we have dynamic requests for the /graphql endpoint (i.e. no single
71-
// data response) hence the status(200) below.
72-
res.status(200).jsonp(responseData)
73+
res.jsonp(responseData)
7374
}
7475

7576
server.use(router)

src/services/user.service.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
33
*
44
* This program is free software: you can redistribute it and/or modify
@@ -19,29 +19,16 @@ import axios from 'axios'
1919
import User from '@/model/User.model'
2020
import { createUrl, getCylcHeaders } from '@/utils/urls'
2121

22-
class UserService {
22+
export default class UserService {
2323
/**
2424
* Gets the user profile from the backend server.
25-
* @returns {Promise<*>} - a promise that dispatches Vuex action
25+
* @returns {Promise<User>} - a promise that dispatches Vuex action
2626
*/
27-
getUserProfile () {
28-
return axios.get(
27+
async getUserProfile () {
28+
const { data } = await axios.get(
2929
createUrl('userprofile'),
30-
{ headers: getCylcHeaders() },
31-
).then(({ data }) => {
32-
return new User(
33-
data.name,
34-
data.groups,
35-
data.created,
36-
data.admin,
37-
data.server,
38-
data.owner,
39-
data.permissions,
40-
data.mode,
41-
data.initials
42-
)
43-
})
30+
{ headers: getCylcHeaders() }
31+
)
32+
return new User(data)
4433
}
4534
}
46-
47-
export default UserService

src/styles/cylc/_user_profile.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
*/
1717

1818
.c-user-profile {
19+
.v-field--disabled {
20+
// Increase opactity to make it easier to read disabled fields
21+
opacity: 0.6;
22+
}
1923
.v-container .v-row {
2024
margin-bottom: 1em;
2125
}

src/views/UserProfile.vue

Lines changed: 21 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2424
prominent
2525
color="grey-lighten-3"
2626
>
27-
<h3 class="text-h5">{{ $t('UserProfile.tableHeader') }}</h3>
28-
<p class="text-body-1">{{ $t('UserProfile.tableSubHeader') }}</p>
27+
<h3 class="text-h5">{{ $t('UserProfile.title') }}</h3>
2928
</v-alert>
30-
<v-form v-if="user !== null">
29+
<v-form>
3130
<v-defaults-provider :defaults="$options.vuetifyDefaults">
3231
<v-container py-0>
32+
<v-row no-gutters>
33+
<h3>{{ $t('UserProfile.yourProfile') }}</h3>
34+
</v-row>
35+
3336
<v-row no-gutters class="align-center wrap">
3437
<v-col cols="3">
3538
<span>{{ $t('UserProfile.username') }}</span>
@@ -45,53 +48,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4548
</v-col>
4649
</v-row>
4750

48-
<v-row no-gutters class="align-center wrap">
49-
<v-col cols="3">
50-
<span>{{ $t('UserProfile.administrator') }}</span>
51-
</v-col>
52-
<v-col cols="9">
53-
<v-checkbox
54-
v-model="user.admin"
55-
disabled
56-
id="profile-admin"
57-
aria-disabled="true"
58-
class="text-body-1"
59-
/>
60-
</v-col>
61-
</v-row>
62-
63-
<v-row no-gutters class="align-center wrap">
64-
<v-col cols="3">
65-
<span>{{ $t('UserProfile.groups') }}</span>
66-
</v-col>
67-
<v-col cols="9">
68-
<v-select
69-
:items="user.groups"
70-
v-model="user.groups"
71-
:menu-props="{ attach: true }"
72-
multiple
73-
disabled
74-
id="profile-groups"
75-
aria-disabled="true"
76-
class="text-body-1"
77-
/>
78-
</v-col>
79-
</v-row>
80-
81-
<v-row no-gutters class="align-center wrap">
82-
<v-col cols="3">
83-
<span>{{ $t('UserProfile.created') }}</span>
84-
</v-col>
85-
<v-col cols="9">
86-
<v-text-field
87-
:model-value="user.created"
88-
disabled
89-
id="profile-created"
90-
aria-disabled="true"
91-
class="text-body-1"
92-
/>
93-
</v-col>
94-
</v-row>
9551
<v-row no-gutters class="align-center wrap">
9652
<v-col cols="3">
9753
<span>{{ $t('UserProfile.permissions') }}</span>
@@ -103,16 +59,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
10359
:menu-props="{ attach: true }"
10460
multiple
10561
disabled
62+
chips
10663
id="profile-permissions"
107-
aria-disabled="true"
108-
class="text-body-1"
109-
/>
64+
>
65+
<template #chip="{ data }">
66+
<v-chip
67+
v-bind="data"
68+
label
69+
size="default"
70+
/>
71+
</template>
72+
</v-select>
11073
</v-col>
11174
</v-row>
75+
11276
<v-row no-gutters class="mt-4">
113-
<v-col cols="12">
114-
<p class="text-h6">Preferences</p>
115-
</v-col>
77+
<h3>Preferences</h3>
11678
</v-row>
11779

11880
<v-row no-gutters class="align-center wrap">
@@ -158,7 +120,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
158120
v-for="theme in $options.jobThemes"
159121
:key="theme"
160122
>
161-
{{ theme.replace('_', ' ') }}
123+
{{ upperFirst(theme.replace('_', ' ')) }}
162124
</th>
163125
</tr>
164126
<tr>
@@ -234,7 +196,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
234196
</v-container>
235197
</v-defaults-provider>
236198
</v-form>
237-
<v-progress-linear v-else :indeterminate="true" />
238199
</v-col>
239200
</v-row>
240201
</v-container>
@@ -249,6 +210,7 @@ import { decreaseFontSize, getCurrentFontSize, increaseFontSize, resetFontSize }
249210
import { allViews, useDefaultView } from '@/views/views.js'
250211
import Job from '@/components/cylc/Job.vue'
251212
import JobState from '@/model/JobState.model'
213+
import { upperFirst } from 'lodash-es'
252214
253215
// TODO: update where user preferences are stored after #335
254216
@@ -265,6 +227,7 @@ export default {
265227
cyclePointsOrderDesc: useCyclePointsOrderDesc(),
266228
jobTheme: useJobTheme(),
267229
reducedAnimation: useReducedAnimation(),
230+
upperFirst,
268231
}
269232
},
270233

tests/e2e/specs/header.cy.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ describe('Header Component multiuser', () => {
3030
beforeEach(() => {
3131
cy.intercept('/userprofile', {
3232
body: {
33-
name: 'userTest',
34-
groups: [
35-
'cylc',
36-
'developer'
37-
],
38-
created: '2021-03-23T23:26:23.606Z',
39-
admin: true,
40-
server: '/user/cylc/',
33+
username: 'userTest',
4134
permissions: [
4235
'read',
4336
],

tests/e2e/specs/url.cy.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ describe('URL handling', () => {
3939
it('reroutes to noAuth page if user isnt authorised', () => {
4040
cy.intercept('/userprofile', {
4141
body: {
42-
name: 'user',
43-
groups: ['cylc', 'developer'],
44-
created: '2021-03-23T23:26:23.606Z',
45-
admin: true,
46-
server: '/user/cylc/',
42+
username: 'user',
4743
permissions: [],
4844
mode: 'single user',
4945
owner: 'user'

0 commit comments

Comments
 (0)