Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Commit

Permalink
[BB-3618] Implement page structure (#714)
Browse files Browse the repository at this point in the history
* Added the initial implementation of the new page structure

This commit adds the initial implementation of page structure
where we are trying to revamp the UI.

Signed-off-by: Farhaan Bukhsh <farhaan@opencraft.com>
  • Loading branch information
farhaanbukhsh committed Mar 9, 2021
1 parent c1183fe commit edcb1fa
Show file tree
Hide file tree
Showing 32 changed files with 2,477 additions and 77 deletions.
Expand Up @@ -3,6 +3,10 @@ const messages = {
defaultMessage:
'This page is not accessible by staff users yet. Use <link>this link</link> instead.',
description: 'Error message for staff users'
},
back: {
defaultMessage: 'Back',
description: 'Back button to go to last page'
}
};

Expand Down
Expand Up @@ -40,7 +40,7 @@ it('Correctly renders button with Studio link', () => {
}
).toJSON();

const manageCoursesBtn = getChild(tree, [1,0,0,0,1,0,0,3,0]);
const manageCoursesBtn = getChild(tree, [1,0,0,0,1,0,0,0,3,0]);

expect(manageCoursesBtn.props.href).toEqual('test-url');
});
130 changes: 66 additions & 64 deletions frontend/src/console/components/CoursesManage/CoursesManage.tsx
@@ -1,9 +1,6 @@
import * as React from 'react';
import { InstancesModel } from 'console/models';
import {
ConsolePage,
ConsolePageCustomizationContainer
} from 'console/components';
import { ConsolePage, PreviewBox } from 'newConsole/components';
import { CONTACT_US_LINK } from 'global/constants';
import { WrappedMessage } from 'utils/intl';
import { Col, Button, Row } from 'react-bootstrap';
Expand Down Expand Up @@ -39,68 +36,73 @@ export class CoursesManageComponent extends React.PureComponent<Props, State> {
}

return (
<ConsolePage contentLoading={this.props.loading}>
<div className="courses-page">
<ConsolePageCustomizationContainer>
<h2>
<WrappedMessage id="title" messages={messages} />
</h2>
<WrappedMessage id="explanation" messages={messages} />
<div className="list-items">
<Row>
<Col xs={1}>
<div className="number-circle">
<p>1</p>
</div>
</Col>
<Col>
<WrappedMessage
id="instructions_access"
messages={messages}
/>
</Col>
</Row>
<Row>
<Col xs={1}>
<div className="number-circle">
<p>2</p>
</div>
</Col>
<Col>
<WrappedMessage
id="instructions_credentials"
messages={messages}
/>
</Col>
</Row>
</div>
<ConsolePage
contentLoading={this.props.loading}
showSideBarEditComponent={false}
>
<PreviewBox>
<div className="courses-page">
<div>
<h2 className="course-page-title">
<WrappedMessage id="title" messages={messages} />
</h2>
<WrappedMessage id="explanation" messages={messages} />
<div className="list-items">
<Row>
<Col xs={1}>
<div className="number-circle">
<p>1</p>
</div>
</Col>
<Col className="studio-info">
<WrappedMessage
id="instructions_access"
messages={messages}
/>
</Col>
</Row>
<Row>
<Col xs={1}>
<div className="number-circle">
<p>2</p>
</div>
</Col>
<Col className="studio-info">
<WrappedMessage
id="instructions_credentials"
messages={messages}
/>
</Col>
</Row>
</div>

<p>
<a href={instanceLink}>
<Button
className="manageBtn"
disabled={instanceLink === ''}
size="lg"
>
<WrappedMessage messages={messages} id="button_text" />
<i className="fas fa-external-link-alt fa-m" />
</Button>
</a>
</p>
<p>
<a href={instanceLink}>
<Button
className="manageBtn"
disabled={instanceLink === ''}
size="lg"
>
<WrappedMessage messages={messages} id="button_text" />
<i className="fas fa-external-link-alt fa-m" />
</Button>
</a>
</p>

<h6>
<WrappedMessage id="help_text" messages={messages} />
<a
className="support-link"
href={CONTACT_US_LINK}
target="_blank"
rel="noopener noreferrer"
>
<WrappedMessage id="help_link" messages={messages} />
</a>
</h6>
</ConsolePageCustomizationContainer>
</div>
<h6>
<WrappedMessage id="help_text" messages={messages} />
<a
className="support-link"
href={CONTACT_US_LINK}
target="_blank"
rel="noopener noreferrer"
>
<WrappedMessage id="help_link" messages={messages} />
</a>
</h6>
</div>
</div>
</PreviewBox>
</ConsolePage>
);
}
Expand Down
Expand Up @@ -49,22 +49,22 @@ exports[`renders without crashing 1`] = `
/>
</div>
<div
className="console-page-container"
className="new-console-page-container"
>
<div
className="console-page-content row"
className="new-console-page-content row"
>
<div
className="container-fluid"
>
<div
className="row"
className="justify-content-center row"
>
<div
className="col-md-3"
>
<div
className="customization-menu accordion"
className="new-customization-menu accordion"
>
<div
className="card"
Expand Down Expand Up @@ -292,7 +292,7 @@ exports[`renders without crashing 1`] = `
</div>
</div>
<div
className="col-md-9"
className="col-md-7"
>
<div
className="customization-form"
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/console/components/CoursesManage/styles.scss
Expand Up @@ -3,13 +3,14 @@
.courses-page {
// Only put this because the page didn't pick up the right font family.
font-family: $chivo-font;
padding: 5%;

p {
margin-top: 20px;
}

.row {
margin-bottom: 5px;
margin-bottom: 10px;
}

.number-circle {
Expand Down Expand Up @@ -48,4 +49,20 @@
padding-left: 10px;
}
}

