Skip to content

Digidem rebased#2

Open
luandro wants to merge 22 commits intodigidemfrom
digidem-rebased
Open

Digidem rebased#2
luandro wants to merge 22 commits intodigidemfrom
digidem-rebased

Conversation

@luandro
Copy link

@luandro luandro commented May 4, 2023

No description provided.

lauramosher and others added 22 commits November 10, 2022 18:14
* Fix: Locale fallbacks; default was getting overwritten

* Chore: remove unnecessary puts

* feat: Add feature flags

Adds the Flipper gem for feature flagging along

* Feat: Add ability for super admin to manage Feature Flags

* Add beta flag to Community

* Register beta group to Flipper gates
* Redesign rails eror pages

* Fix corrupted files for favicon and apple touch icons in public folder

* Add new offline environment

* Create special offline.env to override dev environment

* Add ability to precompile assets field kit deploy

The primary server start script now looks for RAILS_ENV=offline and will
precompile assets for the user when provided. Also adds public/assets to
.gitignore to avoid committing to repo.

* Fix: boot issue if HOST_HOSTNAME isn't defined

* Fix: Remove production env override of internationalization fallback (use global setting)

* Build standalone docker image for Terrastories

This adds Docker configuration to successfully build and generate an
image that can run Terrastories — excluding necessary external services
(offline tileserver, database).
* add m4a mime type

* add a couple more common mimetypes
* Add public flag to Community

* Feat: Mark community as public

This has not been made available to all communities yet.

This feature can be enabled for a community by a Super Admin.

This ONLY allows marking a community public — it does nothing else. aka:
a feature that leads to nowhere.

* fix: public_community -> public_communities in policy
* fix: viewers should be able to view speakers that are available on anonymous stories

* chore: Remove unused Devise features

This turns off registrations but leaves the current code in place in
case we ever want to resurrect it for offline-communtiies.

This removes:
- Confirmations (views were there, but not enabled)
- Recoverable (forgot password screens)
- Lockable (too many logins would lock)

Note: ALL of the datatbase attributes that power these features are
still in place in case we ever wish to turn these back on.

* fix: unable to save new community with empty email

TL;DR: The unique index on users_email was causing a fatal error when
more than one email was set to null or empty string.

While we still want an index for fast lookups, we needed to remove the
unique constraint.
This adds an automatic onboarding detection if a community is booting up
Terrastories for the first time. It's determined by if the app is in
"offline" mode (either enabled by using an offline/local tileserver or
by running with RAILS_ENV=offline) AND the database does not detect an
existing Community.

It also, at the moment, adds a just-in-case Super Admin account.
* fix: change admin page to member dashboard

* remove switch for member dashboard route
)

* 📄 Docs overhaul in light of docs.terrastories.app

* chore: small fixes and adding script to SETUP
* Add slug to Community

This slug will be used in URL's for public interface to avoid exposting
ID's or other database information.

* Reverse Theme <> Community relationship

Before, Community belonged to a theme. This caused some weird behavior
on how the Theme was created when a Community was created (Theme had to
be created/built first). Now, a Theme belongs to a Community and is
created after a Community is created.

* Remove theme_id from community

* Moves Sponsor Logos and Background Image to Community

In an effort to make "theme" map settings and put community settings
directly on the community, this moves the sponsor logos and the
background image directly onto the Community.

This is done via a data-only migration which updates the active storage
attachments to switch from Theme to Community (and back on a rollback).

For backwards compatibility:

1. The Theme page for Admin's now accepts nested attributes for the
   background image and sponsor logos. This will ensure current behavior
   appears to stay the same, even though the backend storage is changed.
2. If a Community has `split_settings` feature enabled, the welcome area
   settings in Theme is hidden and is instead available in the Settings
   tab in the sidebar.

This also fixes an issue where "Settings" was not showing up since it
was checking if Split Settings was enabled for ALL and not just the
current community.

And lastly, this removes the `set_theme` before actions that were
required in order to display the splash welcome screen background and
logos, since now we just look it up from the Community record.

