diff --git a/src/dashboard/Apps/AppsIndex.react.js b/src/dashboard/Apps/AppsIndex.react.js
index 714925e4b8..229ed622c9 100644
--- a/src/dashboard/Apps/AppsIndex.react.js
+++ b/src/dashboard/Apps/AppsIndex.react.js
@@ -186,13 +186,10 @@ class AppsIndex extends React.Component {
window.location = `${b4aSettings.DASHBOARD_PATH}/apps/new`}
- secondaryCta="Go to database hub"
- // eslint-disable-next-line no-undef
- secondaryAction={() => window.location = b4aSettings.HUB_URL} />
+ action={() => window.location = `${b4aSettings.DASHBOARD_PATH}/apps/new`} />
);
}
diff --git a/src/dashboard/B4aHubPublishPage/B4aHubPublishModal.js b/src/dashboard/B4aHubPublishPage/B4aHubPublishModal.js
deleted file mode 100644
index d28e5486d2..0000000000
--- a/src/dashboard/B4aHubPublishPage/B4aHubPublishModal.js
+++ /dev/null
@@ -1,85 +0,0 @@
-import React from 'react'
-import ReactDOMServer from 'react-dom/server'
-import Swal from 'sweetalert2'
-import styles from 'dashboard/B4aHubPublishPage/B4aHubPublishPage.scss'
-
-const show = (currentApp, onPublished) => {
- let result;
-
- Swal.mixin({
- confirmButtonText: 'Publish',
- showCancelButton: true,
- reverseButtons: true,
- padding: '2.5em'
- }).queue([
- {
- title: 'Publish on Database Hub',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
-
-
-
-
- I understand that the data of this app will become public, and I confirm that there is no private or sensitive data in any class of this app.
-
-
-
- ),
- preConfirm: async () => {
- const confirmHubPublishButton = document.getElementById('confirmHubPublish');
-
- if (!confirmHubPublishButton.checked) {
- Swal.showValidationMessage('Please read and mark the box to agree.');
- return;
- }
-
- confirmHubPublishButton.disabled = true;
-
- Swal.showLoading()
-
- try {
- result = await currentApp.publishOnHub()
- } catch (e) {
- Swal.deleteQueueStep(1);
- Swal.insertQueueStep({
- type: 'error',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
- {e.message || 'Something wrong happened in our side. Please try again later.'}
-
-
- ),
- showConfirmButton: false,
- cancelButtonText: 'Got it!',
- });
- return;
- }
-
- onPublished(result);
- }
- },
- {
- type: 'success',
- html: ReactDOMServer.renderToStaticMarkup(
-
- ),
- showCancelButton: false,
- confirmButtonText: 'Got it!',
- onBeforeOpen: () => {
- const a = Swal.getContent().querySelector('a')
- if (a) a.href = a.text = `https://www.back4app.com/database/${result.author.slug}/${result.database.slug}`
- }
- }
- ])
-}
-
-export default { show }
diff --git a/src/dashboard/B4aHubPublishPage/B4aHubPublishPage.react.js b/src/dashboard/B4aHubPublishPage/B4aHubPublishPage.react.js
deleted file mode 100644
index a6f7080222..0000000000
--- a/src/dashboard/B4aHubPublishPage/B4aHubPublishPage.react.js
+++ /dev/null
@@ -1,180 +0,0 @@
-import React from 'react'
-import ReactDOMServer from 'react-dom/server'
-import CategoryList from "components/CategoryList/CategoryList.react";
-import DashboardView from 'dashboard/DashboardView.react'
-import Toolbar from 'components/Toolbar/Toolbar.react'
-import Fieldset from 'components/Fieldset/Fieldset.react';
-import styles from 'dashboard/B4aHubPublishPage/B4aHubPublishPage.scss'
-import ReactPlayer from 'react-player';
-import Label from 'components/Label/Label.react';
-import Button from 'components/Button/Button.react';
-import Field from 'components/Field/Field.react';
-import B4aHubPublishModal from 'dashboard/B4aHubPublishPage/B4aHubPublishModal'
-import B4aHubUnpublishModal from 'dashboard/B4aHubPublishPage/B4aHubUnpublishModal'
-import Swal from 'sweetalert2'
-import B4aLoaderContainer from 'components/B4aLoaderContainer/B4aLoaderContainer.react';
-import { CurrentApp } from 'context/currentApp';
-
-
-class B4aHubPublishPage extends DashboardView {
- static contextType = CurrentApp;
- constructor() {
- super()
- this.section = 'More',
- this.subsection = 'Database HUB'
- this.state = {
- url: undefined
- }
- this.state = {
- loading: true,
- isDatabasePublic: false,
- publicDatabaseURL: undefined
- }
- }
-
- async componentDidMount() {
- if (!this.context.custom.isDatabasePublic) {
- this.setState({
- loading: false
- })
- return
- }
-
- const publicDatabase = await this.context.getPublicDatabase()
-
- this.setState({
- loading: false,
- isDatabasePublic: true,
- publicDatabaseURL: publicDatabase && publicDatabase.author && `https://www.back4app.com/database/${publicDatabase.author.slug}/${publicDatabase.slug}`
- })
- }
-
- renderSidebar() {
- const { path } = this.props.match;
- const current = path.substr(path.lastIndexOf("/") + 1, path.length - 1);
- return (
-
- );
- }
-
-
- renderContent() {
- return (
-
-
-
-
-
- }
- input={
- {this.state.isDatabasePublic ? (
-
{
- if (!this.context.custom.isOwner) {
- Swal.queue([{
- type: 'error',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
- Sorry, you must be the app owner to unpublish it from Database Hub.
-
-
- )
- }])
- return;
- }
- B4aHubUnpublishModal.show(this.context, () => {
- this.setState({
- isDatabasePublic: false,
- publicDatabaseURL: undefined
- })
- })
- }}
- value="Unpublish from Hub"
- color="red"
- primary={true}
- className={styles['input-child']}
- />
- ) : (
- {
- if (!this.context.custom.isOwner) {
- Swal.queue([{
- type: 'error',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
- Sorry, you must be the app owner to publish it on Database Hub.
-
-
- )
- }])
- return;
- }
- if (this.context.custom.isGDPR) {
- Swal.queue([{
- type: 'error',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
- Sorry, you can not publish a GDPR App.
-
-
- )
- }])
- return;
- }
- B4aHubPublishModal.show(this.context, result => {
- this.setState({
- isDatabasePublic: true,
- publicDatabaseURL: `https://www.back4app.com/database/${result.author.slug}/${result.database.slug}`
- })
- })
- }}
- value="Publish on Hub"
- primary={true}
- className={styles['input-child']}
- />
- )}
- }
- />
- {this.state.isDatabasePublic && (
- }
- input={}>
-
- )}
-
-
-
- )
- }
-}
-
-export default B4aHubPublishPage
diff --git a/src/dashboard/B4aHubPublishPage/B4aHubPublishPage.scss b/src/dashboard/B4aHubPublishPage/B4aHubPublishPage.scss
deleted file mode 100644
index 5758a1f9b4..0000000000
--- a/src/dashboard/B4aHubPublishPage/B4aHubPublishPage.scss
+++ /dev/null
@@ -1,63 +0,0 @@
-@import 'stylesheets/back4app.scss';
-
-.loading {
- position: relative;
- min-height: $content-max-height;
-}
-
-.hub-publish-page {
- background-color: #f9f9f9;
- min-height: $content-max-height;
- padding-top: 70px;
- overflow: hidden;
-}
-
-.input {
- background-color: #f6fafb;
- min-height: -webkit-fill-available;
- min-height: -moz-fill-available;
- min-height: fill-available;
- border: 0 solid #e3e3e3;
- border-left-width: 1px;
-
- .input-child {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- max-width: 260px;
- overflow-wrap: break-word;
- }
-}
-
-.elements-wrapper {
- display: flex;
- margin-top: 10px;
- margin-bottom: 10px;
-
- .input-wrapper {
- display: flex;
- margin-right: 16px;
- align-items: center;
- }
-
- .label-wrapper {
- text-align: left;
- }
-}
-
-.congrats-box {
- display: block;
-
- .congrats-message {
- font-weight: bold;
- text-align: center;
- margin-bottom: 35px;
- }
-
- .anchor-url {
- font-size: 0.75em;
- flex-basis: 100%;
- text-align: center;
- }
-}
diff --git a/src/dashboard/B4aHubPublishPage/B4aHubUnpublishModal.js b/src/dashboard/B4aHubPublishPage/B4aHubUnpublishModal.js
deleted file mode 100644
index 69a7aea7d3..0000000000
--- a/src/dashboard/B4aHubPublishPage/B4aHubUnpublishModal.js
+++ /dev/null
@@ -1,65 +0,0 @@
-import React from 'react'
-import ReactDOMServer from 'react-dom/server'
-import Swal from 'sweetalert2'
-import styles from 'dashboard/B4aHubPublishPage/B4aHubPublishPage.scss'
-
-const show = (currentApp, onUnpublished) => {
- Swal.mixin({
- confirmButtonText: 'Yes, unpublish',
- confirmButtonColor: '#E02424',
- showCancelButton: true,
- reverseButtons: true,
- padding: '2.5em'
- }).queue([
- {
- type: 'warning',
- title: 'Unpublish from Database Hub',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
- Are you sure that you want to unpublish this app from Database Hub? Nobody will be able to connect to or clone it anymore and all customizations will be lost.
-
-
- ),
- preConfirm: async () => {
- Swal.showLoading()
-
- try {
- await currentApp.unpublishFromHub()
- } catch (e) {
- Swal.deleteQueueStep(1);
- Swal.insertQueueStep({
- type: 'error',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
- {e.message || 'Something wrong happened in our side. Please try again later.'}
-
-
- ),
- showConfirmButton: false,
- cancelButtonText: 'Got it!',
- });
- return;
- }
-
- onUnpublished();
- }
- },
- {
- type: 'success',
- html: ReactDOMServer.renderToStaticMarkup(
-
-
- Your app was successfully unpublished from Database Hub.
-
-
- ),
- showCancelButton: false,
- confirmButtonText: 'Got it!',
- confirmButtonColor: '#3085d6'
- }
- ])
-}
-
-export default { show }
diff --git a/src/dashboard/Dashboard.js b/src/dashboard/Dashboard.js
index 714811652c..e1332d9d00 100644
--- a/src/dashboard/Dashboard.js
+++ b/src/dashboard/Dashboard.js
@@ -475,7 +475,6 @@ class Dashboard extends React.Component {
{AnalyticsRoute}
{SettingsRoute}
} />
- {/* {user.allowHubPublish && } />} */}
);
diff --git a/src/dashboard/DashboardView.react.js b/src/dashboard/DashboardView.react.js
index ae241706d7..f4c508a604 100644
--- a/src/dashboard/DashboardView.react.js
+++ b/src/dashboard/DashboardView.react.js
@@ -225,10 +225,15 @@ export default class DashboardView extends React.Component {
// link: '/analytics'
// })
- moreSubSection.push({
- name: 'Database HUB',
- link: '/connections'
- })
+ // The Hub is discontinued. Apps connected before the shutdown can still
+ // remove their connections; for everyone else the page does not exist.
+ const hubConnections = (this.context.custom && this.context.custom.hubConnections) || [];
+ if (hubConnections.length > 0) {
+ moreSubSection.push({
+ name: 'Database HUB',
+ link: '/connections'
+ })
+ }
// moreSubSection.push({
// name: 'App Templates',
@@ -430,12 +435,14 @@ export default class DashboardView extends React.Component {
badge: ,
})
- appSidebarSections.push({
- name: 'More',
- icon: 'b4a-more-icon',
- link: '/connections',
- subsections: moreSubSection
- })
+ if (moreSubSection.length > 0) {
+ appSidebarSections.push({
+ name: 'More',
+ icon: 'b4a-more-icon',
+ link: moreSubSection[0].link,
+ subsections: moreSubSection
+ })
+ }
const sidebar = (
- Or find a public dataset to connect
- e.g. jobs, countries, industries, colors, zip codes and more...
- back4app.com/database
-
);
}
diff --git a/src/dashboard/Hub/HubConnections.react.js b/src/dashboard/Hub/HubConnections.react.js
index 8f7b430195..6dd2893eb1 100644
--- a/src/dashboard/Hub/HubConnections.react.js
+++ b/src/dashboard/Hub/HubConnections.react.js
@@ -1,16 +1,17 @@
-import AccountManager from 'lib/AccountManager';
import React from 'react'
import CategoryList from 'components/CategoryList/CategoryList.react';
-import B4aEmptyState from 'components/B4aEmptyState/B4aEmptyState.react';
-import B4aLoader from 'components/B4aLoader/B4aLoader.react';
import Icon from 'components/Icon/Icon.react'
import DashboardView from 'dashboard/DashboardView.react'
import HubDisconnectionDialog from 'dashboard/Hub/HubDisconnectionDialog.react'
import styles from 'dashboard/Hub/HubConnections.scss'
import { CurrentApp } from 'context/currentApp';
import { withRouter } from 'lib/withRouter';
+import generatePath from 'lib/generatePath';
import { customDangerSwl } from 'lib/b4aCustomSweetalert';
+// The Hub is discontinued. This page only lets apps connected before the
+// shutdown remove their connections; the list comes from the dashboard config
+// (custom.hubConnections, owner only). Apps without connections never see it.
@withRouter
class HubConnections extends DashboardView {
static contextType = CurrentApp;
@@ -21,129 +22,90 @@ class HubConnections extends DashboardView {
this.subsection = 'Database HUB';
this.state = {
- data: null,
namespaceBeingDisconnected: '',
showDisconnectDialog: false,
isDisconnecting: false,
- isloading: true,
};
+ }
- this.user = AccountManager.currentUser();
+ getConnections() {
+ return (this.context.custom && this.context.custom.hubConnections) || [];
}
- async componentDidMount() {
- const data = await this.context.fetchHubConnections();
- this.setState({ data, isloading: false });
+ componentDidMount() {
+ if (this.getConnections().length === 0) {
+ this.props.navigate(generatePath(this.context, 'browser'), { replace: true });
+ }
}
renderSidebar() {
- const { pathname } = this.props.location;
- const current = pathname.substr(pathname.lastIndexOf('/') + 1, pathname.length - 1);
- const categories = [
- { name: 'Connections', id: 'connections' },
- ];
- if (this.user.allowHubPublish) {
- categories.push({ name: 'Publish', id: 'hub-publish' })
- }
return (
-
+
);
}
renderRows() {
- if (!this.state.data || this.state.data.length === 0) {
- return null
- }
- return this.state.data.map(({ name, authorSlug, namespace, slug, isCollab }) => {
- return (
-
- {namespace}
- {name}
-
-
- View on Hub
-
-
-
- {!isCollab && this.setState({ namespaceBeingDisconnected: namespace, showDisconnectDialog: true })}>
-
-
}
-
-
- )
- })
+ return this.getConnections().map(namespace => (
+
+ {namespace}
+
+ this.setState({ namespaceBeingDisconnected: namespace, showDisconnectDialog: true })}>
+
+
+
+
+ ));
}
renderContent() {
+ if (this.getConnections().length === 0) {
+ return null;
+ }
return (
- {/* {(this.state.data && this.state.data.length) || 0} public databases connected */}
Database Hub
- Connections
+ The Database Hub was discontinued. You can remove the connections this app still has.
-
-
- {/* {
- window.open(b4aSettings.HUB_URL, '_blank');
- }}/> */}
-
- {this.state.isloading ?
: (
- !this.state.data || this.state.data.length === 0 ? (
-
-
) : (<>
-
-
-
-
- Namespace
- Public database
- Database Hub Link
-
-
-
-
- {this.renderRows()}
-
-
-
- {this.state.showDisconnectDialog &&
-
{
- await this.setState({ isDisconnecting: true });
- try {
- await this.context.disconnectHubDatabase(this.state.namespaceBeingDisconnected);
- window.location.reload(false);
- } catch (err) {
- this.setState({ isDisconnecting: false });
- customDangerSwl.fire({
- title: 'Disconnection failed',
- text: 'Please contact our support or try again later'
- });
- }
- }}
- onCancel={() => this.setState({ isDisconnecting: false, showDisconnectDialog: false })}
- isDisconnecting={this.state.isDisconnecting} />
- }
- >)
- )}
+
+
+
+
+ Namespace
+
+
+
+
+ {this.renderRows()}
+
+
+
+ {this.state.showDisconnectDialog &&
+ {
+ await this.setState({ isDisconnecting: true });
+ try {
+ await this.context.disconnectHubDatabase(this.state.namespaceBeingDisconnected);
+ // Reloads the dashboard config: without connections left, the page goes away.
+ window.location.reload(false);
+ } catch (err) {
+ this.setState({ isDisconnecting: false });
+ customDangerSwl.fire({
+ title: 'Disconnection failed',
+ text: 'Please contact our support or try again later'
+ });
+ }
+ }}
+ onCancel={() => this.setState({ isDisconnecting: false, showDisconnectDialog: false })}
+ isDisconnecting={this.state.isDisconnecting} />
+ }
)
}
diff --git a/src/lib/ParseApp.js b/src/lib/ParseApp.js
index e1d3999786..74d024d614 100644
--- a/src/lib/ParseApp.js
+++ b/src/lib/ParseApp.js
@@ -1493,140 +1493,6 @@ export default class ParseApp {
}
}
- async fetchHubConnections() {
- try {
- return (await axios.get(`/hub/connections/${this.slug}`)).data;
- } catch (err) {
- throw err.response && err.response.data && err.response.data.error ? err.response.data.error : err
- }
- }
-
- async publishOnHub() {
- const hubEndpoint = this.serverURL === 'https://parseapi-homolog.back4app.com' ? this.serverURL : 'https://parseapi.back4app.com'
- const axiosConfig = {
- withCredentials: true,
- headers: {
- 'X-Parse-Application-Id': this.serverURL === 'https://parseapi-homolog.back4app.com' ? 'laJwKNAPsuBKrj2B6u1jbE03cgKeFez8eZcTYlL7' : 'X4zHblrpTF5ZhOwoKXzm6PhPpUQCQLrmZoKPBAoS',
- 'X-Parse-Client-Key': this.serverURL === 'https://parseapi-homolog.back4app.com' ? 'vNlgQDBx2NNo9VMp2XLMHHjPwITqALprXbjZMdDU' : 'k3xdRL0jnNB4qnfjsiYC3qLtKYdLEAvWA96ysIU4',
- }
- }
-
- let publishResult
- try {
- publishResult = await axios.post(`${hubEndpoint}/functions/publish`, { appEntityId: this.slug }, axiosConfig)
- } catch (err) {
- console.error(err.response && err.response.data && err.response.data.error ? err.response.data.error : err)
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
-
- const jobStatusId = publishResult.data && publishResult.data.result && publishResult.data.result.jobStatusId
-
- if (!jobStatusId) {
- console.error(JSON.stringify(publishResult))
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
-
- for (let i = 1; i <= 10; i++) {
- let jobStatusResult
- try {
- jobStatusResult = await axios.post(`${hubEndpoint}/functions/jobStatus`, { id: jobStatusId }, axiosConfig)
- } catch (err) {
- console.error(err.response && err.response.data && err.response.data.error ? err.response.data.error : err)
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
-
- const jobStatus = jobStatusResult.data && jobStatusResult.data.result;
-
- if (!jobStatus) {
- console.error(JSON.stringify(jobStatusResult))
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
-
- let messageObject = {}
- if (jobStatus.message) {
- try {
- messageObject = JSON.parse(jobStatus.message)
- } catch {
- console.error(jobStatus.message)
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
- }
-
- if (jobStatus.status === 'succeeded') {
- this.custom.isDatabasePublic = true;
- return messageObject
- } else if (jobStatus.status === 'failed') {
- if (messageObject.code && messageObject.message) {
- throw messageObject
- } else {
- console.error(jobStatus.message)
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
- }
-
- await new Promise(resolve => setTimeout(resolve, i * 2000))
- }
-
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
-
- async getPublicDatabase() {
- const hubEndpoint = this.serverURL === 'https://parseapi-homolog.back4app.com' ? this.serverURL : 'https://parseapi.back4app.com'
- const axiosConfig = {
- headers: {
- 'X-Parse-Application-Id': this.serverURL === 'https://parseapi-homolog.back4app.com' ? 'laJwKNAPsuBKrj2B6u1jbE03cgKeFez8eZcTYlL7' : 'X4zHblrpTF5ZhOwoKXzm6PhPpUQCQLrmZoKPBAoS',
- 'X-Parse-Client-Key': this.serverURL === 'https://parseapi-homolog.back4app.com' ? 'vNlgQDBx2NNo9VMp2XLMHHjPwITqALprXbjZMdDU' : 'k3xdRL0jnNB4qnfjsiYC3qLtKYdLEAvWA96ysIU4',
- }
- }
-
- let getPublicDatabaseResult
- try {
- getPublicDatabaseResult = await axios.get(`${hubEndpoint}/classes/Database?where=${encodeURIComponent(JSON.stringify({ appEntityId: this.slug }))}&include=author`, axiosConfig)
- } catch (err) {
- console.error(err.response && err.response.data && err.response.data.error ? err.response.data.error : err)
- return null
- }
-
- const publicDatabase = getPublicDatabaseResult.data && getPublicDatabaseResult.data.results && getPublicDatabaseResult.data.results.length > 0 && getPublicDatabaseResult.data.results[0]
-
- if (!publicDatabase) {
- console.error(JSON.stringify(getPublicDatabaseResult))
- return null
- }
-
- return publicDatabase;
- }
-
- async unpublishFromHub() {
- const hubEndpoint = this.serverURL === 'https://parseapi-homolog.back4app.com' ? this.serverURL : 'https://parseapi.back4app.com'
- const axiosConfig = {
- withCredentials: true,
- headers: {
- 'X-Parse-Application-Id': this.serverURL === 'https://parseapi-homolog.back4app.com' ? 'laJwKNAPsuBKrj2B6u1jbE03cgKeFez8eZcTYlL7' : 'X4zHblrpTF5ZhOwoKXzm6PhPpUQCQLrmZoKPBAoS',
- 'X-Parse-Client-Key': this.serverURL === 'https://parseapi-homolog.back4app.com' ? 'vNlgQDBx2NNo9VMp2XLMHHjPwITqALprXbjZMdDU' : 'k3xdRL0jnNB4qnfjsiYC3qLtKYdLEAvWA96ysIU4',
- }
- }
-
- let unpublishResult
- try {
- unpublishResult = await axios.post(`${hubEndpoint}/functions/unpublish`, { appEntityId: this.slug }, axiosConfig)
- } catch (err) {
- console.error(err.response && err.response.data && err.response.data.error ? err.response.data.error : err)
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
-
- if (unpublishResult.status !== 200) {
- if (unpublishResult.data && unpublishResult.data.code && unpublishResult.message) {
- throw unpublishResult.data
- } else {
- console.error(JSON.stringify(unpublishResult))
- throw new Error('Something wrong happened in our side. Please try again later.')
- }
- }
-
- this.custom.isDatabasePublic = false;
- }
-
async fetchServerLogs() {
try {
return (