diff --git a/src/App.svelte b/src/App.svelte index f8cec139..ba8279cf 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -56,6 +56,7 @@ import { register as registerSW } from "./swmodule"; import TeamDetail from "./components/teams/TeamDetail.svelte"; import UserPermissions from "./components/users/UserPermissions.svelte"; + import GroupPermissions from "./components/groups/GroupPermissions.svelte"; import RunnerDetail from "./components/runners/RunnerDetail.svelte"; import Imprint from "./components/general/Imprint.svelte"; import Privacy from "./components/general/Privacy.svelte"; @@ -120,9 +121,9 @@ import GroupDetail from "./components/groups/GroupDetail.svelte"; - + + + diff --git a/src/components/groups/GroupPermissions.svelte b/src/components/groups/GroupPermissions.svelte new file mode 100644 index 00000000..c232d05e --- /dev/null +++ b/src/components/groups/GroupPermissions.svelte @@ -0,0 +1,246 @@ + + +{#await user_promise} + +{:then user} + + + + + + + + + + {$_('users')} + + + + {original_data.firstname} + {original_data.middlename || ''} + {original_data.lastname} + + + + + + + {$_('permissions')} + + + + + + + {$_('permissions')}: + {original_data.firstname} + {original_data.middlename || ''} + {original_data.lastname} + + {#if promises.length === 0} + {$_('save-changes')} + {:else} + {$_('applying-changes')} + {/if} + + + + + + {$_('verfuegbare')} + + + {$_('erteilte')} + + + {$_('geerbte')} + + + + + {#if allpermissions.length > 0} + + + {#each allpermissions as p} + {#if !grantedPermissions.includes(p)} + + {p.target + ':' + p.action} + { + grantedPermissions = grantedPermissions.concat([p]); + if (to_delete.some((o) => o === p.id)) { + to_delete = to_delete.filter((o) => o !== p.id); + } else { + to_add = to_add.concat([ + { + action: p.action, + target: p.target, + principal: original_data.id, + }, + ]); + } + }} + type="button" + class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-green-200 text-base font-medium text-black hover:bg-green-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 sm:ml-3 sm:w-auto sm:text-sm">+ + + {/if} + {/each} + + + + + {#each grantedPermissions as p} + + {p.target + ':' + p.action} + { + grantedPermissions = grantedPermissions.filter((o) => o.target + ':' + o.action !== p.target + ':' + p.action); + if (to_add.some((o) => o.target + ':' + o.action === p.target + ':' + p.action)) { + to_add = to_add.filter((o) => o.target + ':' + o.action !== p.target + ':' + p.action); + } else { + to_delete = to_delete.concat([p.id]); + } + }} + type="button" + class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-300 text-base font-medium text-black hover:bg-red-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:ml-3 sm:w-auto sm:text-sm">- + + {/each} + + + + + {#each inheritedPermissions as p} + + {p.target + ':' + p.action} + + {/each} + + + {/if} + + +{:catch error} + +{/await}
+ {p.target + ':' + p.action} + { + grantedPermissions = grantedPermissions.concat([p]); + if (to_delete.some((o) => o === p.id)) { + to_delete = to_delete.filter((o) => o !== p.id); + } else { + to_add = to_add.concat([ + { + action: p.action, + target: p.target, + principal: original_data.id, + }, + ]); + } + }} + type="button" + class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-green-200 text-base font-medium text-black hover:bg-green-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 sm:ml-3 sm:w-auto sm:text-sm">+ +
+ {p.target + ':' + p.action} + { + grantedPermissions = grantedPermissions.filter((o) => o.target + ':' + o.action !== p.target + ':' + p.action); + if (to_add.some((o) => o.target + ':' + o.action === p.target + ':' + p.action)) { + to_add = to_add.filter((o) => o.target + ':' + o.action !== p.target + ':' + p.action); + } else { + to_delete = to_delete.concat([p.id]); + } + }} + type="button" + class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-300 text-base font-medium text-black hover:bg-red-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:ml-3 sm:w-auto sm:text-sm">- +
+ {p.target + ':' + p.action} +