Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

enhancement: show tenant status message (#704)

Guilherme Oenningdf441788440a
diff --git a/app/models/identity.go b/app/models/identity.go
index ab42af43c..c7de5a311 100644
--- a/app/models/identity.go
+++ b/app/models/identity.go
@@ -15,7 +15,7 @@ type Tenant struct {
Invitation string `json:"invitation"`
WelcomeMessage string `json:"welcomeMessage"`
CNAME string `json:"cname"`
- Status int `json:"-"`
+ Status int `json:"status"`
IsPrivate bool `json:"isPrivate"`
LogoBlobKey string `json:"logoBlobKey"`
CustomCSS string `json:"-"`
diff --git a/app/pkg/web/testdata/tenant.html b/app/pkg/web/testdata/tenant.html
index dda074327..18534cf11 100755
--- a/app/pkg/web/testdata/tenant.html
+++ b/app/pkg/web/testdata/tenant.html
@@ -40,7 +40,7 @@
<script id="server-data" type="application/json">
- {"__assets":{"CSS":["/assets/css/file1.css"],"JS":["/assets/js/file1.js","/assets/js/file2.js"]},"__contextID":"CONTEXT_ID","__currentURL":"https://demo.test.fider.io:3000/","__favicon":"https://demo.test.fider.io:3000/favicon","__logo":"https://getfider.com/images/logo-100x100.png","__props":null,"__settings":{"baseURL":"https://demo.test.fider.io:3000","buildTime":"","compiler":"","domain":"","environment":"","globalAssetsURL":"https://demo.test.fider.io:3000","googleAnalytics":"","hasLegal":false,"mode":"","oauth":[],"stripePublicKey":"","tenantAssetsURL":"https://demo.test.fider.io:3000","version":""},"__tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","cname":"","isPrivate":false,"logoBlobKey":""},"__title":"Game of Thrones"}
+ {"__assets":{"CSS":["/assets/css/file1.css"],"JS":["/assets/js/file1.js","/assets/js/file2.js"]},"__contextID":"CONTEXT_ID","__currentURL":"https://demo.test.fider.io:3000/","__favicon":"https://demo.test.fider.io:3000/favicon","__logo":"https://getfider.com/images/logo-100x100.png","__props":null,"__settings":{"baseURL":"https://demo.test.fider.io:3000","buildTime":"","compiler":"","domain":"","environment":"","globalAssetsURL":"https://demo.test.fider.io:3000","googleAnalytics":"","hasLegal":false,"mode":"","oauth":[],"stripePublicKey":"","tenantAssetsURL":"https://demo.test.fider.io:3000","version":""},"__tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"isPrivate":false,"logoBlobKey":""},"__title":"Game of Thrones"}
</script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,fetch" crossorigin="anonymous"></script>
diff --git a/public/components/common/Header.tsx b/public/components/common/Header.tsx
index 6c2531d82..5f808b630 100644
--- a/public/components/common/Header.tsx
+++ b/public/components/common/Header.tsx
@@ -1,7 +1,7 @@
import "./Header.scss";
import React from "react";
-import { SignInModal, EnvironmentInfo, Avatar, TenantLogo } from "@fider/components";
+import { SignInModal, EnvironmentInfo, Avatar, TenantLogo, TenantStatusInfo } from "@fider/components";
import { actions, Fider } from "@fider/services";
import { FaUser, FaCog, FaCaretDown } from "react-icons/fa";
@@ -86,6 +86,7 @@ export class Header extends React.Component<{}, HeaderState> {
)}
</div>
</div>
+ <TenantStatusInfo />
</div>
);
}
diff --git a/public/components/common/TenantStatusInfo.tsx b/public/components/common/TenantStatusInfo.tsx
new file mode 100644
index 000000000..97d03f305
--- /dev/null
+++ b/public/components/common/TenantStatusInfo.tsx
@@ -0,0 +1,19 @@
+import React from "react";
+import { Fider } from "@fider/services";
+import { TenantStatus } from "@fider/models";
+import { Message } from "./Message";
+
+export const TenantStatusInfo = () => {
+ if (!Fider.isBillingEnabled() || Fider.session.tenant.status !== TenantStatus.Locked) {
+ return null;
+ }
+
+ return (
+ <div className="container">
+ <Message type="error">
+ This site is locked due to lack of a subscription. Visit the <a href="/admin/billing">Billing</a> settings to
+ update it.
+ </Message>
+ </div>
+ );
+};
diff --git a/public/components/common/index.tsx b/public/components/common/index.tsx
index 6d88ca0cd..5a3b6c1f4 100644
--- a/public/components/common/index.tsx
+++ b/public/components/common/index.tsx
@@ -10,6 +10,7 @@ export * from "./form/Field";
export * from "./form/Checkbox";
export * from "./MultiLineText";
export * from "./EnvironmentInfo";
+export * from "./TenantStatusInfo";
export * from "./Avatar";
export * from "./Message";
export * from "./Hint";
diff --git a/public/models/identity.ts b/public/models/identity.ts
index 8e0ec3b61..b18d38721 100644
--- a/public/models/identity.ts
+++ b/public/models/identity.ts
@@ -5,10 +5,17 @@ export interface Tenant {
subdomain: string;
invitation: string;
welcomeMessage: string;
+ status: TenantStatus;
isPrivate: boolean;
logoBlobKey: string;
}
+export enum TenantStatus {
+ Active = 1,
+ Pending = 2,
+ Locked = 3
+}
+
export interface User {
id: number;
name: string;
diff --git a/public/pages/Home/components/PostsContainer.tsx b/public/pages/Home/components/PostsContainer.tsx
index b87f21729..6ddfb8c50 100644
--- a/public/pages/Home/components/PostsContainer.tsx
+++ b/public/pages/Home/components/PostsContainer.tsx
@@ -63,7 +63,7 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsCo
this.setState({ posts: reset ? undefined : this.state.posts, loading: true });
this.timer = window.setTimeout(() => {
actions.searchPosts({ query, view, limit, tags }).then(response => {
- if (this.state.loading) {
+ if (response.ok && this.state.loading) {
this.setState({ loading: false, posts: response.data });
}
});
diff --git a/public/pages/Home/components/SimilarPosts.tsx b/public/pages/Home/components/SimilarPosts.tsx
index 0f3dc3148..6bc4f7588 100644
--- a/public/pages/Home/components/SimilarPosts.tsx
+++ b/public/pages/Home/components/SimilarPosts.tsx
@@ -49,7 +49,9 @@ export class SimilarPosts extends React.Component<SimilarPostsProps, SimilarPost
private loadSimilarPosts = () => {
if (this.state.loading) {
actions.searchPosts({ query: this.state.title }).then(x => {
- this.setState({ loading: false, posts: x.data });
+ if (x.ok) {
+ this.setState({ loading: false, posts: x.data });
+ }
});
}
};
diff --git a/public/pages/ShowPost/components/PostSearch.tsx b/public/pages/ShowPost/components/PostSearch.tsx
index 91480c88d..9fe402472 100644
--- a/public/pages/ShowPost/components/PostSearch.tsx
+++ b/public/pages/ShowPost/components/PostSearch.tsx
@@ -36,11 +36,13 @@ export class PostSearch extends React.Component<PostSearchProps, PostSearchState
window.clearTimeout(this.timer);
this.timer = window.setTimeout(() => {
actions.searchPosts({ query: searchQuery }).then(res => {
- const posts =
- this.props.exclude && this.props.exclude.length > 0
- ? res.data.filter(i => this.props.exclude!.indexOf(i.number) === -1)
- : res.data;
- this.setState({ posts });
+ if (res.ok) {
+ const posts =
+ this.props.exclude && this.props.exclude.length > 0
+ ? res.data.filter(i => this.props.exclude!.indexOf(i.number) === -1)
+ : res.data;
+ this.setState({ posts });
+ }
});
}, 200);
};