Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(admin): add user role management #4248

Merged
merged 109 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
63b758d
feat(admin): add user role management
chinook25 Sep 23, 2024
092408a
wip: admin page tries request
chinook25 Sep 23, 2024
4509030
wip: use useFetch (not working)
chinook25 Sep 24, 2024
4a69b28
wip: now it retrieves!
chinook25 Sep 24, 2024
a4b5171
wip: retrieve tokens
chinook25 Sep 24, 2024
7612f38
wip: add murmurs
chinook25 Sep 24, 2024
faf3f5b
Merge branch 'master' into feat/admin-role-management
chinook25 Sep 25, 2024
20477dc
wip: use useFetch
chinook25 Sep 25, 2024
239fe1e
wip: pagination working
chinook25 Sep 26, 2024
3981a51
wip: limit 20
chinook25 Sep 26, 2024
bebe5dc
wip: correct next page
chinook25 Sep 27, 2024
f11b42d
wip: add roles to user
chinook25 Oct 1, 2024
b57ab94
wip: add column to db
chinook25 Oct 1, 2024
9090611
wip rename
chinook25 Oct 1, 2024
7e678c9
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 1, 2024
15c32fb
now with correct query
chinook25 Oct 1, 2024
7449963
adding roles to sql
chinook25 Oct 1, 2024
c49169a
Merge branch 'master' into feat/admin-role-management
mswertz Oct 1, 2024
1b428a0
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 2, 2024
cd45861
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 3, 2024
78b2e47
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 4, 2024
086705d
wip: trying to retrieve roles, almost there?
chinook25 Oct 4, 2024
0bf018a
wip: remove unused code
chinook25 Oct 4, 2024
d7b20b5
chore: format
chinook25 Oct 4, 2024
de1e694
chore: format
chinook25 Oct 4, 2024
f2f245d
feat: retrieving roles works
chinook25 Oct 4, 2024
32aabc7
chore: remove roles from user
chinook25 Oct 4, 2024
1163a05
chore: remove unused type
chinook25 Oct 4, 2024
dddad76
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 7, 2024
7bfe0eb
chore: move load roles function
chinook25 Oct 7, 2024
f94833b
feat: split result into schema and role
chinook25 Oct 7, 2024
3201621
chore: minor refactor
chinook25 Oct 7, 2024
7da5b8b
fix: warnings
chinook25 Oct 7, 2024
c488c17
chore: nicer role and token display
chinook25 Oct 7, 2024
793e626
chore: refactor
chinook25 Oct 8, 2024
c059219
feat: add delete and update functions
chinook25 Oct 8, 2024
f7d8962
minor chagne
chinook25 Oct 8, 2024
6c71ff9
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 8, 2024
d73c913
feat: can add users
chinook25 Oct 8, 2024
534e7df
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 9, 2024
3380177
merge master
chinook25 Oct 9, 2024
30279c2
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 9, 2024
2cc3874
chore: add comments
chinook25 Oct 9, 2024
9dc7425
feat: show enabled; wip: start with edit user modal
chinook25 Oct 10, 2024
ae6f00b
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 14, 2024
0204c24
feat: put create user in modal
chinook25 Oct 14, 2024
27a700a
feat:retrieve roles
chinook25 Oct 15, 2024
4434a7d
chore: move functions to util file
chinook25 Oct 16, 2024
c6bed32
feat: show tokens in modal
chinook25 Oct 16, 2024
a7820f6
feat: add dis-/en-able button
chinook25 Oct 16, 2024
55fa5b6
chore: tsing
chinook25 Oct 16, 2024
eb03b44
chore: move edit user modal to component
chinook25 Oct 17, 2024
1ae772e
feat?: wip edit user
chinook25 Oct 17, 2024
bcbb249
feat: interface to add/remove roles and remove tokens
chinook25 Oct 17, 2024
a5d7c20
edit password field
chinook25 Oct 17, 2024
67946f0
Merge branch 'master' into feat/admin-role-management
chinook25 Oct 22, 2024
e216d99
wip: adding update user endpoint
chinook25 Oct 22, 2024
1d92672
wip: making update user endpoint
chinook25 Oct 23, 2024
b44047d
wip: gql query correct?
chinook25 Oct 23, 2024
5641f8c
update pass
chinook25 Oct 24, 2024
372a54c
feat: can commit user changes;fix: disabled user toggles correctly
chinook25 Oct 25, 2024
6f75747
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 4, 2024
6883c43
feat: can now save enabling;update list on save
chinook25 Nov 4, 2024
e2e38c0
feat: make role api better
chinook25 Nov 5, 2024
c6a71b6
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 7, 2024
875b9d0
wip: adding role api
chinook25 Nov 7, 2024
e5f61ab
fix: import
chinook25 Nov 7, 2024
0f4df76
feat: can add and remove roles!
chinook25 Nov 7, 2024
20480e7
feat: can now update existing roles
chinook25 Nov 7, 2024
e25daca
chore:refactor
chinook25 Nov 7, 2024
5a5d70c
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 11, 2024
40286b9
test: add working start of test
chinook25 Nov 12, 2024
bca1285
chore: basic test
chinook25 Nov 12, 2024
4314bca
test: basic change test
chinook25 Nov 12, 2024
31ec18e
test: basic change test
chinook25 Nov 12, 2024
bc21da8
chore: test updateUser
chinook25 Nov 13, 2024
9e3b520
chore: improve cov
chinook25 Nov 13, 2024
d09a101
chore: refactor to make sonarcloud happy
chinook25 Nov 13, 2024
60842d5
chore: refactor to make sonarcloud happy
chinook25 Nov 13, 2024
f8d2ec1
chore: refactor to make sonarcloud happy
chinook25 Nov 13, 2024
6f33ba6
chore: more sonarring
chinook25 Nov 13, 2024
b8f192b
chore: remove dead code
chinook25 Nov 13, 2024
732cb00
chore: undo remove code
chinook25 Nov 13, 2024
d33d8bf
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 18, 2024
e5b624d
chore: reset backend
chinook25 Nov 18, 2024
00784aa
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 18, 2024
d148ba0
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 20, 2024
dca93a6
feat: add add user component
chinook25 Nov 20, 2024
7d5cb30
feat: proper admin in bar
chinook25 Nov 20, 2024
6b74d87
chore: cleanup
chinook25 Nov 20, 2024
62a8f1c
chore: capitalize components
chinook25 Nov 21, 2024
bd5b965
Rename editUserModal.vue to EditUserModal.vue
chinook25 Nov 21, 2024
a9e6daf
Rename newUserModal.vue to NewUserModal.vue
chinook25 Nov 21, 2024
123f9ec
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 21, 2024
25d8215
chore: no close tag
chinook25 Nov 26, 2024
7e0ea34
Merge branch 'master' into feat/admin-role-management
chinook25 Nov 28, 2024
f924f44
feat: password field
chinook25 Nov 28, 2024
67ad606
feat: simpler password
chinook25 Nov 28, 2024
021371e
chore: remove prop from string input
chinook25 Nov 28, 2024
80f7292
chore: remove prop from string input
chinook25 Nov 28, 2024
d87dd04
chore: modalling
chinook25 Nov 28, 2024
e9914d3
Merge branch 'master' into feat/admin-role-management
chinook25 Jan 7, 2025
9c90815
chore: use instead of useFetch; remove comments
chinook25 Jan 9, 2025
fedc711
chore: remove unnecessary key
chinook25 Jan 9, 2025
a903c4f
fix: get roles url in full application
chinook25 Jan 9, 2025
5dbef0e
Merge branch 'master' into feat/admin-role-management
chinook25 Jan 15, 2025
03fa899
fix: swap disabled button color
chinook25 Jan 15, 2025
cc71dcb
chore: disable token management for now; add errors to user edit/create
chinook25 Jan 16, 2025
41441d6
chore: hide token count
chinook25 Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions apps/settings/src/components/Members.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
<MessageError v-if="graphqlError">{{ graphqlError }}</MessageError>
<MessageSuccess v-if="success">{{ success }}</MessageSuccess>
</div>
<div
v-if="
session &&
(session.email == 'admin' ||
(session.roles && session.roles.length > 0))
"
>
<div v-if="session?.email === 'admin' || session?.roles?.length">
<h5 class="card-title">Manage members</h5>
<p>Use table below to add, edit or remove members</p>
<form v-if="canEdit" class="form-inline">
Expand Down Expand Up @@ -106,13 +100,11 @@ export default {
loading: false,
};
},

