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

Orgs own projects #865

Merged
merged 18 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Basic frontend for testing in sandbox
This proves that it works, and orgs can acquire and release projects.
rmunn committed Jun 14, 2024
commit b2adb139c7b066b3a6a087d4e0d5d2de1a30fbad
60 changes: 59 additions & 1 deletion frontend/src/lib/gql/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,66 @@
import type { $OpResult, DeleteUserByAdminOrSelfInput, DeleteUserByAdminOrSelfMutation, SoftDeleteProjectMutation, DeleteDraftProjectMutation } from './types';
import type { $OpResult, DeleteUserByAdminOrSelfInput, DeleteUserByAdminOrSelfMutation, SoftDeleteProjectMutation, DeleteDraftProjectMutation, AcquireProjectMutation, ReleaseProjectMutation } from './types';

import { getClient } from './gql-client';
import { graphql } from './generated';

export async function _acquireProject(orgId: string, projectId: string): $OpResult<AcquireProjectMutation> {
//language=GraphQL
const result = await getClient()
.mutation(
graphql(`
mutation AcquireProject($input: AcquireProjectInput!) {
acquireProject(input: $input) {
organization {
id
projects {
id
name
code
}
}
errors {
... on Error {
__typename
message
}
}
}
}
`),
{ input: { orgId, projectId } },
);
return result;
}

export async function _releaseProject(orgId: string, projectId: string): $OpResult<ReleaseProjectMutation> {
//language=GraphQL
const result = await getClient()
.mutation(
graphql(`
mutation ReleaseProject($input: ReleaseProjectInput!) {
releaseProject(input: $input) {
organization {
id
projects {
id
name
code
}
}
errors {
... on Error {
__typename
message
}
}
}
}
`),
{ input: { orgId, projectId } },
);
return result;
}

export async function _deleteUserByAdminOrSelf(input: DeleteUserByAdminOrSelfInput): $OpResult<DeleteUserByAdminOrSelfMutation> {
//language=GraphQL
const result = await getClient()
18 changes: 18 additions & 0 deletions frontend/src/routes/(unauthenticated)/sandbox/+page.svelte
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import ConfirmModal from '$lib/components/modals/ConfirmModal.svelte';
import {delay} from '$lib/util/time';
import DeleteModal from '$lib/components/modals/DeleteModal.svelte';
import { _acquireProject, _releaseProject } from '$lib/gql/mutations';

function uploadFinished(): void {
alert('upload done!');
@@ -47,6 +48,17 @@ function preFillForm(): void {
let modal: ConfirmModal;
let deleteModal: DeleteModal;

const testOrgId = '292c80e6-a815-4cd1-9ea2-34bd01274de6';
const sena3Id = '0ebc5976-058d-4447-aaa7-297f8569f968';

async function acquire() {
console.log(await _acquireProject(testOrgId, sena3Id));
}

async function release() {
console.log(await _releaseProject(testOrgId, sena3Id));
}

</script>
<PageBreadcrumb>Hello from sandbox</PageBreadcrumb>
<PageBreadcrumb>second value</PageBreadcrumb>
@@ -70,6 +82,12 @@ let deleteModal: DeleteModal;
<button class="btn" on:click={fetch500}>Fetch 500</button>
<button class="btn" on:click={gqlThrows500}>GQL 500</button>
</div>
<div class="card w-96 bg-base-200 shadow-lg">
<div class="card-body">
<button class="btn btn-success" on:click={acquire}>acquire</button>
<button class="btn btn-accent" on:click={release}>release</button>
</div>
</div>
<div class="card w-96 bg-base-200 shadow-lg">
<div class="card-body">
<TusUpload internalButton endpoint="/api/tus-test" accept="image/*" on:uploadComplete={uploadFinished}/>