Skip to content

Commit

Permalink
Merge branch 'main' into subscriptions-disable-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDarsa committed Jul 4, 2024
2 parents 88664a7 + 3f01f91 commit 8cade61
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/organizations/overview.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Organization overview page', () => {
overview.doQuotaFieldCheck();
});

it.only('Changes org friendly name/description', () => {
it('Changes org friendly name/description', () => {
registerIdleHandler('idle');

overview.changeOrgFriendlyname(testData.organizations.overview.friendlyName);
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/rbac/developer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('DEVELOPER permission test suites', () => {
environmentOverview.doDeleteEnvironmentError('main');
});

it('Deletes stating environment', () => {
it('Deletes staging environment', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging`);

cy.intercept('POST', Cypress.env('api'), req => {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('DEVELOPER permission test suites', () => {
});

it('Fails to cancel any deployment - no permission to CANCEL for DEVELOPER', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);

registerIdleHandler('idle');

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/rbac/guest.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('GUEST permission test suites', () => {
});

it('Fails to do cancel a deployment - no permission for GUEST', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);
registerIdleHandler('idle');

cy.intercept('POST', Cypress.env('api'), req => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/rbac/maintainer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('MAINTAINER permission test suites', () => {
environmentOverview.doDeleteEnvironmentError('main');
});

it('Deletes stating environment', () => {
it('Deletes staging environment', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging`);

cy.intercept('POST', Cypress.env('api'), req => {
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('MAINTAINER permission test suites', () => {
});

it('Cancels a staging deployment', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);

registerIdleHandler('idle');

Expand Down
4 changes: 3 additions & 1 deletion cypress/e2e/rbac/reporter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('REPORTER permission test suites', () => {
});

it('Fails to do cancel a deployment - no permission for REPORTER', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);

registerIdleHandler('idle');

Expand All @@ -168,6 +168,8 @@ describe('REPORTER permission test suites', () => {
cy.waitForNetworkIdle('@idle', 500);

deployment.navigateToRunningDeployment();

cy.waitForNetworkIdle('@idle', 500);
deployment.doFailedCancelDeployment();
});
});
Expand Down
9 changes: 5 additions & 4 deletions cypress/support/actions/organizations/OverviewAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default class OverviewAction {

changeOrgFriendlyname(friendlyName: string) {
overviewRepo.getNameEditButton('edit-name').click();
overviewRepo.getEditField().type(friendlyName);

overviewRepo.getEditField().clear().type(friendlyName);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation');
Expand All @@ -53,7 +54,7 @@ export default class OverviewAction {
}
doFailedChangeOrgFriendlyname(friendlyName: string) {
overviewRepo.getNameEditButton('edit-name').click();
overviewRepo.getEditField().type(friendlyName);
overviewRepo.getEditField().clear().type(friendlyName);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation').then(interception => {
Expand All @@ -68,7 +69,7 @@ export default class OverviewAction {

changeOrgDescription(description: string) {
overviewRepo.getDescEditButton('edit-description').click();
overviewRepo.getEditField().type(description);
overviewRepo.getEditField().clear().type(description);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation');
Expand All @@ -85,7 +86,7 @@ export default class OverviewAction {
}
doFailedChangeOrgDescription(description: string) {
overviewRepo.getDescEditButton('edit-description').click();
overviewRepo.getEditField().type(description);
overviewRepo.getEditField().clear().type(description);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation').then(interception => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/actions/organizations/ProjectsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class ProjectsActions {

projects.selectTarget();

projects.getAddConfirm().click();
projects.getAddConfirm().click({ force: true });

cy.wait('@gqladdProjectToOrganizationMutation');

Expand All @@ -32,7 +32,7 @@ export default class ProjectsActions {

projects.selectTarget();

projects.getAddConfirm().click();
projects.getAddConfirm().click({ force: true });

cy.wait('@gqladdProjectToOrganizationMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);
Expand Down
3 changes: 3 additions & 0 deletions src/components/Organizations/NewProject/StyledNewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const StyledNewProject = styled.div`
.form-box {
margin-bottom: 1rem;
&.spacetop {
margin-top: 1rem;
}
}
.docs-link {
Expand Down
78 changes: 77 additions & 1 deletion src/components/Organizations/NewProject/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const OrgNewProject = ({
refresh,
}) => {
const [addUserToProject, setAddUserToProject] = React.useState(true);
const [pullRequests, setPullRequests] = React.useState('');
const [branches, setBranches] = React.useState('');

return (
<StyledNotificationWrapper>
<div className="margins">
Expand All @@ -95,6 +98,8 @@ const OrgNewProject = ({
setProjectName({ target: { value: '' } });
setGitURL({ target: { value: '' } });
setProdEnv({ target: { value: '' } });
setPullRequests('');
setBranches('');
setSelectedDeployTarget({ target: { value: '' } });
closeModal();
});
Expand Down Expand Up @@ -174,6 +179,74 @@ const OrgNewProject = ({
/>
</RoleSelect>
</label>

<div className="form-box spacetop">
<label>
Branches{' '}
<Tooltip
overlayClassName="orgTooltip lg"
title={
<>
<b>[Default: true]</b>
<br />
<span> Which branches should be deployed, can be one of:</span>
<ul className="tooltiplist">
<li>true - all branches are deployed </li>

<li>false - no branches are deployed</li>

<li>
regex of all branches that can be deployed (including production), example:
'^(main|staging)$'
</li>
</ul>
</>
}
placement="right"
>
<InfoCircleOutlined style={{ fontSize: '1rem' }} />
</Tooltip>
<input
type="text"
placeholder="Branches"
value={branches}
onChange={({ target: { value } }) => setBranches(value)}
/>
</label>
</div>

<div className="form-box">
<label>
Pull requests{' '}
<Tooltip
overlayClassName="orgTooltip lg"
title={
<>
<b>[Default: true]</b>
<br />
<span> Which pull requests should be deployed, can be one of:</span>
<ul className="tooltiplist">
<li>true - all pull requests are deployed </li>

<li>false - no pull requests are deployed</li>

<li>regex of all Pull Request titles that can be deployed, example: '[BUILD]'</li>
</ul>
</>
}
placement="right"
>
<InfoCircleOutlined style={{ fontSize: '1rem' }} />
</Tooltip>
<input
placeholder="Pull requests"
type="text"
value={pullRequests}
onChange={({ target: { value } }) => setPullRequests(value)}
/>
</label>
</div>

<Checkbox>
<input
type="checkbox"
Expand All @@ -182,6 +255,7 @@ const OrgNewProject = ({
/>
<span>Add my user to this project</span>
</Checkbox>

<div className="docs-link">
<div className="info-icon">
<Image src={info} alt="" />
Expand Down Expand Up @@ -219,7 +293,7 @@ const OrgNewProject = ({
inputGitURL.indexOf(' ') > 0 ||
inputProdEnv === '' ||
inputProdEnv.indexOf(' ') > 0 ||
selectedDeployTarget === undefined
selectedDeployTarget == undefined
}
action={() => {
addGroupProject({
Expand All @@ -230,6 +304,8 @@ const OrgNewProject = ({
productionEnvironment: inputProdEnv,
organization: parseInt(organizationId, 10),
addOrgOwner: addUserToProject,
...(pullRequests ? { pullRequests } : {}),
...(branches ? { branches } : {}),
},
});
}}
Expand Down
34 changes: 27 additions & 7 deletions src/components/Organizations/Organization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ const Organization = ({ organization, refetch }) => {
}

const [nameModalOpen, setNameModalOpen] = useState(false);
const [friendlyName, setFriendlyName] = useState('');
const [friendlyName, setFriendlyName] = useState(organization.friendlyName);

const [descModalOpen, setDescModalOpen] = useState(false);
const [description, setDescription] = useState('');
const [description, setDescription] = useState(organization.description);

const quotaDisplay = (quota, quotaNumber, quotaLimit, showLink = true) => {
const pluralName = quota + 's';
Expand Down Expand Up @@ -93,9 +93,29 @@ const Organization = ({ organization, refetch }) => {
};

const renderEditBtn = type => (
<EditOutlined data-cy={`edit-${type}`} style={{ color: '#4578E6' }} onClick={modalAction('open', type)} />
<EditOutlined
data-cy={`edit-${type}`}
style={{ color: '#4578E6' }}
onClick={() => {
if (type === 'name') {
setFriendlyName(organization.friendlyName);
}
if (type === 'description') {
setDescription(organization.description);
}

modalAction('open', type)();
}}
/>
);

const handleFriendlyNameChange = e => {
setFriendlyName(e.target.value);
};

const handleDescriptionChange = e => {
setDescription(e.target.value);
};
return (
<StyledOrganization>
<OrgHeader headerText="overview" />
Expand All @@ -117,12 +137,12 @@ const Organization = ({ organization, refetch }) => {
<label>
Organization name: <span style={{ color: '#E30000' }}>*</span>
<input
autoFocus
className="inputName"
data-cy="input-orgName"
type="text"
placeholder="Existing organization name"
value={friendlyName}
onChange={e => setFriendlyName(e.target.value)}
onChange={handleFriendlyNameChange}
/>
</label>
</div>
Expand Down Expand Up @@ -188,12 +208,12 @@ const Organization = ({ organization, refetch }) => {
<label>
Organization description: <span style={{ color: '#E30000' }}>*</span>
<input
autoFocus
className="inputName"
data-cy="input-orgName"
type="text"
placeholder="Org description"
value={description}
onChange={e => setDescription(e.target.value)}
onChange={handleDescriptionChange}
/>
</label>
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/layouts/GlobalStyles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ body {
.ant-tooltip-content .ant-tooltip-inner{
color: ${props => (props.theme.colorScheme === 'dark' ? '#000' : '#fff')};
background: ${props => (props.theme.colorScheme === 'dark' ? '#fff' : '#000')};
.tooltiplist{
margin-left: 0.812rem;
li{
margin-bottom: initial;
padding-left: 0;
list-style: disc;
}
}
}
&.lg{
.ant-tooltip-content{
width:max-content;
}
}
}
.componentTooltip {
Expand Down

0 comments on commit 8cade61

Please sign in to comment.