* Fix: reset.scss overwrote font-style on html tags incorrectly.

* Replace `associated_updated_at` w/ touch: true

Rather than building associated_updated_at by doing several trips to the
database to look up most recent updated_at date; we can utilize Rails
belong_to relation option `touch: true` to update community every time a
change is made to a nested model that we want to track on the Community.

* include community sorts in filter form for Super Admin

* remove theme from community seed

* Fix: allow split settings community update to save background img and sponsor logos

* Fix: move delete attachments from Theme controller to Community controller

* Fix: fk and orphaned theme migration

* Demo: attach example bg image in seeds

* Demo: attach example sponsor logo in seeds

* Fix: syntax error in Welcome#show

Co-authored-by: Rudo Kemper <31662219+rudokemper@users.noreply.github.com>
* chore: do not show user profile path for super admin

* chore: Remove extraneous closing tag

Co-authored-by: Laura Mosher <laura@mosher.tech>
…es#900)

* Fix error with rubygems-update

```
ERROR:  Error installing rubygems-update:
	There are no versions of rubygems-update (= 3.4.3) compatible with your Ruby & RubyGems
	rubygems-update requires Ruby version >= 2.6.0. The current ruby version is 2.5.9.229.
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory @ dir_chdir - /usr/local/bundle/gems/rubygems-update-3.0.3
```

Same issue as ruby/rubygems#2534,
following the suggested workaround in the comments there to install an
older version of rubygems-update

* Pin bundler version to avoid error with Ruby 2.5.9

Without this, we get this error
```
Fetching gem metadata from https://rubygems.org/..........
bundler-2.4.5 requires ruby version >= 2.6.0, which is incompatible with the
current version, 2.5.9
```

According to https://bundler.io/compatibility.html, the highest version
of bundler that supports Ruby 2.5.9 is 2.3, so ~> to 2.3.0, which should
get us on bundler 2.3.26 but not >= 2.4.0
* Remove old specs for non-existent code, fix specs that have defaults changed

* Fix: Import

There are a couple of odd issues with import that came up recently. This
commit adds testing around the new import areas and fixes a few issues:

1. When media was not found, still import.
2. Correctly associate belongs_to records.
3. Correctly associate has_many* records.
4. Columns that are not mapped don't break the import.

---------

Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
* Fix: Profile Change Password

There was an issue reported relating to changing both password and
username that resulted in the user getting logged out and potentially
locked out due to the username/email getting malformed.

In order to make this flow smoother:

1. Password changes are now their own controller and set of views. This
   also ensures we can bypass sign in when the password changes to allow
   invisible password session changes.
2. Profile updates are now in a separate profiles controller. This
   allows admin modification of users to remain separate from user
   modification of their own profile.

* Allow Super Admins to modify their user record

- Allows super admin to change their password
- Allows super admin to update their username, email, photo, etc

* Address PR feedback

---------

Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
* Upgrade webpacker to latest

* Switch from using i18n-js to react-i18next

The first of a few refactors to stop loading the front-end map portion
("Home") using BOTH webpacker AND asset pipeline / sprockets. The split
is confusing and has caused some issues with where to include JS /
packages / etc.

i18n-js utilize Rails translations and allowed them to be converted and
loaded into JS in a rails-y way. v3 of the gem, this had a very
"magical" feel and did not require a separate package, though one was
optionally available. v4 of them required both the gem AND the package,
plus an additional build-time CLI to export the translation files for
use in a production environment.

The v3 to v4 ugprade would require a lot of additional work and
maintenance overhead and our long-term goal is to move translations into
an external / no-code oss platform for shared use. As such, this PR
separates out the React portion of translations from the Rails
translations and defines them to use in JSON files for react i18next.

* Remove plyr-rails gem

This appears to be unused despite being loaded. Removing the gem.

If we decide we want to use / link up Plyr in the future, we can do so
using the NPM package for the map sidebar; or re-add it for the
dashbaord (where it is not current loaded).

