cortex 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.babelrc +18 -0
- data/.codeclimate.yml +43 -0
- data/.csslintrc +2 -0
- data/.editorconfig +9 -0
- data/.eslintignore +1 -0
- data/.eslintrc.yml +277 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +47 -0
- data/.gitignore +82 -0
- data/.npmignore +34 -0
- data/.postcssrc.yml +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1156 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +58 -0
- data/Gemfile +101 -0
- data/Gemfile.lock +604 -0
- data/Guardfile +23 -0
- data/LICENSE.md +201 -0
- data/README.md +239 -0
- data/Rakefile +22 -0
- data/app/assets/config/cortex_manifest.js +4 -0
- data/app/assets/fonts/cortex/Montserrat-Light.otf +0 -0
- data/app/assets/fonts/cortex/Montserrat-Medium.otf +0 -0
- data/app/assets/fonts/cortex/Montserrat-Regular.otf +0 -0
- data/app/assets/fonts/cortex/Montserrat-SemiBold.otf +0 -0
- data/app/assets/images/cortex/favicon.ico +0 -0
- data/app/assets/images/cortex/icons/add.svg +59 -0
- data/app/assets/images/cortex/icons/blog.png +0 -0
- data/app/assets/images/cortex/icons/media.png +0 -0
- data/app/assets/images/cortex/logo.svg +43 -0
- data/app/assets/javascripts/cortex/application.js +17 -0
- data/app/assets/javascripts/cortex/authentication.js +6 -0
- data/app/assets/javascripts/cortex/base.js +6 -0
- data/app/assets/javascripts/cortex/datepicker_init.js +29 -0
- data/app/assets/javascripts/cortex/flash.js +7 -0
- data/app/assets/javascripts/cortex/form.js +6 -0
- data/app/assets/javascripts/cortex/media_dialogs.js +40 -0
- data/app/assets/javascripts/cortex/quick_links.js +13 -0
- data/app/assets/stylesheets/cortex/application.scss +34 -0
- data/app/assets/stylesheets/cortex/authentication.scss +34 -0
- data/app/assets/stylesheets/cortex/base.scss +4 -0
- data/app/assets/stylesheets/cortex/bootstrap-namespaced.scss +57 -0
- data/app/assets/stylesheets/cortex/components/card.scss +9 -0
- data/app/assets/stylesheets/cortex/components/dialog.scss +67 -0
- data/app/assets/stylesheets/cortex/components/flash.scss +60 -0
- data/app/assets/stylesheets/cortex/components/form.scss +45 -0
- data/app/assets/stylesheets/cortex/components/header.scss +53 -0
- data/app/assets/stylesheets/cortex/components/index.scss +28 -0
- data/app/assets/stylesheets/cortex/components/jumbo-button.scss +41 -0
- data/app/assets/stylesheets/cortex/components/loaders.scss +76 -0
- data/app/assets/stylesheets/cortex/components/notes.scss +26 -0
- data/app/assets/stylesheets/cortex/components/sidebar.scss +120 -0
- data/app/assets/stylesheets/cortex/components/table.scss +7 -0
- data/app/assets/stylesheets/cortex/components/tenant-switcher.scss +209 -0
- data/app/assets/stylesheets/cortex/components/ui.scss +119 -0
- data/app/assets/stylesheets/cortex/demo.scss +140 -0
- data/app/assets/stylesheets/cortex/directives/aspect-ratio.scss +9 -0
- data/app/assets/stylesheets/cortex/helpers.scss +1701 -0
- data/app/assets/stylesheets/cortex/layout.scss +21 -0
- data/app/assets/stylesheets/cortex/material-icons.scss +13 -0
- data/app/assets/stylesheets/cortex/variables/_colors.scss +46 -0
- data/app/assets/stylesheets/cortex/variables/_material-overrides.scss +1 -0
- data/app/assets/stylesheets/cortex/variables/_typography.scss +114 -0
- data/app/cells/cortex/application_cell.rb +8 -0
- data/app/cells/cortex/content_type/nav.haml +5 -0
- data/app/cells/cortex/content_type_cell.rb +10 -0
- data/app/cells/cortex/field_cell.rb +35 -0
- data/app/cells/cortex/index/content_item/column.haml +4 -0
- data/app/cells/cortex/index/content_item_cell.rb +37 -0
- data/app/cells/cortex/index/index.haml +5 -0
- data/app/cells/cortex/index/table_body.haml +11 -0
- data/app/cells/cortex/index/table_headers.haml +5 -0
- data/app/cells/cortex/index_cell.rb +53 -0
- data/app/cells/cortex/wizard/column/show.haml +10 -0
- data/app/cells/cortex/wizard/column_cell.rb +21 -0
- data/app/cells/cortex/wizard/field/show.haml +30 -0
- data/app/cells/cortex/wizard/field_cell.rb +29 -0
- data/app/cells/cortex/wizard/plugin/show.haml +1 -0
- data/app/cells/cortex/wizard/plugin_cell.rb +28 -0
- data/app/cells/cortex/wizard/show.haml +1 -0
- data/app/cells/cortex/wizard/step/show.haml +2 -0
- data/app/cells/cortex/wizard/step_cell.rb +17 -0
- data/app/cells/cortex/wizard_cell.rb +15 -0
- data/app/containers/cortex/transaction_container.rb +23 -0
- data/app/controllers/concerns/cortex/decoratable.rb +16 -0
- data/app/controllers/cortex/admin_controller.rb +7 -0
- data/app/controllers/cortex/application_controller.rb +19 -0
- data/app/controllers/cortex/authentication/passwords_controller.rb +3 -0
- data/app/controllers/cortex/authentication/sessions_controller.rb +3 -0
- data/app/controllers/cortex/content_items_controller.rb +75 -0
- data/app/controllers/cortex/content_types_controller.rb +19 -0
- data/app/controllers/cortex/dashboards_controller.rb +7 -0
- data/app/controllers/cortex/graphql_controller.rb +40 -0
- data/app/controllers/cortex/tenants_controller.rb +12 -0
- data/app/devise/cortex/authentication_failure.rb +12 -0
- data/app/graphql/cortex/cortex_schema.rb +8 -0
- data/app/graphql/cortex/interfaces/.keep +0 -0
- data/app/graphql/cortex/mutations/.keep +0 -0
- data/app/graphql/cortex/types/content_item_type.rb +31 -0
- data/app/graphql/cortex/types/content_type_type.rb +23 -0
- data/app/graphql/cortex/types/contract_type.rb +10 -0
- data/app/graphql/cortex/types/date_time_type.rb +8 -0
- data/app/graphql/cortex/types/field_item_type.rb +15 -0
- data/app/graphql/cortex/types/field_type.rb +18 -0
- data/app/graphql/cortex/types/mutation_type.rb +5 -0
- data/app/graphql/cortex/types/query_type.rb +45 -0
- data/app/graphql/cortex/types/tenant_type.rb +19 -0
- data/app/graphql/cortex/types/user_type.rb +20 -0
- data/app/helpers/cortex/application_helper.rb +75 -0
- data/app/helpers/cortex/cells/association_helper.rb +25 -0
- data/app/helpers/cortex/content_item_helper.rb +106 -0
- data/app/helpers/cortex/dashboard_helper.rb +19 -0
- data/app/helpers/cortex/popup_helper.rb +27 -0
- data/app/jobs/cortex/application_job.rb +4 -0
- data/app/mailers/cortex/application_mailer.rb +6 -0
- data/app/mailers/cortex/password_reset_mailer.rb +13 -0
- data/app/models/concerns/cortex/belongs_to_tenant.rb +13 -0
- data/app/models/concerns/cortex/has_firstname_lastname.rb +11 -0
- data/app/models/concerns/cortex/has_gravatar.rb +18 -0
- data/app/models/concerns/cortex/searchable.rb +11 -0
- data/app/models/concerns/cortex/searchable_content_item.rb +31 -0
- data/app/models/concerns/cortex/searchable_content_item_for_content_type.rb +52 -0
- data/app/models/concerns/cortex/searchable_content_type.rb +11 -0
- data/app/models/cortex/application_record.rb +17 -0
- data/app/models/cortex/content_item.rb +71 -0
- data/app/models/cortex/content_type.rb +27 -0
- data/app/models/cortex/contentable_decorator.rb +8 -0
- data/app/models/cortex/contract.rb +12 -0
- data/app/models/cortex/decorator.rb +13 -0
- data/app/models/cortex/field.rb +36 -0
- data/app/models/cortex/field_item.rb +54 -0
- data/app/models/cortex/field_type.rb +44 -0
- data/app/models/cortex/permission.rb +11 -0
- data/app/models/cortex/role.rb +12 -0
- data/app/models/cortex/tenant.rb +41 -0
- data/app/models/cortex/user.rb +77 -0
- data/app/operations/cortex/database_transact_operation.rb +17 -0
- data/app/operations/cortex/execute_content_item_state_change_operation.rb +16 -0
- data/app/operations/cortex/parse_content_item_field_items_operation.rb +18 -0
- data/app/operations/cortex/persist_content_item_operation.rb +12 -0
- data/app/policies/cortex/application_policy.rb +55 -0
- data/app/policies/cortex/content_item_policy.rb +49 -0
- data/app/policies/cortex/content_type_policy.rb +38 -0
- data/app/transactions/concerns/cortex/content_itemable.rb +15 -0
- data/app/transactions/concerns/cortex/field_item_transactor.rb +28 -0
- data/app/transactions/concerns/cortex/widget_parsable.rb +19 -0
- data/app/transactions/cortex/application_transaction.rb +5 -0
- data/app/transactions/cortex/create_content_item_transaction.rb +35 -0
- data/app/transactions/cortex/get_content_item_transaction.rb +4 -0
- data/app/transactions/cortex/get_content_items_for_content_type_transaction.rb +34 -0
- data/app/transactions/cortex/get_publish_state_transaction.rb +28 -0
- data/app/transactions/cortex/new_field_item_transaction.rb +16 -0
- data/app/transactions/cortex/update_content_item_transaction.rb +45 -0
- data/app/transactions/cortex/update_field_item_transaction.rb +23 -0
- data/app/types/cortex/application_types.rb +21 -0
- data/app/types/cortex/content_item_transaction_type.rb +10 -0
- data/app/types/cortex/core_types.rb +5 -0
- data/app/types/cortex/transaction_type.rb +5 -0
- data/app/views/cortex/authentication/passwords/new.html.haml +13 -0
- data/app/views/cortex/authentication/sessions/new.html.haml +20 -0
- data/app/views/cortex/authentication/shared/_links.html.haml +19 -0
- data/app/views/cortex/content_items/_form.html.haml +13 -0
- data/app/views/cortex/content_items/_grid.html.haml +1 -0
- data/app/views/cortex/content_items/edit.html.haml +2 -0
- data/app/views/cortex/content_items/index.html.haml +4 -0
- data/app/views/cortex/content_items/new.html.haml +2 -0
- data/app/views/cortex/content_types/index.html.haml +2 -0
- data/app/views/cortex/content_types/new.html.haml +0 -0
- data/app/views/cortex/dashboards/index.html.haml +6 -0
- data/app/views/cortex/graphql/ide.haml +1 -0
- data/app/views/cortex/partials/_breadcrumb.html.haml +2 -0
- data/app/views/cortex/partials/_cortex_redux_state.html.haml +1 -0
- data/app/views/cortex/partials/_flash.html.haml +25 -0
- data/app/views/cortex/partials/_media_dialogs.html.haml +13 -0
- data/app/views/cortex/partials/_navigation.html.haml +15 -0
- data/app/views/cortex/partials/_notes.html.haml +17 -0
- data/app/views/cortex/partials/_quick_links.html.haml +22 -0
- data/app/views/cortex/partials/_sidebar.html.haml +7 -0
- data/app/views/cortex/partials/_topbar.html.haml +5 -0
- data/app/views/cortex/partials/_user_control.html.haml +7 -0
- data/app/views/cortex/partials/authentication/_header.html.haml +4 -0
- data/app/views/cortex/partials/trackers/_google_analytics.html.haml +10 -0
- data/app/views/cortex/partials/trackers/_qualtrics.html.haml +10 -0
- data/app/views/cortex/password_reset_mailer/send_password_reset.html.erb +5 -0
- data/app/views/cortex/password_reset_mailer/send_password_reset.text.erb +5 -0
- data/app/views/layouts/cortex/application.html.haml +30 -0
- data/app/views/layouts/cortex/devise.html.haml +19 -0
- data/app/views/layouts/cortex/mailer.html.erb +13 -0
- data/app/views/layouts/cortex/mailer.text.erb +1 -0
- data/bin/rails +25 -0
- data/config/config.yml +22 -0
- data/config/initializers/devise.rb +35 -0
- data/config/initializers/elasticsearch.rb +3 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/flipper.rb +16 -0
- data/config/initializers/graphiql.rb +51 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/load_config.rb +16 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/plugins.rb +17 -0
- data/config/initializers/react_on_rails.rb +15 -0
- data/config/initializers/rolify.rb +9 -0
- data/config/initializers/tag_parsers.rb +5 -0
- data/config/locales/devise.en.yml +64 -0
- data/config/routes.rb +41 -0
- data/cortex.gemspec +84 -0
- data/db/migrate/0_enable_pgcrypto_extension.rb +5 -0
- data/db/migrate/10_create_fields.rb +15 -0
- data/db/migrate/11_create_content_items.rb +14 -0
- data/db/migrate/12_create_field_items.rb +12 -0
- data/db/migrate/13_create_field_types.rb +5 -0
- data/db/migrate/1_create_users.rb +14 -0
- data/db/migrate/2_create_tenants.rb +26 -0
- data/db/migrate/3_add_devise_to_users.rb +49 -0
- data/db/migrate/4_create_roles.rb +15 -0
- data/db/migrate/5_create_permissions.rb +16 -0
- data/db/migrate/6_create_flipper_tables.rb +20 -0
- data/db/migrate/7_create_contracts.rb +11 -0
- data/db/migrate/8_create_decorators.rb +21 -0
- data/db/migrate/9_create_content_types.rb +17 -0
- data/db/seeds.rb +40 -0
- data/db/seeds.yml +33 -0
- data/lib/assets/.keep +0 -0
- data/lib/breadcrumbs/title_builder.rb +12 -0
- data/lib/cortex.rb +4 -0
- data/lib/cortex/engine.rb +41 -0
- data/lib/cortex/version.rb +3 -0
- data/lib/helpers/utility_helper.rb +7 -0
- data/lib/tasks/cortex_tasks.rake +13 -0
- data/lib/tasks/elasticsearch_tasks.rake +1 -0
- data/node_package/.babelrc +26 -0
- data/node_package/src/components/side_bar/environment_flag.jsx +21 -0
- data/node_package/src/components/side_bar/tenant_list.jsx +65 -0
- data/node_package/src/components/wizard/column.jsx +29 -0
- data/node_package/src/components/wizard/field.jsx +22 -0
- data/node_package/src/components/wizard/step.jsx +20 -0
- data/node_package/src/constants/tenant_switcher.jsx +17 -0
- data/node_package/src/constants/type_constants.jsx +12 -0
- data/node_package/src/constants/wizard.jsx +9 -0
- data/node_package/src/containers/layout.jsx +33 -0
- data/node_package/src/containers/tenant_switcher_container.jsx +115 -0
- data/node_package/src/containers/wizard_container.jsx +28 -0
- data/node_package/src/elements/loaders.jsx +7 -0
- data/node_package/src/helpers/formatting.jsx +5 -0
- data/node_package/src/helpers/tenant_ancestry.jsx +14 -0
- data/node_package/src/helpers/tenant_lookup.jsx +23 -0
- data/node_package/src/index.jsx +21 -0
- data/node_package/src/reducers/index.jsx +13 -0
- data/node_package/src/reducers/rails_context_reducer.jsx +5 -0
- data/node_package/src/reducers/tenant_switcher_reducer.jsx +74 -0
- data/node_package/src/reducers/wizard_reducer.jsx +32 -0
- data/node_package/src/services/rails_api_service.jsx +13 -0
- data/node_package/src/store/store.jsx +15 -0
- data/package.json +66 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/config/manifest.js +4 -0
- data/spec/dummy/app/assets/javascripts/application.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.scss +2 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +8 -0
- data/spec/dummy/app/javascript/packs/cortex.jsx +1 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.haml +11 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +105 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/rspec +17 -0
- data/spec/dummy/bin/setup +38 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/bin/webpack +29 -0
- data/spec/dummy/bin/webpack-dev-server +29 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +7 -0
- data/spec/dummy/config/apollo_engine_proxy.yml +23 -0
- data/spec/dummy/config/application.rb +21 -0
- data/spec/dummy/config/boot.rb +11 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/config.yml +22 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +74 -0
- data/spec/dummy/config/environments/production.rb +103 -0
- data/spec/dummy/config/environments/staging.rb +103 -0
- data/spec/dummy/config/environments/test.rb +65 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/load_config.rb +9 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/react_on_rails.rb +41 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/sentry.rb +6 -0
- data/spec/dummy/config/initializers/session_store.rb +7 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +8 -0
- data/spec/dummy/config/newrelic.yml +224 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/secrets.yml +32 -0
- data/spec/dummy/config/sidekiq.yml +9 -0
- data/spec/dummy/config/webpack/development.js +3 -0
- data/spec/dummy/config/webpack/environment.js +3 -0
- data/spec/dummy/config/webpack/production.js +3 -0
- data/spec/dummy/config/webpack/test.js +3 -0
- data/spec/dummy/config/webpacker.yml +66 -0
- data/spec/dummy/db/migrate/20180118233001_enable_pgcrypto_extension.cortex.rb +6 -0
- data/spec/dummy/db/migrate/20180118233002_create_users.cortex.rb +15 -0
- data/spec/dummy/db/migrate/20180118233003_create_tenants.cortex.rb +27 -0
- data/spec/dummy/db/migrate/20180118233004_add_devise_to_users.cortex.rb +50 -0
- data/spec/dummy/db/migrate/20180118233005_create_roles.cortex.rb +16 -0
- data/spec/dummy/db/migrate/20180118233006_create_permissions.cortex.rb +17 -0
- data/spec/dummy/db/migrate/20180118233007_create_flipper_tables.cortex.rb +21 -0
- data/spec/dummy/db/migrate/20180118233008_create_contracts.cortex.rb +12 -0
- data/spec/dummy/db/migrate/20180118233009_create_decorators.cortex.rb +22 -0
- data/spec/dummy/db/migrate/20180118233010_create_content_types.cortex.rb +18 -0
- data/spec/dummy/db/migrate/20180118233011_create_fields.cortex.rb +16 -0
- data/spec/dummy/db/migrate/20180118233012_create_content_items.cortex.rb +15 -0
- data/spec/dummy/db/migrate/20180118233013_create_field_items.cortex.rb +13 -0
- data/spec/dummy/db/migrate/20180118233014_create_field_types.cortex.rb +6 -0
- data/spec/dummy/db/schema.rb +258 -0
- data/spec/dummy/db/seeds.rb +1 -0
- data/spec/dummy/lib/tasks/content_types_tasks.rake +31 -0
- data/spec/dummy/lib/tasks/employer/blog_tasks.rake +345 -0
- data/spec/dummy/package.json +28 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/spec/javascripts/support/jasmine.yml +50 -0
- data/spec/dummy/yarn.lock +6615 -0
- data/spec/rails_helper.rb +57 -0
- data/spec/spec_helper.rb +96 -0
- data/yarn.lock +6032 -0
- metadata +1061 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Step from '../components/wizard/step'
|
3
|
+
|
4
|
+
class WizardContainer extends React.PureComponent {
|
5
|
+
constructor(props) {
|
6
|
+
super(props)
|
7
|
+
this.contentItemFieldLookup = props.data.fields.reduce((lookup, field) => {
|
8
|
+
lookup[field.id] = field
|
9
|
+
return lookup
|
10
|
+
}, {})
|
11
|
+
}
|
12
|
+
|
13
|
+
renderStep = (step, index) => {
|
14
|
+
return <Step key={`step_${index}`} contentItemFieldLookup={this.contentItemFieldLookup} {...step} />
|
15
|
+
}
|
16
|
+
|
17
|
+
render() {
|
18
|
+
const {steps, fields, content_item, content_type} = this.props.data
|
19
|
+
|
20
|
+
return (
|
21
|
+
<div>
|
22
|
+
{steps.map(this.renderStep)}
|
23
|
+
</div>
|
24
|
+
)
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
export default WizardContainer
|
@@ -0,0 +1,14 @@
|
|
1
|
+
const ParentLookup = (parent_id, tenantLookupTable, nameList) => {
|
2
|
+
if (parent_id === null) {
|
3
|
+
return nameList
|
4
|
+
}
|
5
|
+
let tenant = tenantLookupTable[parent_id];
|
6
|
+
nameList.unshift(tenant.name)
|
7
|
+
return ParentLookup(tenant.parent_id, tenantLookupTable, nameList)
|
8
|
+
}
|
9
|
+
|
10
|
+
const TenantAncestryList = (parentTenant, tenantLookupTable) => {
|
11
|
+
return ParentLookup(parentTenant, tenantLookupTable, [])
|
12
|
+
}
|
13
|
+
|
14
|
+
export default TenantAncestryList;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import {NOT_DEFINED} from '../constants/type_constants'
|
2
|
+
|
3
|
+
const TenantIndex = (tenants) => tenants.reduce((lookup, tenant, i) => {
|
4
|
+
lookup[tenant.id] = tenant
|
5
|
+
return lookup;
|
6
|
+
}, {topLevel: []})
|
7
|
+
|
8
|
+
const TenantLookup = (tenants) => {
|
9
|
+
|
10
|
+
return tenants.reduce((lookup, tenant, i) => {
|
11
|
+
if (tenant.parent_id === null) {
|
12
|
+
lookup.topLevel.push(tenant.id);
|
13
|
+
return lookup;
|
14
|
+
}
|
15
|
+
if (lookup[tenant.parent_id].children === NOT_DEFINED) {
|
16
|
+
lookup[tenant.parent_id].children = []
|
17
|
+
}
|
18
|
+
lookup[tenant.parent_id].children.push(tenant.id)
|
19
|
+
return lookup;
|
20
|
+
}, TenantIndex(tenants))
|
21
|
+
}
|
22
|
+
|
23
|
+
export default TenantLookup
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import ReactOnRails from 'react-on-rails';
|
3
|
+
import {Provider} from 'react-redux';
|
4
|
+
|
5
|
+
import Layout from './containers/layout';
|
6
|
+
import CortexStore from './store/store';
|
7
|
+
|
8
|
+
ReactOnRails.registerStore({
|
9
|
+
CortexStore
|
10
|
+
});
|
11
|
+
|
12
|
+
const CortexApp = (props, railsContext) => {
|
13
|
+
const store = ReactOnRails.getStore('CortexStore');
|
14
|
+
return (
|
15
|
+
<Provider store={store}>
|
16
|
+
<Layout temporary_render={props.temporary_render}/>
|
17
|
+
</Provider>
|
18
|
+
);
|
19
|
+
};
|
20
|
+
|
21
|
+
ReactOnRails.register({CortexApp});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import tenantSwitcherReducer from './tenant_switcher_reducer';
|
2
|
+
import railsContextReducer from './rails_context_reducer';
|
3
|
+
import wizardReducer from './wizard_reducer'
|
4
|
+
|
5
|
+
const GetReducers = (CortexState, railsContext) => {
|
6
|
+
return {
|
7
|
+
session: tenantSwitcherReducer(CortexState),
|
8
|
+
wizard: wizardReducer(CortexState),
|
9
|
+
railsContext: railsContextReducer(railsContext)
|
10
|
+
}
|
11
|
+
};
|
12
|
+
|
13
|
+
export default GetReducers
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import {
|
2
|
+
UPDATE_ORGANIZATION_SCOPE,
|
3
|
+
TOGGLE_TENANT_SWITCHER,
|
4
|
+
SELECT_TENANT,
|
5
|
+
TENANT_UPDATED,
|
6
|
+
SUBLIST_CLICKED,
|
7
|
+
TENANT_UPDATE_ERROR,
|
8
|
+
TOGGLE_SIDEBAR,
|
9
|
+
PAGINATE_BACK
|
10
|
+
} from '../constants/tenant_switcher'
|
11
|
+
|
12
|
+
const tenantSwitcherReducer = ({active_tenant, csrf_token, sidebarExpanded, tenants, current_user, environment, environment_abbreviated}) => {
|
13
|
+
const initialState = {
|
14
|
+
tenantListActive: false,
|
15
|
+
activeTenant: active_tenant,
|
16
|
+
parentTenant: active_tenant.parent_id,
|
17
|
+
tenantSyncedWithDB: true,
|
18
|
+
csrf_token,
|
19
|
+
sidebarExpanded,
|
20
|
+
tenants,
|
21
|
+
currentUser: current_user,
|
22
|
+
environment,
|
23
|
+
environment_abbreviated
|
24
|
+
}
|
25
|
+
return function reducer(state = initialState, action) {
|
26
|
+
switch (action.type) {
|
27
|
+
case PAGINATE_BACK:
|
28
|
+
return {
|
29
|
+
...state,
|
30
|
+
parentTenant: action.payload
|
31
|
+
};
|
32
|
+
case SELECT_TENANT:
|
33
|
+
return {
|
34
|
+
...state,
|
35
|
+
activeTenant: action.payload,
|
36
|
+
tenantSyncedWithDB: state.activeTenant.id === action.payload.id
|
37
|
+
};
|
38
|
+
case TENANT_UPDATED:
|
39
|
+
return {
|
40
|
+
...state,
|
41
|
+
currentUser: action.payload,
|
42
|
+
parentTenant: action.payload.active_tenant.parent_id,
|
43
|
+
tenantSyncedWithDB: true,
|
44
|
+
tenantListActive: false
|
45
|
+
}
|
46
|
+
case SUBLIST_CLICKED:
|
47
|
+
return {
|
48
|
+
...state,
|
49
|
+
parentTenant: action.payload
|
50
|
+
}
|
51
|
+
case TENANT_UPDATE_ERROR:
|
52
|
+
return {
|
53
|
+
...state,
|
54
|
+
activeTenant: state.active_tenant
|
55
|
+
}
|
56
|
+
case TOGGLE_SIDEBAR:
|
57
|
+
return {
|
58
|
+
...state,
|
59
|
+
sidebarExpanded: !state.sidebarExpanded,
|
60
|
+
tenantListActive: false
|
61
|
+
};
|
62
|
+
case TOGGLE_TENANT_SWITCHER:
|
63
|
+
return {
|
64
|
+
...state,
|
65
|
+
tenantListActive: !state.tenantListActive,
|
66
|
+
parentTenant: state.activeTenant.parent_id
|
67
|
+
};
|
68
|
+
default:
|
69
|
+
return state
|
70
|
+
}
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
export default tenantSwitcherReducer
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import {
|
2
|
+
FORM_VALID,
|
3
|
+
FORM_INVALID,
|
4
|
+
DISPLAY_VALIDATIONS
|
5
|
+
} from '../constants/wizard'
|
6
|
+
|
7
|
+
const wizardReducer = ({wizard}) => {
|
8
|
+
const initialState = wizard
|
9
|
+
return function reducer(state = initialState, action) {
|
10
|
+
switch (action.type) {
|
11
|
+
case FORM_VALID:
|
12
|
+
return {
|
13
|
+
...state,
|
14
|
+
form_valid: true
|
15
|
+
};
|
16
|
+
case FORM_INVALID:
|
17
|
+
return {
|
18
|
+
...state,
|
19
|
+
form_valid: false
|
20
|
+
};
|
21
|
+
case DISPLAY_VALIDATIONS:
|
22
|
+
return {
|
23
|
+
...state,
|
24
|
+
display_validations: true
|
25
|
+
}
|
26
|
+
default:
|
27
|
+
return state
|
28
|
+
}
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
export default wizardReducer
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import axios from 'axios';
|
2
|
+
|
3
|
+
const SetRailsAPIService = (railsContext, session) => {
|
4
|
+
if (railsContext.serverSide === true) {
|
5
|
+
return axios
|
6
|
+
}
|
7
|
+
axios.defaults.baseURL = window.location.origin
|
8
|
+
axios.defaults.headers.common['X-CSRF-Token'] = session.csrf_token
|
9
|
+
axios.defaults.headers.common['Accept'] = 'application/json'
|
10
|
+
return axios
|
11
|
+
}
|
12
|
+
|
13
|
+
export default SetRailsAPIService
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import {compose, createStore, applyMiddleware, combineReducers} from 'redux';
|
2
|
+
import logger from 'redux-logger'
|
3
|
+
|
4
|
+
import GetReducers from '../reducers'
|
5
|
+
|
6
|
+
export default (props, railsContext) => {
|
7
|
+
const reducers = GetReducers(props, railsContext);
|
8
|
+
const reducer = combineReducers(reducers);
|
9
|
+
|
10
|
+
const composedStore = compose(
|
11
|
+
applyMiddleware(logger),
|
12
|
+
);
|
13
|
+
|
14
|
+
return composedStore(createStore)(reducer);
|
15
|
+
};
|
data/package.json
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
{
|
2
|
+
"name": "cortex",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"main": "node_package/lib/index.js",
|
5
|
+
"homepage": "https://github.com/cortex-cms/cortex",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "https://github.com/cortex-cms/cortex.git"
|
9
|
+
},
|
10
|
+
"keywords": [
|
11
|
+
"cortex",
|
12
|
+
"cms",
|
13
|
+
"rails",
|
14
|
+
"api",
|
15
|
+
"headless",
|
16
|
+
"custom-content",
|
17
|
+
"content",
|
18
|
+
"distribution",
|
19
|
+
"multitenant",
|
20
|
+
"reporting",
|
21
|
+
"graphql",
|
22
|
+
"elasticsearch",
|
23
|
+
"reactjs"
|
24
|
+
],
|
25
|
+
"author": "toastercup@gmail.com",
|
26
|
+
"license": "Apache-2.0",
|
27
|
+
"dependencies": {
|
28
|
+
"redux": "^3.7.2",
|
29
|
+
"redux-logger": "^3.0.6",
|
30
|
+
"jquery": "^3.3.1",
|
31
|
+
"jquery-ui-bundle": "^1.12.1",
|
32
|
+
"jquery-ui-timepicker-addon": "~> 1.6.3",
|
33
|
+
"bourbon": "^4.3.4",
|
34
|
+
"font-awesome": "^4.7.0",
|
35
|
+
"bootstrap-tagsinput": "^0.7.1",
|
36
|
+
"dialog-polyfill": "^0.4.9",
|
37
|
+
"underscore": "~> 1.8.3",
|
38
|
+
"moment": "~> 2.19.3",
|
39
|
+
"bootstrap-sass": "~> 3.3.7",
|
40
|
+
"clipboard": "~> 1.7.1",
|
41
|
+
"material-design-lite": "^1.3.0",
|
42
|
+
"material-ui": "next",
|
43
|
+
"axios": "^0.16.2",
|
44
|
+
"isomorphic-fetch": "^2.2.1"
|
45
|
+
},
|
46
|
+
"devDependencies": {
|
47
|
+
"@rails/webpacker": "3.0.2",
|
48
|
+
"babel-preset-react": "^6.24.1",
|
49
|
+
"babel-cli": "^6.26.0",
|
50
|
+
"coffeescript": "1.12.7",
|
51
|
+
"prop-types": "^15.6.0",
|
52
|
+
"react": "^16.0.0",
|
53
|
+
"react-dom": "^16.0.0"
|
54
|
+
},
|
55
|
+
"files": [
|
56
|
+
"node_package/lib"
|
57
|
+
],
|
58
|
+
"scripts": {
|
59
|
+
"clean": "rm -rf node_package/lib",
|
60
|
+
"prepublish": "yarn run build",
|
61
|
+
"babel": "babel --out-dir node_package/lib node_package/src",
|
62
|
+
"build": "yarn run clean && yarn run babel",
|
63
|
+
"build-watch": "babel --watch --out-dir node_package/lib node_package/src",
|
64
|
+
"prerelease": "yarn run clean && yarn run build"
|
65
|
+
}
|
66
|
+
}
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
Bundler.require(:tasks)
|
5
|
+
require_relative 'config/application'
|
6
|
+
|
7
|
+
CortexStarter::Application.load_tasks
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/* eslint no-console:0 */
|
2
|
+
// This file is automatically compiled by Webpack, along with any other files
|
3
|
+
// present in this directory. You're encouraged to place your actual application logic in
|
4
|
+
// a relevant structure within app/javascript and only use these pack files to reference
|
5
|
+
// that code so it'll be compiled.
|
6
|
+
//
|
7
|
+
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
|
8
|
+
// layout file, like app/views/layouts/application.html.erb
|
@@ -0,0 +1 @@
|
|
1
|
+
import 'cortex';
|
@@ -0,0 +1,11 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
5
|
+
%title Cortex Starter App
|
6
|
+
= csrf_meta_tags
|
7
|
+
= stylesheet_link_tag 'application', media: 'all'
|
8
|
+
= javascript_include_tag 'application'
|
9
|
+
= javascript_pack_tag 'application'
|
10
|
+
%body
|
11
|
+
= yield
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|