Add disable attribute for no permission buttons and shorten query param names

This commit is contained in:
thiloho
2024-10-19 17:55:02 +02:00
parent 185aeea4e5
commit b1a59e38c1
22 changed files with 292 additions and 147 deletions

View File

@@ -2,7 +2,7 @@ import type { Actions, PageServerLoad } from "./$types";
import { API_BASE_PREFIX, apiRequest } from "$lib/server/utils";
import type { Collab, User } from "$lib/db-schema";
export const load: PageServerLoad = async ({ parent, params, fetch }) => {
export const load: PageServerLoad = async ({ parent, params, fetch, locals }) => {
const collaborators: (Collab & { user: User })[] = (
await apiRequest(
fetch,
@@ -14,12 +14,14 @@ export const load: PageServerLoad = async ({ parent, params, fetch }) => {
)
).data;
const { website, home } = await parent();
const { website, home, permissionLevel } = await parent();
return {
website,
home,
collaborators
collaborators,
permissionLevel,
user: locals.user
};
};

View File

@@ -51,7 +51,7 @@
</select>
</label>
<button type="submit">Submit</button>
<button type="submit" disabled={[10, 20].includes(data.permissionLevel)}>Submit</button>
</form>
</Modal>
</section>
@@ -89,7 +89,11 @@
</select>
</label>
<button type="submit">Update collaborator</button>
<button
type="submit"
disabled={[10, 20].includes(data.permissionLevel) || user_id === data.user.id}
>Update collaborator</button
>
</form>
</Modal>
<Modal id="remove-collaborator-{user_id}" text="Remove">
@@ -104,7 +108,11 @@
>
<input type="hidden" name="user-id" value={user_id} />
<button type="submit">Remove collaborator</button>
<button
type="submit"
disabled={[10, 20].includes(data.permissionLevel) || user_id === data.user.id}
>Remove collaborator</button
>
</form>
</Modal>
</div>