computed: {
canEdit() {
return (
this.session != null &&
(this.session.email == "admin" ||
this.session.roles.includes("Manager"))
this.session?.email === "admin" ||
this.session?.roles.includes("Manager")
);
},
},
Expand All @@ -127,7 +119,7 @@ export default {
`mutation drop($member:[String]){drop(members:$member){message}}`,
{ member: name }
)
.then((data) => {
.then(() => {
this.loadMembers();
})
.catch((error) => {
Expand Down
2 changes: 2 additions & 0 deletions apps/tailwind-components/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<!-- <SearchBar /> -->
</div>

<slot name="admin" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a admin slot , suggest to have slots names related to parts of the header ( left , right , info , cart ) instead of role

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to add menu item


<slot name="account">
<!-- <HeaderButton label="Favorites" icon="star" /> -->
<HeaderButton label="Account" icon="user" />
Expand Down
31 changes: 9 additions & 22 deletions apps/tailwind-components/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function showModal() {
visible.value = true;
}

const closeModal = (returnVal?: string) => {
const closeModal = () => {
visible.value = false;
};

Expand All @@ -20,6 +20,7 @@ defineExpose({
visible,
});
</script>

<template>
<section
v-show="visible"
Expand All @@ -29,11 +30,12 @@ defineExpose({
class="fixed min-h-lvh w-full top-0 left-0 flex z-20"
>
<a
@click="closeModal('close from backdrop')"
id="backdrop"
@click="closeModal()"
class="w-full h-full absolute left-0 bg-black/60"
href="#"
tabindex="-1"
></a>
/>

<div class="bg-white w-3/4 relative m-auto h-3/4 rounded-50px max-w-xl">
<header class="pt-[36px] px-[50px] overflow-y-auto">
Expand All @@ -43,38 +45,23 @@ defineExpose({
</h2>

<button
@click="closeModal('close from btn')"
@click="closeModal()"
aria-label="Close modal"
class="absolute top-7 right-8 p-1"
>
<BaseIcon class="text-blue-500" name="cross" />
</button>

<slot name="header"></slot>
<slot name="header" />
</header>

<div class="px-[50px] overflow-y-auto py-4 max-h-[calc(80vh-232px)]">
<slot></slot>
<slot />
</div>

<footer class="bg-modal-footer px-[50px] rounded-b-50px">
<menu class="flex items-center justify-left h-[116px]">
<slot name="footer">
<div class="flex flex-wrap gap-5">
<button
@click="closeModal('close from btn')"
class="flex items-center border rounded-full h-10.5 px-5 text-heading-lg gap-3 tracking-widest uppercase font-display bg-button-primary text-button-primary border-button-primary hover:bg-button-primary-hover hover:text-button-primary-hover hover:border-button-primary-hover"
>
Primary
</button>
<button
@click="closeModal('close from btn')"
class="flex items-center border rounded-full h-10.5 px-5 text-heading-lg gap-3 tracking-widest uppercase font-display bg-button-secondary text-button-secondary border-button-secondary hover:bg-button-secondary-hover hover:text-button-secondary-hover hover:border-button-secondary-hover"
>
Secondary
</button>
</div>
</slot>
<slot name="footer" />
</menu>
</footer>
</div>
Expand Down
1 change: 0 additions & 1 deletion apps/tailwind-components/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const mainButtons = computed(() =>
const subButtons = computed(() =>
props.navigation.slice(props.maximumButtonShown)
);
const active = "underline";
chinook25 marked this conversation as resolved.
Show resolved Hide resolved
</script>

<template>
Expand Down
1 change: 0 additions & 1 deletion apps/tailwind-components/components/Table.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- eslint-disable vue/multi-word-component-names -->
<template>
<table class="w-full table-auto">
<thead>
Expand Down
1 change: 0 additions & 1 deletion apps/tailwind-components/components/TableCell.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- eslint-disable vue/multi-word-component-names -->
<script setup>
defineProps({
allowLineBreak: {
Expand Down
1 change: 0 additions & 1 deletion apps/tailwind-components/components/TableRow.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- eslint-disable vue/multi-word-component-names -->
<template>
<tr class="sm:hover:bg-blue-50 sm:hover:cursor-pointer">
<slot></slot>
Expand Down
4 changes: 2 additions & 2 deletions apps/tailwind-components/components/input/Radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<script lang="ts" setup>
defineProps<{
value: string;
value?: string | boolean;
}>();

const modelValue = defineModel<string>();
const modelValue = defineModel<string | boolean>();
</script>
12 changes: 4 additions & 8 deletions apps/tailwind-components/components/input/RadioGroup.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<template>
<div :id="`${id}-radio-group`">
<div
class="flex justify-start align-center"
v-for="option in radioOptions"
:key="option.value"
chinook25 marked this conversation as resolved.
Show resolved Hide resolved
>
<div v-for="option in radioOptions" class="flex justify-start align-center">
<InputRadio
:id="`${id}-radio-group-${option.value}`"
class="sr-only"
Expand Down Expand Up @@ -41,7 +37,7 @@

<script lang="ts" setup>
interface RadioOptionsDataIF {
value: string;
value: string | boolean;
label?: string;
checked?: boolean | undefined;
}
Expand All @@ -57,9 +53,9 @@ withDefaults(
}
);

const modelValue = defineModel<string>();
const modelValue = defineModel<string | boolean>();

function resetModelValue() {
modelValue.value = "";
modelValue.value = undefined;
}
</script>
2 changes: 0 additions & 2 deletions apps/tailwind-components/components/input/Select.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { N } from "vitest/dist/reporters-MmQN-57K.js";

withDefaults(
defineProps<{
id: string;
Expand Down
35 changes: 19 additions & 16 deletions apps/tailwind-components/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['@nuxtjs/tailwindcss', '@nuxt/test-utils/module'],
modules: ["@nuxtjs/tailwindcss", "@nuxt/test-utils/module"],
tailwindcss: {
cssPath: '~/assets/css/main.css',
configPath: '~/tailwind.config.js'
cssPath: "~/assets/css/main.css",
configPath: "~/tailwind.config.js",
},

ssr: process.env.NUXT_PUBLIC_IS_SSR === 'false' ? false : true,
ssr: process.env.NUXT_PUBLIC_IS_SSR === "false" ? false : true,

router: {
options: process.env.NUXT_PUBLIC_IS_SSR === 'false' ? {
hashMode: true
} : {}
options:
process.env.NUXT_PUBLIC_IS_SSR === "false"
? {
hashMode: true,
}
: {},
},

nitro: {
prerender: {
ignore: ['/_tailwind/']
}
ignore: ["/_tailwind/"],
},
},

app: {
head: {
htmlAttrs: {
'data-theme': ''
}
}
"data-theme": "",
},
},
},

components: [
Expand All @@ -36,16 +39,16 @@ export default defineNuxtConfig({
},
{
path: "~/components/viz",
pathPrefix: false
pathPrefix: false,
},
"~/components",
],

runtimeConfig: {
public: {
apiBase: "https://emx2.dev.molgenis.org/", // "http://localhost:8080/",
apiBase: "http://localhost:8080/",
},
},

compatibilityDate: '2024-08-23',
})
compatibilityDate: "2024-08-23",
});
21 changes: 11 additions & 10 deletions apps/tailwind-components/pages/Button.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,23 @@

<h2 class="text-2xl">Icons</h2>
<div class="flex gap-4">
<Button type="primary" size="medium" icon="filter" iconPosition="left"
>Filter</Button
>
<Button type="primary" size="small" icon="filter" iconPosition="right"
>Filter</Button
>
<Button type="secondary" size="small" icon="star" iconPosition="left"
>Star</Button
>
<Button type="primary" size="medium" icon="filter" iconPosition="left">
Filter
</Button>
<Button type="primary" size="small" icon="filter" iconPosition="right">
Filter
</Button>
<Button type="secondary" size="small" icon="star" iconPosition="left">
Star
</Button>
<Button
type="secondary"
size="small"
icon="CaretDown"
iconPosition="right"
>CaretDown</Button
>
CaretDown
</Button>
</div>
</div>
</template>
1 change: 1 addition & 0 deletions apps/tailwind-components/pages/Modal.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function showModal() {

let sectionCount = ref(0);
</script>

<template>
<button
@click="showModal"
Expand Down
8 changes: 4 additions & 4 deletions apps/tailwind-components/server/routes/[schema]/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { joinURL } from "ufo";
import { createConsola } from "consola";

export default defineEventHandler((event) => {
const config = useRuntimeConfig(event);
const logger = createConsola({ level: config.logLevel?? 3 });
const config = useRuntimeConfig(event);
const logger = createConsola({ level: config.logLevel ?? 3 });
logger.info("proxy schema gql request : ", event.path);
if (event.method === "POST") {
readBody(event).then((body) => {
if (body.query) {
logger.debug( body.query);
logger.debug(body.query);
}
if (body.variables) {
logger.debug(body.variables);
Expand All @@ -17,6 +17,6 @@ export default defineEventHandler((event) => {
}
const schema = getRouterParam(event, "schema") || "";
logger.info("to : ", joinURL(config.public.apiBase, schema, "graphql"));
const target = joinURL(config.public.apiBase, schema,"graphql");
const target = joinURL(config.public.apiBase, schema, "graphql");
return proxyRequest(event, target);
});
Loading