* Use npm mapbox-gl for React map

This does NOT remove the mapbox-gl gem as that is used by the dashboard;
however, it is removed from the application styles and javascript
includes and is instead included in package.json and imported for usage.

This also required converting the minimap to an es6 module.

* Switch i18n setup to its own file

* Bundle pause_all_videos in application pack

* Bundle React/Map styles in Webpack; not sprockets

* Lock mapbox-gl version to the same as Rails gemfile version (2.9.0)

* Add comments and remove extraneous consoles.

* Fix deprecration error: DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated

* Upgrade Ruby 2.5.9 -> 2.6.0

* Upgrade Ruby 2.6.0 -> 2.6.10

* Update bundler

* Config change

* Set versions for gems

* Only require rails modules that we use

* bundle update rails

* bundle update pg

* fixup: moduleize

* Switch from CSS in Webpacker to CSS Bundling

(my bad on moving everything to webpacker...only to learn after that it
was a complete waste of time...)

* require relative

* Upgrade Ruby 2.6.10 -> 2.7.0

* Ruby 2.7.0 -> 2.7.7 (latest patch in 2.7 before 3.0)

* Update React-Select

* Update aws-sdk-s3

* Update Devise

Devise 4.9 is Ruby 3 ready. Since we are still using ujs (and not
turbo), most of the changes are irrelevant to our setup.

For ease in future updates, this makes sure that links relying on UJS,
both in and outside of devise, are both ujs and turbo compatible. This
also opts in to the new Devise configuration.

* Update devise-i18n to match with devise updates

* Update Flipper; also fix missing community -> current_community

* Update geocoder

* Update Listen

* Update Pundit

* Update comments

* Upgrade @babel/core

* Bump i18next

* Only include one source for Mapbox

Before we bundled both Mapbox Rails (gem) and Mapbox gl (npm). This
removes the Rails version (which was a wrapper for the js file, and
frequently behind).

Asset files correctly add mapbox-gl to webpacked version (import) and
sprokets (//= require mapbox-gl).

* Upgrade mapbox-gl

* Add webpack-dev-server to dev bootup

* Remove tileserver fonts

* Add tileserver specific gitignore

* rails credentials key is optional, even in production

* Remove ActionCable

* Remove root level .dockerignore (unused)

* Remove unused start script

* Readd mailer, required for devise

* Improve offline configuration and add comments

* Use single Dockerfile with mulit-stage targets for dev

* Remove now obsolete standalone dockerfile

* Add workflow to build and push devcore image to Docker

---------

Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
* Use compose host (db) in default offline DATABASE_URL configuration.

* Offline Mode: Generate secret_key_base

Between the creation of Rails.env.offline, removal of Rails.credentials
and the requirement of RAILS_MASTER_KEY, and updates, RAILS_ENV=offline
stopped booting due to missing SECRET_KEY_BASE.

Rather than requiring folks setting up the full development mode to have
one created automatically, this updates the environments/offline.rb file
to generate a new one and store it in a tmp file accessible by the app
(and stored in Docker, similar to development). This also removes the
need to generate and store one in the Docker image (which would be used
by all communities using that image), or adding even more steps to
generate the string and add it.

It mirrors the implementation Rails uses for Rails.env.test and
Rails.env.development.

It also accounts for any setups that DO utilize an ENV variable. So if
one is set, it uses it, otherwise it creates a new one.

* Lock Dockerfile image tag to minor ruby patch

* Pre-compile assets for offline mode setup

This updates bin/setup to precompile assets of offline mode setup is
selected. It's prefixed by offline-assets so as to not interfere with
other precompilation tasks.

Developers using RAILS_ENV=offline will need to beware that changes to
assets will not reflect without re-compiling between changes. It's
recommended to test offline tileserver maps in development mode using
OFFLINE_MAP_STYLE or USE_LOCAL_MAP_SERVER for testing with
RAILS_ENV=development instead.

---------

Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants