Edit project frontend integration (#2777)
* Added GQL integration for Edit project from teaming Signed-off-by: Saranya-jena <saranya@chaosnative.com> * added translations Signed-off-by: Saranya-jena <saranya@chaosnative.com> * removed unused CSS Signed-off-by: Saranya-jena <saranya@chaosnative.com>
This commit is contained in:
parent
1e74868004
commit
3fdc7e1cdd
|
|
@ -476,6 +476,7 @@ settings:
|
||||||
header: Members
|
header: Members
|
||||||
invitedProject: Projects you were invited to
|
invitedProject: Projects you were invited to
|
||||||
noUsers: No users available
|
noUsers: No users available
|
||||||
|
editProjectLabel: Project ID
|
||||||
label:
|
label:
|
||||||
search: Search...
|
search: Search...
|
||||||
role: Role
|
role: Role
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,12 @@ export const CREATE_PROJECT = gql`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const UPDATE_PROJECT_NAME = gql`
|
||||||
|
mutation updateProjectName($projectID: String!, $projectName: String!) {
|
||||||
|
updateProjectName(projectID: $projectID, projectName: $projectName)
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const SEND_INVITE = gql`
|
export const SEND_INVITE = gql`
|
||||||
mutation sendInvite($member: MemberInput!) {
|
mutation sendInvite($member: MemberInput!) {
|
||||||
sendInvitation(member: $member) {
|
sendInvitation(member: $member) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useQuery } from '@apollo/client';
|
import { useMutation, useQuery } from '@apollo/client';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -12,11 +12,16 @@ import {
|
||||||
Typography,
|
Typography,
|
||||||
useTheme,
|
useTheme,
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import { Search } from 'litmus-ui';
|
import { EditableText, Search } from 'litmus-ui';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Center from '../../../../containers/layouts/Center';
|
import Center from '../../../../containers/layouts/Center';
|
||||||
import { ALL_USERS, GET_PROJECT, LIST_PROJECTS } from '../../../../graphql';
|
import {
|
||||||
|
ALL_USERS,
|
||||||
|
GET_PROJECT,
|
||||||
|
LIST_PROJECTS,
|
||||||
|
UPDATE_PROJECT_NAME,
|
||||||
|
} from '../../../../graphql';
|
||||||
import { UserInvite } from '../../../../models/graphql/invite';
|
import { UserInvite } from '../../../../models/graphql/invite';
|
||||||
import {
|
import {
|
||||||
Member,
|
Member,
|
||||||
|
|
@ -93,7 +98,6 @@ const TeamingTab: React.FC = () => {
|
||||||
const [allUsers, setAllUsers] = useState<UserInvite[]>([]);
|
const [allUsers, setAllUsers] = useState<UserInvite[]>([]);
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState<number>(0);
|
const [activeTab, setActiveTab] = useState<number>(0);
|
||||||
const [selectedProjectName, setselectedProjectName] = useState<string>('');
|
|
||||||
|
|
||||||
const handleChange = (event: React.ChangeEvent<{}>, actTab: number) => {
|
const handleChange = (event: React.ChangeEvent<{}>, actTab: number) => {
|
||||||
setActiveTab(actTab);
|
setActiveTab(actTab);
|
||||||
|
|
@ -104,7 +108,6 @@ const TeamingTab: React.FC = () => {
|
||||||
ProjectDetailVars
|
ProjectDetailVars
|
||||||
>(GET_PROJECT, {
|
>(GET_PROJECT, {
|
||||||
variables: { projectID },
|
variables: { projectID },
|
||||||
onCompleted: (data) => setselectedProjectName(data.getProject.name),
|
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -231,6 +234,15 @@ const TeamingTab: React.FC = () => {
|
||||||
setInvitationCount(projectInvitation);
|
setInvitationCount(projectInvitation);
|
||||||
setProjectOtherCount(projectOther);
|
setProjectOtherCount(projectOther);
|
||||||
}, [projects, dataProject, deleteMemberOpen, inviteNewOpen, activeTab]);
|
}, [projects, dataProject, deleteMemberOpen, inviteNewOpen, activeTab]);
|
||||||
|
|
||||||
|
const [updateProjectName] = useMutation(UPDATE_PROJECT_NAME, {
|
||||||
|
refetchQueries: [
|
||||||
|
{
|
||||||
|
query: GET_PROJECT,
|
||||||
|
variables: { projectID },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{!loading ? (
|
{!loading ? (
|
||||||
|
|
@ -282,12 +294,22 @@ const TeamingTab: React.FC = () => {
|
||||||
</Center>
|
</Center>
|
||||||
<div>
|
<div>
|
||||||
<Paper className={classes.myProject} elevation={0}>
|
<Paper className={classes.myProject} elevation={0}>
|
||||||
<div className={classes.project}>
|
<Center>
|
||||||
<Typography className={classes.projectName}>
|
<div className={classes.project}>
|
||||||
{/* Check for removal of userData */}
|
<EditableText
|
||||||
{selectedProjectName}
|
label={t('settings.teamingTab.editProjectLabel')}
|
||||||
</Typography>
|
defaultValue={dataB ? dataB.getProject.name : ''}
|
||||||
</div>
|
onSave={(value) => {
|
||||||
|
updateProjectName({
|
||||||
|
variables: {
|
||||||
|
projectID,
|
||||||
|
projectName: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Center>
|
||||||
<Toolbar data-cy="toolBarComponent" className={classes.toolbar}>
|
<Toolbar data-cy="toolBarComponent" className={classes.toolbar}>
|
||||||
{/* Search user */}
|
{/* Search user */}
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -229,16 +229,12 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||||
},
|
},
|
||||||
project: {
|
project: {
|
||||||
margin: theme.spacing(3.875, 'auto', 2.5, 'auto'),
|
margin: theme.spacing(3.875, 'auto', 2.5, 'auto'),
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
},
|
||||||
projectName: {
|
projectName: {
|
||||||
margin: theme.spacing(0, 0, 0, 1.56),
|
|
||||||
textTransform: 'uppercase',
|
textTransform: 'uppercase',
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
fontSize: '1rem',
|
fontSize: '1rem',
|
||||||
},
|
},
|
||||||
|
|
||||||
active: {
|
active: {
|
||||||
textTransform: 'capitalize',
|
textTransform: 'capitalize',
|
||||||
color: theme.palette.primary.main,
|
color: theme.palette.primary.main,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue