Skip to content

Commit

Permalink
Merge pull request #1804 from MetRonnie/userprofile
Browse files Browse the repository at this point in the history
Mock server: update introspection query & userprofile responses
  • Loading branch information
oliver-sanders committed Jun 20, 2024
2 parents 8f25266 + ae7d429 commit 2dfbedb
Show file tree
Hide file tree
Showing 25 changed files with 2,412 additions and 783 deletions.
5 changes: 2 additions & 3 deletions src/components/cylc/Drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<v-list
class="pa-0 d-flex flex-column"
>
<c-header :user="user.username" />
<c-header />

<v-list-item
to="/"
Expand Down Expand Up @@ -69,7 +69,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

<script>
import Header from '@/components/cylc/Header.vue'
import { mapMutations, mapState } from 'vuex'
import { mapMutations } from 'vuex'
import Workflows from '@/views/Workflows.vue'
import { mdiHome, mdiGraphql } from '@mdi/js'
import pkg from '@/../package.json'
Expand All @@ -94,7 +94,6 @@ export default {
},
computed: {
...mapState('user', ['user']),
drawer: {
get () {
return this.$store.state.app.drawer
Expand Down
7 changes: 0 additions & 7 deletions src/components/cylc/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,3 @@ const showGoButton = computed(() => (
))
</script>

<style>
/* work around bug with v-combobox overflow https://github.com/vuetifyjs/vuetify/issues/17596 */
.v-combobox__selection {
overflow-x: hidden;
}
</style>
3 changes: 0 additions & 3 deletions src/components/cylc/workspace/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</v-avatar>
<v-menu activator="parent">
<v-card :title="user.username">
<v-card-subtitle v-if="user.admin">
Admin
</v-card-subtitle>
<v-card-text>
<v-btn
to="/user-profile"
Expand Down
7 changes: 2 additions & 5 deletions src/lang/en-GB/UserProfile.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"tableHeader": "Your Profile",
"tableSubHeader": "This is a read-only view of your user",
"title": "Settings",
"yourProfile": "Your Profile",
"username": "Username",
"administrator": "Administrator",
"groups": "Groups",
"created": "Created",
"permissions": "Authorized Operations"
}
7 changes: 2 additions & 5 deletions src/lang/pt-BR/UserProfile.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"tableHeader": "Seu perfil de Usuário",
"tableSubHeader": "Esta é a lista (modo leitura) do perfil do seu usuário",
"title": "Configurações",
"yourProfile": "Seu perfil de Usuário",
"username": "Nome de Usuário",
"administrator": "Administrador",
"groups": "Grupos",
"created": "Criado",
"permissions": "Operações Autorizadas"
}
50 changes: 27 additions & 23 deletions src/model/User.model.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -15,33 +15,37 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @typedef {object} User
* @property {string} username - user name
* @property {string[]} groups - user groups
* @property {string} created - date when the user was created
* @property {boolean} admin - whether the user is an administrator or not
* @property {string} server - server URL
* @property {string} owner - UIS owner
* @property {string[]} permissions - list of permissions
* @property {string} mode - single or multi user mode
* @property {string} initials - user initials
*/
export default class User {
constructor (username, groups, created, admin, server, owner, permissions, mode, initials) {
// the authenticated user
// (full info only available when authenticated via the hub)
constructor ({ username, owner, permissions, mode, initials, color }) {
/**
* @type {string}
*/
this.username = username
this.groups = groups
this.created = created
this.admin = admin
this.server = server || '?' // server can be unset
// the UIS owner
// (i.e. the user who's workflows we are looking at)
// (this might not be the authenticated user for multi-user setups)
/**
* the UIS owner (i.e. the user who's workflows we are looking at)
* (this might not be the authenticated user for multi-user setups)
* @type {string}
*/
this.owner = owner
/**
* list of permissions
* @type {string[]}
*/
this.permissions = permissions
/**
* single or multi user mode
* @type {string}
*/
this.mode = mode
/**
* user initials
* @type {string}
*/
this.initials = initials
/**
* user avatar color if set
* @type {string | null}
*/
this.color = color
}
}
13 changes: 7 additions & 6 deletions src/services/mock/json-server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ server.ws('/subscriptions', (ws) => {
* Render a response. This can be used to customize outputs,
* map response parameters to other values.
* @see https://www.rahulpnath.com/blog/setting-up-a-fake-rest-api-using-json-server/
* @param req - express HTTP request
* @param res - express HTTP response
* @param {import('express').Request} req - express HTTP request
* @param {import('express').Response} res - express HTTP response
*/
router.render = async (req, res) => {
// This is the original response.
Expand All @@ -65,11 +65,12 @@ router.render = async (req, res) => {
} else {
responseData = await graphql.handleGraphQLRequest(req)
}
// NB: json-server returns 404 for requests that are not in the router
// but we have dynamic requests for the /graphql endpoint (i.e. no single
// data response) hence the status(200) below.
res.status(200)
}
// NB: json-server returns 404 for requests that are not in db.json, but
// we have dynamic requests for the /graphql endpoint (i.e. no single
// data response) hence the status(200) below.
res.status(200).jsonp(responseData)
res.jsonp(responseData)
}

server.use(router)
Expand Down
Loading

0 comments on commit 2dfbedb

Please sign in to comment.