diff --git a/cypress/e2e/53_workspaceMission.cy.ts b/cypress/e2e/53_workspaceMission.cy.ts index d6549dc2..cb889aa5 100644 --- a/cypress/e2e/53_workspaceMission.cy.ts +++ b/cypress/e2e/53_workspaceMission.cy.ts @@ -49,6 +49,42 @@ describe('Create Workspace And Update Mission', () => { cy.contains(missionStatment).should('exist', { timeout: 1000 }); cy.contains(tacticsStatment).should('exist', { timeout: 1000 }); + cy.get('button').contains('Add Repository').click(); + cy.wait(500); + + const repoName = 'Repo Name'; + cy.get('[data-testid="repo-name-input"]').type(repoName); + cy.get('[data-testid="repo-url-input"]').type('https://github.com/test/repo'); + cy.get('button').contains('Save').click(); + cy.wait(500); + + cy.contains('Add New Repository').should('not.exist'); + cy.get('h5').contains('Repositories').should('be.visible'); + cy.contains(repoName).should('exist', { timeout: 1000 }); + + cy.get('img[alt="Three dots icon"]').first().click(); + cy.wait(500); + + const updatedRepoName = 'Updated Repo'; + cy.get('[data-testid="repo-name-input"]').clear().type(updatedRepoName); + cy.get('[data-testid="repo-url-input"]').clear().type('https://github.com/updated/repo'); + cy.get('button').contains('Save').click(); + cy.wait(500); + + cy.contains('Add New Repository').should('not.exist'); + cy.contains(updatedRepoName).should('be.visible'); + cy.contains('https://github.com/updated/repo').should('be.visible'); + + cy.get('img[alt="Three dots icon"]').first().click(); + cy.get('button').contains('Delete').click(); + cy.wait(1000); + + cy.get('button').contains('Delete').click(); + cy.wait(1000); + + cy.contains(updatedRepoName).should('not.exist'); + cy.contains('https://github.com/updated/repo').should('not.exist'); + cy.logout('carol'); }); }); diff --git a/package.json b/package.json index d3f819fb..63450116 100644 --- a/package.json +++ b/package.json @@ -208,4 +208,4 @@ "devDependencies": { "cypress": "^13.6.3" } -} +} \ No newline at end of file diff --git a/src/components/common/DeleteConfirmationModal/DeleteConfirmationModal.tsx b/src/components/common/DeleteConfirmationModal/DeleteConfirmationModal.tsx index fd51635f..8407a139 100644 --- a/src/components/common/DeleteConfirmationModal/DeleteConfirmationModal.tsx +++ b/src/components/common/DeleteConfirmationModal/DeleteConfirmationModal.tsx @@ -40,6 +40,7 @@ export const DeleteConfirmationModal = ({ hovercolor={'#E96464'} activecolor={'#E15A5A'} shadowcolor={'#ED747480'} + data-testid="delete-confirmation" text="Delete" onClick={deleteHandler} /> diff --git a/src/pages/tickets/style.ts b/src/pages/tickets/style.ts index b4be453e..d7cf75fb 100644 --- a/src/pages/tickets/style.ts +++ b/src/pages/tickets/style.ts @@ -57,7 +57,28 @@ export const HeaderWrap = styled.div` export const DataWrap = styled.div` padding: 40px 50px; display: flex; - width: 50%; + width: 58%; + margin: 0 auto; + display: flex; + flex-direction: column; + align-items: left; + justify-content: center; + + @media only screen and (max-width: 900px) { + width: 90%; + padding: 30px 40px; + } + + @media only screen and (max-width: 500px) { + width: 90%; + padding: 20px 10px; + } +`; + +export const DataWrap2 = styled.div` + padding: 0px; + display: flex; + width: 100%; margin: 0 auto; display: flex; flex-direction: column; @@ -80,12 +101,13 @@ export const FieldWrap = styled.div` `; export const Label = styled.h5` - font-size: 1.12rem; + font-size: 1.1rem; font-weight: bolder; `; export const Data = styled.div` - border: 1px solid #ccc; + border: 2px solid #dde1e5; + caret-color: #618aff; min-height: 50px; border-radius: 5px; padding: 20px 30px; @@ -97,8 +119,8 @@ export const Data = styled.div` .MaterialIcon { font-style: normal; font-weight: 900; - font-size: 1.4rem; - color: #000000; + font-size: 1.3rem; + color: #36454f; } `; @@ -149,10 +171,6 @@ export const TextArea = styled.textarea` } `; -interface ButtonProps { - color?: string; -} - export const FeatureLabel = styled.p` color: var(--Text-2, #3c3f41); font-family: Barlow; @@ -187,3 +205,69 @@ export const Spacer = styled.div` height: 10px; width: 100%; `; + +export const PageContainer = styled.div` + display: flex; + align-items: center; +`; + +export const PaginationImg = styled.img` + cursor: pointer; +`; + +export const FlexDiv = styled.div` + display: flex; + justify-content: center; + align-items: center; + gap: 2px; + + .euiPopover__anchor { + margin-top: 6px !important; + } +`; + +export const FeatureLink = styled.a` + text-decoration: none; + color: #000; +`; + +export const StyledList = styled.ul` + padding: 0; + margin-top: 10px; +`; + +export const StyledListElement = styled.li` + display: flex; + align-items: center; +`; + +interface PaginationButtonsProps extends React.ButtonHTMLAttributes { + active: boolean; +} + +export const PaginationButtons = styled.button` + border-radius: 3px; + width: 30px; + height: 30px; + flex-shrink: 0; + outline: none; + border: none; + text-align: center; + margin: 5px; + background: ${(props: any) => (props.active ? 'var(--Active-blue, #618AFF)' : 'white')}; + color: ${(props: any) => (props.active ? 'white' : 'black')}; +`; + +export const ImgText = styled.h3` + color: #b0b7bc; + text-align: center; + font-family: 'Barlow'; + font-size: 1.875rem; + font-style: normal; + font-weight: 800; + line-height: 1.0625rem; + letter-spacing: 0.01875rem; + text-transform: uppercase; + opacity: 0.5; + margin-bottom: 0; +`; diff --git a/src/people/widgetViews/Icons/threeDotsIcon.svg b/src/people/widgetViews/Icons/threeDotsIcon.svg new file mode 100644 index 00000000..9aa4411b --- /dev/null +++ b/src/people/widgetViews/Icons/threeDotsIcon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/people/widgetViews/WorkspaceFeature.tsx b/src/people/widgetViews/WorkspaceFeature.tsx index 7e08f01c..db249f67 100644 --- a/src/people/widgetViews/WorkspaceFeature.tsx +++ b/src/people/widgetViews/WorkspaceFeature.tsx @@ -2,11 +2,6 @@ import { EuiGlobalToastList, EuiLoadingSpinner } from '@elastic/eui'; import { Body, FeatureBody, - FeatureLabel, - FeatureName, - Leftheader, - Header, - HeaderWrap, DataWrap, FieldWrap, Label, @@ -15,11 +10,19 @@ import { TextArea } from 'pages/tickets/style'; import React, { useCallback, useEffect, useState } from 'react'; +import history from 'config/history'; import { useParams } from 'react-router-dom'; import { useStores } from 'store'; import { Feature } from 'store/interface'; import MaterialIcon from '@material/react-material-icon'; -import { ActionButton, ButtonWrap } from './workspace/style'; +import { + ActionButton, + ButtonWrap, + HeadNameWrap, + FeatureHeadWrap, + WorkspaceName, + WorkspaceOption +} from './workspace/style'; type DispatchSetStateAction = React.Dispatch>; @@ -72,13 +75,15 @@ const WorkspaceEditableField = ({ onClick={() => setDisplayOptions(!displayOptions)} data-testid={`${dataTestIdPrefix}-option-btn`} /> - + {displayOptions && ( + +
    +
  • + Edit +
  • +
+
+ )} {!isEditing ? (
{ return ( - -
- - - {featureData?.name} - - -
-
+ + + history.goBack()} + icon={'arrow_back'} + style={{ + fontSize: 25, + cursor: 'pointer' + }} + /> + {featureData?.name} + + { - active: boolean; -} - -const PaginationButtons = styled.button` - border-radius: 3px; - width: 30px; - height: 30px; - flex-shrink: 0; - outline: none; - border: none; - text-align: center; - margin: 5px; - background: ${(props: any) => (props.active ? 'var(--Active-blue, #618AFF)' : 'white')}; - color: ${(props: any) => (props.active ? 'white' : 'black')}; -`; - -const PageContainer = styled.div` - display: flex; - align-items: center; -`; - -const PaginationImg = styled.img` - cursor: pointer; -`; - -const FlexDiv = styled.div` - display: flex; - justify-content: center; - align-items: center; - gap: 2px; - - .euiPopover__anchor { - margin-top: 6px !important; - } -`; - -const FeatureLink = styled.a` - text-decoration: none; - color: #000; -`; - const WorkspaceMission = () => { const { main, ui } = useStores(); const { uuid } = useParams<{ uuid: string }>(); @@ -159,6 +127,12 @@ const WorkspaceMission = () => { const [displayTactics, setDidplayTactics] = useState(false); const [mission, setMission] = useState(workspaceData?.mission); const [tactics, setTactics] = useState(workspaceData?.tactics); + const [repoName, setRepoName] = useState(''); + const [repoUrl, setRepoUrl] = useState(''); + const [repositories, setRepositories] = useState([]); + const [isModalVisible, setIsModalVisible] = useState(false); + const [currentuuid, setCurrentuuid] = useState(''); + const [modalType, setModalType] = useState('add'); const [featureModal, setFeatureModal] = useState(false); const [features, setFeatures] = useState([]); const [currentPage, setCurrentPage] = useState(1); @@ -167,9 +141,72 @@ const WorkspaceMission = () => { const paginationLimit = Math.floor(featuresCount / featureLimit) + 1; const visibleTabs = 3; - const isMobile = useIsMobile(); + const fetchRepositories = useCallback(async () => { + try { + const data = await main.getRepositories(uuid); + setRepositories(data); + } catch (error) { + console.error(error); + } + }, [main, uuid]); + + const openModal = (type: string, repository?: any) => { + if (type === 'add') { + setRepoName(''); + setCurrentuuid(''); + setRepoUrl(''); + setIsModalVisible(true); + setModalType(type); + } else if (type === 'edit') { + setRepoName(repository.name); + setCurrentuuid(repository.uuid); + setRepoUrl(repository.url); + setIsModalVisible(true); + setModalType(type); + } + }; + + const closeRepoModal = () => { + setIsModalVisible(false); + }; + + const DeleteRepository = async (workspace_uuid: string, repository_uuid: string) => { + try { + await main.deleteRepository(workspace_uuid, repository_uuid); + closeRepoModal(); + fetchRepositories(); + } catch (error) { + console.error('Error deleteRepository', error); + } + }; + + const handleDelete = () => { + closeRepoModal(); + DeleteRepository(uuid, currentuuid); + }; + + const { openDeleteConfirmation } = useDeleteConfirmationModal(); + + const deleteHandler = () => { + openDeleteConfirmation({ + onDelete: handleDelete, + children: ( + + Are you sure you want to
+ + Delete this Repo? + +
+ ) + }); + }; + + useEffect(() => { + fetchRepositories(); + }, [fetchRepositories]); + const getWorkspaceData = useCallback(async () => { if (!uuid) return; const workspaceData = await main.getUserWorkspaceByUuid(uuid); @@ -344,7 +381,7 @@ const WorkspaceMission = () => {
{ + + {workspaceData?.description} +
@@ -384,13 +424,15 @@ const WorkspaceMission = () => { onClick={() => setDidplayMission(!displayMission)} data-testid="mission-option-btn" /> - + {displayMission && ( + +
    +
  • + Edit +
  • +
+
+ )} {!editMission && ( <>{workspaceData?.mission ? workspaceData.mission : 'No mission yet'} @@ -434,13 +476,15 @@ const WorkspaceMission = () => { className="MaterialIcon" data-testid="tactics-option-btn" /> - + {displayTactics && ( + +
    +
  • + Edit +
  • +
+
+ )} {!editTactics && ( <>{workspaceData?.tactics ? workspaceData.tactics : 'No tactics yet'} @@ -474,6 +518,40 @@ const WorkspaceMission = () => { )} + + + + +