.course-page-title {
font-family: PlayfairDisplay;
font-size: 30px;
font-weight: bold;
color: #1e4c59;
text-align: left;
}
}

.studio-info {
margin-left: -2%;
}

.manageBtn {
font-size: 14px;
}
3 changes: 3 additions & 0 deletions frontend/src/global/constants.ts
Expand Up @@ -66,6 +66,9 @@ export const ROUTES = {
THEME_FOOTER: '/console/theming/footer',
INSTANCE_SETTINGS_GENERAL: '/console/settings/general',
HERO: '/console/theming/hero',
NEW_HOME: '/newconsole',
NEW_LOGOS: '/newconsole/theming/logos',
NEW_LOGOS_SIDEBAR: '/newconsole/theming/logos/sidebar',
COURSES: '/console/courses/manage'
},
Registration: {
Expand Down
@@ -0,0 +1,8 @@
import React from 'react';
import { setupComponentForTesting } from "utils/testing";
import { PreviewBox } from './PreviewBox';

it('renders without crashing', () => {
const tree = setupComponentForTesting(<PreviewBox />).toJSON();
expect(tree).toMatchSnapshot();
});
13 changes: 13 additions & 0 deletions frontend/src/newConsole/components/PreviewBox/PreviewBox.tsx
@@ -0,0 +1,13 @@
import * as React from 'react';
import { Card } from 'react-bootstrap';
import './style.scss';

interface PreviewBoxProps {
children?: React.ReactNode;
}

export const PreviewBox: React.FC<PreviewBoxProps> = (
props: PreviewBoxProps
) => {
return <Card className="preview-box">{props.children}</Card>;
};
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders without crashing 1`] = `
<div
className="preview-box card"
/>
`;
1 change: 1 addition & 0 deletions frontend/src/newConsole/components/PreviewBox/index.ts
@@ -0,0 +1 @@
export * from './PreviewBox';
5 changes: 5 additions & 0 deletions frontend/src/newConsole/components/PreviewBox/style.scss
@@ -0,0 +1,5 @@
.preview-box {
height: 100%;
box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.3);
width: 95%;
}
4 changes: 4 additions & 0 deletions frontend/src/newConsole/components/index.ts
@@ -0,0 +1,4 @@
export * from './newConsolePage';
export * from './newCustomizationSideMenu';
export * from './newLogos';
export * from './PreviewBox';
106 changes: 106 additions & 0 deletions frontend/src/newConsole/components/newConsolePage/ConsolePage.spec.tsx
@@ -0,0 +1,106 @@
import React from 'react';
import { setupComponentForTesting } from "utils/testing";
import { ConsolePage } from './ConsolePage';


describe("Console Page", function() {
it('Correctly renders loading page', () => {
const tree = setupComponentForTesting(
<ConsolePage contentLoading={true} showSideBarEditComponent={false}>
<span> Test! </span>
</ConsolePage>,
{
console: {
loading: true
}
}
).toJSON();
expect(tree).toMatchSnapshot();
});

describe("Console Page with Edit component", function() {
it('Correctly renders loading page', () => {
const tree = setupComponentForTesting(
<ConsolePage contentLoading={true} showSideBarEditComponent={true}>
<span> Test! </span>
</ConsolePage>,
{
console: {
loading: true
}
}
).toJSON();
expect(tree).toMatchSnapshot();
});
});

it('Correctly renders page with data', () => {
const tree = setupComponentForTesting(
<ConsolePage contentLoading={false} showSideBarEditComponent={false}>
<span> Test! </span>
</ConsolePage>,
{
console: {
loading: false,
activeInstance: {
data: {
id: 1,
instanceName: "test",
subdomain: "test",
lmsUrl: "test-url",
studioUrl: "test-url",
isEmailVerified: true,
},
deployment: {
status: "preparing",
undeployedChanges: [],
deployedChanges: null,
type: 'admin',
}
},
instances: [{
id: 1,
instanceName: "test",
subdomain: "test",
}]
}
}
).toJSON();
expect(tree).toMatchSnapshot();
});

it('Correctly renders page with email not verified alert', () => {
const tree = setupComponentForTesting(
<ConsolePage contentLoading={false} showSideBarEditComponent={false}>
<span> Test! </span>
</ConsolePage>,
{
console: {
loading: false,
activeInstance: {
data: {
id: 1,
instanceName: "test",
subdomain: "test",
lmsUrl: "test-url",
studioUrl: "test-url",
isEmailVerified: false,
},
deployment: {
status: "preparing",
undeployedChanges: [],
deployedChanges: null,
type: 'admin',
}
},
instances: [{
id: 1,
instanceName: "test",
subdomain: "test",
}]
}
}
).toJSON();
expect(tree).toMatchSnapshot();
});
});

0 comments on commit edcb1fa

Please sign in to comment.