Add migration to enable sharing for legacy service owners
This commit is contained in:
parent
482ffe7d0b
commit
a2e45c85bf
|
@ -0,0 +1,48 @@
|
||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
static targets = ['twitter', 'tumblr', 'custom'];
|
||||||
|
|
||||||
|
declare readonly twitterTarget: HTMLAnchorElement;
|
||||||
|
declare readonly tumblrTarget: HTMLAnchorElement;
|
||||||
|
declare readonly customTarget: HTMLAnchorElement;
|
||||||
|
declare readonly hasCustomTarget: boolean;
|
||||||
|
|
||||||
|
static values = {
|
||||||
|
config: Object,
|
||||||
|
autoClose: Boolean
|
||||||
|
};
|
||||||
|
|
||||||
|
declare readonly configValue: Record<string, string>;
|
||||||
|
declare readonly autoCloseValue: boolean;
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
if (this.autoCloseValue) {
|
||||||
|
this.twitterTarget.addEventListener('click', () => this.close());
|
||||||
|
this.tumblrTarget.addEventListener('click', () => this.close());
|
||||||
|
|
||||||
|
if (this.hasCustomTarget) {
|
||||||
|
this.customTarget.addEventListener('click', () => this.close());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configValueChanged(value): void {
|
||||||
|
if (Object.keys(value).length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.element.classList.remove('d-none');
|
||||||
|
|
||||||
|
this.twitterTarget.href = this.configValue['twitter'];
|
||||||
|
this.tumblrTarget.href = this.configValue['tumblr'];
|
||||||
|
|
||||||
|
if (this.hasCustomTarget) {
|
||||||
|
this.customTarget.href = `${this.customTarget.href}${this.configValue['custom']}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(): void {
|
||||||
|
(this.element.closest(".inbox-entry")).remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module User::SharingMethods
|
||||||
|
def display_sharing_custom_url
|
||||||
|
URI(sharing_custom_url).host
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class EnableSharingForServiceOwners < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
execute <<~SQUIRREL
|
||||||
|
UPDATE users
|
||||||
|
SET sharing_enabled = true
|
||||||
|
WHERE id IN (SELECT user_id FROM services);
|
||||||
|
SQUIRREL
|
||||||
|
end
|
||||||
|
|
||||||
|
def down; end
|
||||||
|
end
|
Loading…
Reference in New Issue