Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WIE_202021_CSBillero11
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bernard Roland (Student Com20)
WIE_202021_CSBillero11
Commits
82d616e9
Commit
82d616e9
authored
3 years ago
by
Bernard Roland (Student Com20)
Browse files
Options
Downloads
Patches
Plain Diff
Implemented the remainider of the team adapter
parent
fd1a466a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/src/adapters/team.ts
+121
-0
121 additions, 0 deletions
client/src/adapters/team.ts
with
121 additions
and
0 deletions
client/src/adapters/team.ts
+
121
−
0
View file @
82d616e9
...
...
@@ -101,4 +101,125 @@ export async function getTeamWork(uuid: string): Promise<Work[]> {
}
}
export
async
function
createTeam
(
name
:
string
):
Promise
<
string
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/`
,
{
method
:
'
POST
'
,
headers
:
{
...
getAuthHeader
(),
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
({
name
:
name
,
}),
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
id
;
}
else
{
throw
new
Error
(
"
Failed to create team
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
removeTeamMember
(
team
:
string
,
user
:
string
)
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
team
}
/members/
${
user
}
`
,
{
method
:
'
DELETE
'
,
headers
:
getAuthHeader
(),
});
if
(
!
response
.
ok
)
{
throw
new
Error
(
"
Failed to create team
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
createTeamRole
(
team
:
string
,
name
:
string
):
Promise
<
TeamRole
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
team
}
/roles`
,
{
method
:
'
POST
'
,
headers
:
{
...
getAuthHeader
(),
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
({
name
:
name
,
}),
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
role
;
}
else
{
throw
new
Error
(
"
Failed to create team role
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
deleteTeamRole
(
team
:
string
,
role
:
string
)
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
team
}
/roles/
${
role
}
`
,
{
method
:
'
DELETE
'
,
headers
:
getAuthHeader
(),
});
if
(
!
response
.
ok
)
{
throw
new
Error
(
"
Failed to delete team role
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
addTeamMember
(
team
:
string
,
member
:
{
user
:
string
,
role
:
string
})
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
team
}
/members`
,
{
method
:
'
POST
'
,
headers
:
{
...
getAuthHeader
(),
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
(
member
),
});
if
(
!
response
.
ok
)
{
throw
new
Error
(
"
Failed to add team member
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
updateTeamMember
(
team
:
string
,
member
:
{
user
:
string
,
role
:
string
})
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
team
}
/members`
,
{
method
:
'
PUT
'
,
headers
:
{
...
getAuthHeader
(),
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
(
member
),
});
if
(
!
response
.
ok
)
{
throw
new
Error
(
"
Failed to update team member
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
leaveTeam
(
team
:
string
)
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
team
}
`
,
{
method
:
'
DELETE
'
,
headers
:
getAuthHeader
(),
});
if
(
!
response
.
ok
)
{
throw
new
Error
(
"
Failed to leave team
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment