Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: PWA page editor link in dashboard #329

Merged
merged 2 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions client/components/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Dashboard extends React.Component {
<div className="sd-grid-list sd-grid-list--large">
{this.state.tenants.map(tenant => (
<div className="sd-grid-item-wrapper" key={tenant.code}>
<Tenant tenant={tenant} />
<Tenant tenant={tenant} sessionToken={this.props.sessionToken}/>
</div>
))}
</div>
Expand All @@ -76,7 +76,8 @@ class Dashboard extends React.Component {
}

Dashboard.propTypes = {
publisher: PropTypes.object.isRequired
publisher: PropTypes.object.isRequired,
sessionToken: PropTypes.string.isRequired
};

export default Dashboard;
30 changes: 20 additions & 10 deletions client/components/Dashboard/Tenant.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import React from "react";
import PropTypes from "prop-types";

const Tenant = ({ tenant }) => {
const Tenant = ({ tenant, sessionToken }) => {
const tenant_href = tenant.pwa_config && tenant.pwa_config.url
? tenant.pwa_config.url
: tenant.output_channel
? tenant.output_channel.config.url
: tenant.subdomain
? "https://" + tenant.subdomain + "." + tenant.domain_name
: "https://" + tenant.domain_name;
return (
<React.Fragment>
<div className="sd-grid-item-header">
<h3 className="sd-grid-item-header__heading sd-overflow-ellipsis">
<a
target="_blank"
href={
tenant.pwa_config && tenant.pwa_config.url
? tenant.pwa_config.url
: tenant.output_channel
? tenant.output_channel.config.url
: tenant.subdomain
? "https://" + tenant.subdomain + "." + tenant.domain_name
: "https://" + tenant.domain_name
}
href={tenant_href}
flow="down"
>
<span>{tenant.name}</span>
Expand All @@ -41,6 +40,16 @@ const Tenant = ({ tenant }) => {
</div>
{!tenant.output_channel ? (
<div className="btn-icon-group">
{tenant.pwa_config && tenant.pwa_config.url && (
<a
href={tenant_href+"/page-editor?token="+sessionToken}
className="btn btn--icon-only-circle btn--large btn--hollow"
sd-tooltip="Theme Editor"
flow="down"
>
<i className="icon-edit-line"></i>
</a>
)}
<a
href={"#/publisher/analytics/" + tenant.code}
className="btn btn--icon-only-circle btn--large btn--hollow"
Expand Down Expand Up @@ -113,6 +122,7 @@ const Tenant = ({ tenant }) => {

Tenant.propTypes = {
tenant: PropTypes.object.isRequired,
sessionToken: PropTypes.string.isRequired
};

export default Tenant;
8 changes: 4 additions & 4 deletions client/controllers/WebPublisherDashboardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import React from "react";
import ReactDOM from "react-dom";
import Dashboard from "../components/Dashboard/Dashboard";

WebPublisherDashboardController.$inject = ["publisher"];
export function WebPublisherDashboardController(publisher) {
WebPublisherDashboardController.$inject = ["publisher", "session"];
export function WebPublisherDashboardController(publisher, session) {
class WebPublisherDashboard {
constructor() {
this.publisher = publisher;
this.publisher.setTenant();

ReactDOM.render(
<Dashboard publisher={this.publisher} />,
<Dashboard publisher={this.publisher} sessionToken={session.token.replace("Basic ", "")}/>,
document.getElementById("sp-dashboard-react-app")
);
}
Expand Down