@bigbinary/neeto-custom-domains-frontend 1.1.0 → 1.2.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,17 +1,14 @@
1
- # neeto-custom-domains-engine
1
+ # neeto-custom-domains-nano
2
2
 
3
- The `neeto-custom-domains-engine` manages custom domains across neeto applications.
3
+ The `neeto-custom-domains-nano` manages custom domains across neeto
4
+ applications.
4
5
 
5
6
  ## Contents
6
- 1. [Development with Host application](#development-with-host-application)
7
- - [Engine](#engine)
8
- - [Installation](#installation)
9
- - [Usage](#usage)
10
- 2. [Instructions for publishing](#instructions-for-publishing)
11
7
 
12
- ## Development with Host application
8
+ 1. [Development with Host application](#development-with-host-application)
9
+ 2. [Instructions for publishing](#instructions-for-publishing)
13
10
 
14
- ### Engine
11
+ ## Development with Host application
15
12
 
16
13
  The engine provides the backend setup for neetoCustomDomains.
17
14
 
@@ -33,13 +30,7 @@ end
33
30
  bundle install
34
31
  ```
35
32
 
36
- 3. Add this line to your application's `config/routes.rb` file:
37
-
38
- ```ruby
39
- mount NeetoCustomDomainsEngine::Engine => "/custom_domains"
40
- ```
41
-
42
- 4. Run migrations
33
+ 3. Run migrations
43
34
 
44
35
  ```
45
36
  rails neeto-custom-domains-engine:install:migrations
@@ -48,28 +39,21 @@ rails db:migrate
48
39
 
49
40
  #### Usage
50
41
 
51
- The steps below depend on the association that we use. In some cases, we need to attach multiple custom domains to a model, while in other cases, we only need a single custom domain. We have to make necessary configurations depending on this.
52
-
53
- Let's say we have a "Site" model, and we want to publish our site on a custom domain.
54
-
55
- ##### Configure `has_one` association
56
-
57
- The site only needs to be published in a single custom domain, so we chose `has_one` association.
58
-
59
42
  1. Add association
60
43
 
61
44
  ```ruby
62
- class Site > ApplicationRecord
45
+ class Organization > ApplicationRecord
63
46
  has_one :custom_domain, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
64
47
  end
65
48
  ```
66
49
 
67
50
  2. Add controller
68
51
 
69
- All common controller logic is extracted to the engine. However, we still need to load some records depending on the association that we use.
52
+ All common controller logic is extracted to the engine. However, we still need
53
+ to load some records from the host app controller.
70
54
 
71
55
  ```ruby
72
- class Api::V1::Sites::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
56
+ class Api::V1::Admin::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
73
57
  private
74
58
 
75
59
  def load_custom_domainable!
@@ -82,78 +66,73 @@ class Api::V1::Sites::CustomDomainsController < NeetoCustomDomainsEngine::Domain
82
66
  end
83
67
  ```
84
68
 
85
- 3. Add routes
69
+ 3. Include the following module to your application's `config/routes.rb` file:
86
70
 
87
71
  ```ruby
88
72
  include NeetoCustomDomainsEngine::Routes::Draw
89
73
 
90
- scope module: :sites do
91
- custom_domains_routes(route: :custom_domain)
92
- end
93
- ```
94
- 4. Add front-end component
95
-
96
- ```js
97
- import { CustomDomain } from "@bigbinary/neeto-molecules/CustomDomain";
98
74
  ```
99
- For more info related to front-end component: https://github.com/bigbinary/neeto-molecules/blob/main/docs/components.md#customdomain
100
75
 
101
- ##### Configure `has_many` association
102
-
103
- The site needs to be published in multiple custom domains, so we chose `has_many` association.
104
-
105
- 1. Add association
76
+ 4. Define required routes.
106
77
 
107
78
  ```ruby
108
- class Site > ApplicationRecord
109
- has_many :custom_domain, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
110
- end
111
- ```
79
+ # config/routes.rb
80
+ custom_domains_routes :acme
112
81
 
113
- 2. Add controller
114
- ```ruby
115
- class Api::V1::Sites::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
116
- private
117
-
118
- def load_custom_domainable!
119
- @custom_domainable = organization.sites.find(params[:site_id])
120
- end
121
-
122
- def load_custom_domain!
123
- @custom_domain = @custom_domainable.custom_domains.find(params[:id])
124
- end
125
- end
82
+ # routes/admin.rb
83
+ custom_domains_routes :domain
126
84
  ```
127
85
 
128
- 3. Add routes
129
-
130
- ```ruby
131
- include NeetoCustomDomainsEngine::Routes::Draw
132
-
133
- scope module: :sites do
134
- custom_domains_routes(route: :custom_domain)
135
- end
136
- ```
137
-
138
- 4. Add front-end component
86
+ 5. Add frontend component. `url` should be the api to the custom domains
87
+ controller.
139
88
 
140
89
  ```js
141
- import { CustomDomainDashBoard } from "@bigbinary/neeto-molecules/CustomDomainDashboard";
142
- ```
143
- For more info related to front-end component: https://github.com/bigbinary/neeto-molecules/blob/main/docs/components.md#customdomainDashboard
144
-
145
- ##### Loading site from custom domain
146
- Let's say we have attached the custom domain `test.neeto.com` to a site. Now, when the user tries to access `test.neeto.com` in the browser, we should display the corresponding site in the front-end. In order to achieve this, we need to load the site from the custom domain.
147
-
148
- ```ruby
149
- custom_domain = NeetoCustomDomainsEngine::Domain.find_by(hostname: params[:custom_domain])
150
- if custom_domain.present?
151
- @published_site = custom_domain.custom_domainable.published_site
152
- else
153
- site = Site.find_by! subdomain: params[:subdomain]
154
- @published_site = site.published_site
155
- end
156
- ```
90
+ import { CustomDomain as NeetoCustomDomainDashboard } from "@bigbinary/neeto-custom-domains-frontend";
91
+ import { BASE_API_V1_URL, SINGULAR } from "neetocommons/constants";
92
+ import HelpPopover from "neetomolecules/HelpPopover";
93
+ import { useTranslation } from "react-i18next";
94
+
95
+ import routes from "routes";
96
+ import { EVENTS } from "src/constants";
97
+ import { CUSTOM_DOMAIN_HELP_DOC_URL } from "src/constants/urls";
98
+
99
+ const CustomDomain = () => {
100
+ const { t } = useTranslation();
101
+
102
+ const breadcrumbs = [
103
+ { link: routes.admin.settings.index, text: t("titles.settings") },
104
+ {
105
+ link: routes.admin.settings.customDomain,
106
+ text: t("neetoCustomDomains.customDomain", SINGULAR),
107
+ },
108
+ ];
109
+
110
+ const title = (
111
+ <div className="flex items-center gap-x-2">
112
+ {t("neetoCustomDomains.customDomain", SINGULAR)}
113
+ <HelpPopover
114
+ description={t("neetoCustomDomains.toolTips.customDomain")}
115
+ helpLinkProps={{ href: CUSTOM_DOMAIN_HELP_DOC_URL }}
116
+ popoverProps={{ position: "top" }}
117
+ title={t("neetoCustomDomains.customDomain", SINGULAR)}
118
+ />
119
+ </div>
120
+ );
121
+
122
+ return (
123
+ <div className="w-full">
124
+ <NeetoCustomDomainDashboard
125
+ headerProps={{ breadcrumbs, title }}
126
+ url={`${BASE_API_V1_URL}/custom_domain`}
127
+ />
128
+ </div>
129
+ );
130
+ };
131
+
132
+ export default CustomDomain;
133
+ ```
134
+
135
+ 6. Mount the `CustomDomain` component at the desired apth.
157
136
 
158
137
  ##### ENV variables
159
138
 
@@ -162,13 +141,13 @@ For the working of this engine we need the following env variables.
162
141
  ```
163
142
  LETS_ENCRYPT_PRIVATE_KEY: < For requesting SSL certificates >
164
143
  LETS_ENCRYPT_DIRECTORY_URL: < For requesting SSL certificates >
165
- LETS_ENCRYPT_VALIDATION_DOMAIN_ACCESS_TOKEN: < For domain authentication>
166
- LETS_ENCRYPT_VALIDATION_DOMAIN_ID: < For domain authentication>
167
- LETS_ENCRYPT_VALIDATION_DOMAIN_NAME: < For domain authentication>
168
144
  LETS_ENCRYPT_APP_NAME: < For pushing SSL certificate and custom domains >
169
- HEROKU_AUTH_TOKEN: < For pushing SSL certificate and custom domains >
145
+ NEETO_DEPLOY_APP: < To identify in which platform the app is deployed NeetoDEploy/Heroku>
146
+ NEETO_DEPLOY_AUTH_TOKEN: <For pushing SSL certificate and custom domains>
170
147
  ```
171
148
 
172
149
  ## Instructions for Publishing
173
150
 
174
- Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
151
+ Consult the
152
+ [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages)
153
+ guide for details on how to publish.
@@ -13,27 +13,33 @@
13
13
  "delete": "Delete",
14
14
  "edit": "Edit",
15
15
  "continue": "Continue",
16
- "done": "Done"
16
+ "done": "Done",
17
+ "add": "Add {{what}}"
17
18
  },
18
19
  "customDomain_one": "Custom domain",
19
20
  "customDomain_other": "Custom domains",
20
21
  "customDomainWithCount_one": "{{count}} custom domain",
21
22
  "customDomainWithCount_other": "{{count}} custom domains",
22
23
  "settings": "Custom domain settings",
24
+ "connectionTitle": "Connected custom domain",
25
+ "noDomainConnected": "No custom domain connected",
26
+ "readHelpArticle": "<Link>Read more</Link> to learn more about setting up custom domain",
23
27
  "yourDomain": "Your domain",
24
- "addNew": "Add new custom domain",
28
+ "addNew": "Add custom domain",
25
29
  "delete": "Delete custom domain?",
26
30
  "search": "Search custom domains",
27
31
  "notFound": "There are no custom domains to show.",
28
- "placeholder": "help.neeto.com",
32
+ "placeholder": "Enter your domain",
29
33
  "cname": "CNAME",
30
- "label": "Enter domain",
34
+ "label": "Domain name",
31
35
  "domainValidation": "Domain validation",
32
36
  "domainRedirection": "Domain redirection",
33
- "cnameRecordInfo": "Go to your domain host's DNS settings to add the following CNAME record.{{proxyMessage, anyCase}} <Link>View help article</Link> for more information.",
37
+ "cnameRecordTitle": " Add the DNS record to your DNS provider",
38
+ "cnameRecordInfo": "Go to your DNS provider and create the following DNS record by copying the exact settings listed below. Do not enable proxy for the record. View <Link>help article</Link> for more information.",
34
39
  "proxyMessage": " Do not enable proxy for the record.",
35
40
  "domainRedirectionInfo": "It can take up to 2-24 hours for your custom domain to start working. Please visit your site in 24 hours from now and if after 24 hours <strong>{{hostname}}</strong> is not working then please view <Link>help article</Link> for more information and contact us.",
36
- "domainValidationInfo": "CNAME record not found, if you added CNAME record in last 24 hours then please wait sometime and try it again. Verifying your domain usually only takes a few hours, but in some cases can take up to 24-48 hours. View <Link>help article</Link> for more information.",
41
+ "domainValidationInfo": "CNAME record not found, if you added CNAME record in last 24 hours then please wait sometime and try it again. Verifying your domain usually only takes a few hours, but in some cases can take up to 24-48 hours.",
42
+ "certificateProvisionFailed": "CNAME record found but we are facing some issues with provisioning certificate for your domain. Please try again",
37
43
  "learnMoreMessage": "Learn about <button>how to setup custom domains</button>",
38
44
  "cnameAdded": "I have added redirection CNAME record",
39
45
  "validation": {
@@ -44,9 +50,9 @@
44
50
  },
45
51
  "status": {
46
52
  "domain": {
47
- "active": "Domain validated",
48
- "pendingCnameValidation": "Domain validated",
49
- "pendingDomainValidation": "Domain validation pending"
53
+ "active": "Active",
54
+ "pending": "Pending",
55
+ "failed": "Failed"
50
56
  },
51
57
  "cname": {
52
58
  "active": "Domain redirected",
@@ -58,6 +64,9 @@
58
64
  "formikValidation": {
59
65
  "required": "Domain is required",
60
66
  "valid": "Please add valid domain or URL"
67
+ },
68
+ "toolTips":{
69
+ "customDomain": "Add domain of your choice in case you do not prefer to use the default neeto domain."
61
70
  }
62
71
  }
63
- }
72
+ }