Skip to content

Commit

Permalink
Merge pull request #505 from stakwork/feat/workspace_mission
Browse files Browse the repository at this point in the history
Feat/workspace mission
  • Loading branch information
elraphty authored May 9, 2024
2 parents 9fefa20 + 0c5b5c0 commit 23f5c92
Show file tree
Hide file tree
Showing 16 changed files with 576 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/36_icanhelpFLow.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('I Can Help Flow', () => {

// Assert you can see Alice's Connect Modal QRcode
cy.contains('Discuss this bounty with').should('exist').and('be.visible');
cy.get('span.sc-pLyGp.cZiIZl').contains('alice').should('exist').and('be.visible');
cy.get('[data-testid="ican-help-alias"]').contains('alice').should('exist').and('be.visible');
cy.wait(1000);

cy.get('[data-testid="testid-connectimg"]')
Expand Down
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions cypress/e2e/53_workspaceMission.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
describe('Create Workspace And Update Mission', () => {
it('Creating an Workspace', () => {
cy.login('carol');
cy.wait(1000);

const WorkSpaceName = 'Workspace Mission5';

const workspace = {
loggedInAs: 'carol',
name: WorkSpaceName,
description: 'We are testing out our workspace mission',
website: 'https://community.sphinx.chat',
github: 'https://github.com/stakwork/sphinx-tribes-frontend'
};

cy.create_workspace(workspace);
cy.wait(1000);

cy.contains(workspace.name).contains('Manage').click();
cy.wait(1000);

cy.get('[data-testid="mission-link"]').then(($link: JQuery<HTMLElement>) => {
const modifiedHref = $link.attr('href');
cy.wrap($link).invoke('removeAttr', 'target');
cy.wrap($link).click();
cy.url().should('include', modifiedHref);
});
cy.wait(1000);

cy.contains('No mission yet');
cy.contains('No tactics yet');

cy.get('[data-testid="mission-option-btn"]').click();
cy.get('[data-testid="mission-edit-btn"]').click();

const missionStatment = 'This is my Mission';
cy.get('[data-testid="mission-textarea"]').type(missionStatment);
cy.get('[data-testid="mission-update-btn"]').click();
cy.get('[data-testid="mission-cancel-btn"]').click();

cy.get('[data-testid="tactics-option-btn"]').click();
cy.get('[data-testid="tactics-edit-btn"]').click();

const tacticsStatment = 'This is my Tactics';
cy.get('[data-testid="tactics-textarea"]').type(tacticsStatment);
cy.get('[data-testid="tactics-update-btn"]').click();
cy.get('[data-testid="tactics-cancel-btn"]').click();

cy.contains(missionStatment);
cy.contains(tacticsStatment);

cy.logout('carol');
});
});
File renamed without changes.
26 changes: 26 additions & 0 deletions src/components/form/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,32 @@ export const workspaceSchema: FormField[] = [
}
];

export const missionSchema: FormField[] = [
{
name: 'mission',
label: 'Mission',
type: 'textarea',
required: true,
validator: strValidator,
style: {
height: '100px',
width: '100%',
marginBottom: '30px'
}
},
{
name: 'tactics',
label: 'Tactics and Objectives',
type: 'textarea',
validator: strValidator,
style: {
height: '300px',
width: '100%',
backgroundColor: 'transaprent'
}
}
];

export const workspaceUserSchema: FormField[] = [
{
name: 'owner_pubkey',
Expand Down
4 changes: 4 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '@material/react-material-icon/dist/material-icon.css';
import { AppMode } from 'config';
import { Route, Switch } from 'react-router-dom';
import { observer } from 'mobx-react-lite';
import WorkspaceMission from 'people/widgetViews/WorkspaceMission';
import PeopleHeader from '../people/main/Header';
import TokenRefresh from '../people/utils/TokenRefresh';
import BotsBody from './bots/Body';
Expand Down Expand Up @@ -44,6 +45,9 @@ const modeDispatchPages: Record<AppMode, () => React.ReactElement> = {
<Route path="/workspace/bounties/:uuid">
<WorkspaceTicketsPage />
</Route>
<Route path="/workspace/:uuid">
<WorkspaceMission />
</Route>
<Route path="/leaderboard">
<LeaderboardPage />
</Route>
Expand Down
21 changes: 12 additions & 9 deletions src/pages/tickets/__tests__/WorkspaceHeader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const MockProps: WorkspaceBountyHeaderProps = {
},
languageString: '',
direction: 'desc',
org_uuid: 'clf6qmo4nncmf23du7ng',
workspace_uuid: 'clf6qmo4nncmf23du7ng',
onChangeStatus: jest.fn(),
onChangeLanguage: jest.fn(),
workspaceData: {
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('WorkspaceHeader Component', () => {
it('should call getSpecificWorkspaceBounties with correct parameters', () => {
Object.defineProperty(window, 'location', {
value: {
pathname: `/workspace/bounties/${MockProps.org_uuid}`
pathname: `/workspace/bounties/${MockProps.workspace_uuid}`
},
writable: true
});
Expand All @@ -132,7 +132,7 @@ describe('WorkspaceHeader Component', () => {
fireEvent.keyUp(searchInput, { key: 'Enter', code: 'Enter' });

// Check if getSpecificWorkspaceBounties is called with correct parameters
expect(mainStore.getSpecificWorkspaceBounties).toHaveBeenCalledWith(MockProps.org_uuid, {
expect(mainStore.getSpecificWorkspaceBounties).toHaveBeenCalledWith(MockProps.workspace_uuid, {
page: 1,
resetPage: true,
search: searchText,
Expand Down Expand Up @@ -194,12 +194,15 @@ describe('WorkspaceHeader Component', () => {
<WorkspaceHeader {...MockProps} checkboxIdToSelectedMap={updatedCheckboxIdToSelectedMap} />
);

expect(mainStore.getSpecificWorkspaceBounties).toHaveBeenCalledWith(MockProps.org_uuid, {
page: 1,
resetPage: true,
...updatedCheckboxIdToSelectedMap,
languageString: MockProps.languageString
});
expect(mainStore.getSpecificWorkspaceBounties).toHaveBeenCalledWith(
MockProps.workspace_uuid,
{
page: 1,
resetPage: true,
...updatedCheckboxIdToSelectedMap,
languageString: MockProps.languageString
}
);
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/pages/tickets/workspace/WorkspaceTickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function WorkspaceBodyComponent() {
useEffect(() => {
(async () => {
if (!uuid) return;
const orgData = await main.getUserWorkspaceByUuid(uuid);
if (!orgData) return;
setWorkspaceData(orgData);
const workspaceData = await main.getUserWorkspaceByUuid(uuid);
if (!workspaceData) return;
setWorkspaceData(workspaceData);

setLoading(false);
})();
Expand Down Expand Up @@ -197,7 +197,7 @@ function WorkspaceBodyComponent() {
checkboxIdToSelectedMapLanguage={checkboxIdToSelectedMapLanguage}
languageString={languageString}
workspaceData={workspaceData as Workspace}
org_uuid={uuid}
workspace_uuid={uuid}
totalBountyCount={WorkspaceTotalBounties}
/>
<>
Expand Down
20 changes: 10 additions & 10 deletions src/pages/tickets/workspace/workspaceHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const WorkspaceHeader = ({
checkboxIdToSelectedMapLanguage,
onChangeStatus,
checkboxIdToSelectedMap,
org_uuid,
workspace_uuid,
languageString,
workspaceData,
totalBountyCount
Expand Down Expand Up @@ -103,14 +103,14 @@ export const WorkspaceHeader = ({
const checkUserPermissions = async () => {
const isLoggedIn = !!ui.meInfo;
const hasPermission =
isLoggedIn && (await userCanManageBounty(org_uuid, ui.meInfo?.pubkey, main));
isLoggedIn && (await userCanManageBounty(workspace_uuid, ui.meInfo?.pubkey, main));
setCanPostBounty(hasPermission);
};

if (ui.meInfo && org_uuid) {
if (ui.meInfo && workspace_uuid) {
checkUserPermissions();
}
}, [ui.meInfo, org_uuid, main]);
}, [ui.meInfo, workspace_uuid, main]);

const selectedWidget = 'bounties';

Expand All @@ -129,8 +129,8 @@ export const WorkspaceHeader = ({
};

const handleSearch = (searchText: string) => {
if (org_uuid) {
main.getSpecificWorkspaceBounties(org_uuid, {
if (workspace_uuid) {
main.getSpecificWorkspaceBounties(workspace_uuid, {
page: 1,
resetPage: true,
...checkboxIdToSelectedMap,
Expand All @@ -154,16 +154,16 @@ export const WorkspaceHeader = ({
};

useEffect(() => {
if (org_uuid) {
main.getSpecificWorkspaceBounties(org_uuid, {
if (workspace_uuid) {
main.getSpecificWorkspaceBounties(workspace_uuid, {
page: 1,
resetPage: true,
...checkboxIdToSelectedMap,
languageString,
direction: sortDirection
});
}
}, [org_uuid, checkboxIdToSelectedMap, main, languageString, sortDirection]);
}, [workspace_uuid, checkboxIdToSelectedMap, main, languageString, sortDirection]);

const { name, img, description, website, github } = workspaceData;

Expand All @@ -185,7 +185,7 @@ export const WorkspaceHeader = ({
return () => {
window.removeEventListener('click', handleWindowClick);
};
}, [org_uuid, checkboxIdToSelectedMap, languageString, main, filterClick]);
}, [workspace_uuid, checkboxIdToSelectedMap, languageString, main, filterClick]);

useEffect(() => {
setStatusCountNumber(filterCount(checkboxIdToSelectedMap));
Expand Down
2 changes: 1 addition & 1 deletion src/people/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export interface WorkspaceBountyHeaderProps {
checkboxIdToSelectedMap?: any;
checkboxIdToSelectedMapLanguage?: any;
languageString?: string;
org_uuid?: string;
workspace_uuid?: string;
workspaceData: Workspace;
direction?: string;
totalBountyCount: number;
Expand Down
2 changes: 1 addition & 1 deletion src/people/utils/ConnectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function ConnectCard(props: ConnectCardProps) {
>
<N color={color}>Discuss this bounty with</N>
<D color={color}>
<B>{person?.owner_alias} </B>
<B data-testid="ican-help-alias">{person?.owner_alias} </B>
</D>

<QR value={qrString} size={210} type={'connect'} />
Expand Down
13 changes: 12 additions & 1 deletion src/people/utils/Constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
wantedCodingTaskSchema,
wantedOtherSchema,
workspaceSchema,
workspaceUserSchema
workspaceUserSchema,
missionSchema
} from '../../components/form/schema';

const MAX_UPLOAD_SIZE = 10194304; //10MB
Expand Down Expand Up @@ -53,6 +54,16 @@ const widgetConfigs = {
}
}
},
workspaceMission: {
label: 'Workspace Mision',
name: 'workspace mission',
submitText: 'Save',
schema: missionSchema,
action: {
text: 'Update Mission',
icon: 'add'
}
},
badges: {
label: 'Badges',
name: 'badges',
Expand Down
22 changes: 22 additions & 0 deletions src/people/widgetViews/WorkspaceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,28 @@ const WorkspaceDetails = (props: {
onClick={() => setIsOpenEditWorkspace(true)}
style={{ borderRadius: '5px' }}
/>
<Link
to={`/workspace/${uuid}`}
style={{
textDecoration: 'none',
color: 'inherit',
display: 'block'
}}
target="_blank"
data-testid="mission-link"
>
<Button
disabled={editWorkspaceDisabled}
text="Edit Mission"
data-testid="mission-btn"
color="white"
style={{
borderRadius: '5px',
width: '100%'
}}
endingIcon="open_in_new"
/>
</Link>
<Link
to={`/workspace/bounties/${uuid}`}
style={{ textDecoration: 'none', color: 'inherit', display: 'block' }}
Expand Down
Loading

0 comments on commit 23f5c92

Please sign in to comment.