From 2fc5567c0482403ee2584938f636cef6aead7e36 Mon Sep 17 00:00:00 2001 From: Gabriel Dutra Date: Wed, 20 Nov 2019 17:12:53 -0300 Subject: [PATCH 1/4] Migrate Home to React --- client/app/assets/less/inc/base.less | 6 +- client/app/pages/home/Home.jsx | 171 +++++++++++++++++++++++++++ client/app/pages/home/home.html | 95 --------------- client/app/pages/home/index.js | 42 ------- 4 files changed, 174 insertions(+), 140 deletions(-) create mode 100644 client/app/pages/home/Home.jsx delete mode 100644 client/app/pages/home/home.html delete mode 100644 client/app/pages/home/index.js diff --git a/client/app/assets/less/inc/base.less b/client/app/assets/less/inc/base.less index 2a4ce12699..b9e3cda7ea 100755 --- a/client/app/assets/less/inc/base.less +++ b/client/app/assets/less/inc/base.less @@ -85,7 +85,7 @@ strong { // Fixed width layout for specific pages @media (min-width: 768px) { - .settings-screen, home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container { + .settings-screen, .home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container { .container { width: 750px; } @@ -93,7 +93,7 @@ strong { } @media (min-width: 992px) { - .settings-screen, home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container { + .settings-screen, .home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container { .container { width: 970px; } @@ -101,7 +101,7 @@ strong { } @media (min-width: 1200px) { - .settings-screen, home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container { + .settings-screen, .home-page, page-dashboard-list, page-queries-list, page-alerts-list, alert-page, queries-search-results-page, .fixed-container { .container { width: 1170px; } diff --git a/client/app/pages/home/Home.jsx b/client/app/pages/home/Home.jsx new file mode 100644 index 0000000000..71d35348c4 --- /dev/null +++ b/client/app/pages/home/Home.jsx @@ -0,0 +1,171 @@ +import React, { useEffect, useState } from 'react'; +import PropTypes from 'prop-types'; +import { includes, isEmpty } from 'lodash'; +import { react2angular } from 'react2angular'; +import Icon from 'antd/lib/icon'; +import { EmptyState } from '@/components/empty-state/EmptyState'; +import DynamicComponent from '@/components/DynamicComponent'; +import { BeaconConsent } from '@/components/BeaconConsent'; +import recordEvent from '@/services/recordEvent'; +import { messages } from '@/services/auth'; +import { $http } from '@/services/ng'; +import notification from '@/services/notification'; +import { Dashboard } from '@/services/dashboard'; +import { Query } from '@/services/query'; + +function DeprecatedEmbedFeatureAlert() { + return ( +
+ You have enabled ALLOW_PARAMETERS_IN_EMBEDS. This setting is + now deprecated and should be turned off. Parameters in embeds are supported + by default.{' '} + + Read more + . +
+ ); +} + +function EmailNotVerifiedAlert() { + const verifyEmail = () => { + $http.post('verification_email').then(({ data }) => { + notification.success(data.message); + }); + }; + + return ( +
+ We have sent an email with a confirmation link to your email address. Please + follow the link to verify your email address.{' '} + Resend email. +
+ ); +} + +function FavoriteList({ title, resource, itemUrl, emptyState }) { + const [items, setItems] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + setLoading(true); + resource.favorites().$promise + .then(({ results }) => setItems(results)) + .finally(() => setLoading(false)); + }, []); + + return ( + <> +
+

{title}

+ {loading && } +
+ {!isEmpty(items) && ( +
+ {items.map(item => ( + + +