Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions app/javascript/pages/Users/Settings/Editors.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@

let { user, options }: Props = $props();

let goalsDisabled = $derived(
user.hackatime_extension_text_type !== "simple_text",
);
let extensionTextType = $state(user.hackatime_extension_text_type);
let showGoalsInStatusbar = $state(user.show_goals_in_statusbar);

$effect(() => {
extensionTextType = user.hackatime_extension_text_type;
showGoalsInStatusbar = user.show_goals_in_statusbar;
});

let goalsDisabled = $derived(extensionTextType !== "simple_text");
</script>

<svelte:head>
Expand All @@ -49,14 +55,14 @@
<Select
id="extension_type"
name="user[hackatime_extension_text_type]"
bind:value={user.hackatime_extension_text_type}
bind:value={extensionTextType}
items={options.extension_text_types}
/>
</FormField>

<CheckboxField
name="user[show_goals_in_statusbar]"
bind:checked={user.show_goals_in_statusbar}
bind:checked={showGoalsInStatusbar}
disabled={goalsDisabled}
align="start"
label="Show daily goal in status bar"
Expand Down
8 changes: 7 additions & 1 deletion app/javascript/pages/Users/Settings/Notifications.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
};

let { user }: Props = $props();

let weeklySummaryEmailEnabled = $state(user.weekly_summary_email_enabled);

$effect(() => {
weeklySummaryEmailEnabled = user.weekly_summary_email_enabled;
});
</script>

<svelte:head>
Expand All @@ -36,7 +42,7 @@
<div id="user_weekly_summary_email">
<CheckboxField
name="user[weekly_summary_email_enabled]"
bind:checked={user.weekly_summary_email_enabled}
bind:checked={weeklySummaryEmailEnabled}
label="Weekly coding summary email (sent Sundays at 6:30 PM GMT)"
/>
<p class="mt-2 text-xs text-muted">
Expand Down
7 changes: 6 additions & 1 deletion app/javascript/pages/Users/Settings/Privacy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"Something else",
];

let allowPublicStatsLookup = $state(user.allow_public_stats_lookup);
let rotatingApiKey = $state(false);
let apiKeyCopied = $state(false);
let rotateApiKeyModalOpen = $state(false);
Expand All @@ -52,6 +53,10 @@
deletionReason.length > 0 && deletionReasonDetails.trim().length > 0,
);

$effect(() => {
allowPublicStatsLookup = user.allow_public_stats_lookup;
});

const rotateApiKey = () => {
if (rotatingApiKey) return;
rotatingApiKey = true;
Expand Down Expand Up @@ -93,7 +98,7 @@
>
<CheckboxField
name="user[allow_public_stats_lookup]"
bind:checked={user.allow_public_stats_lookup}
bind:checked={allowPublicStatsLookup}
label="Allow public stats lookup"
/>
</Form>
Expand Down
7 changes: 6 additions & 1 deletion app/javascript/pages/Users/Settings/SlackGithub.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@

let { user, slack, github }: Props = $props();

let usesSlackStatus = $state(user.uses_slack_status);
let unlinkGithubModalOpen = $state(false);

$effect(() => {
usesSlackStatus = user.uses_slack_status;
});
</script>

<svelte:head>
Expand Down Expand Up @@ -62,7 +67,7 @@
>
<CheckboxField
name="user[uses_slack_status]"
bind:checked={user.uses_slack_status}
bind:checked={usesSlackStatus}
label="Update my Slack status automatically"
/>
</Form>
Expand Down
20 changes: 20 additions & 0 deletions test/system/settings/editors_settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,29 @@ class EditorsSettingsTest < ApplicationSystemTestCase
visit my_settings_editors_path

choose_select_option("extension_type", "Clock emoji")
assert_selector "[role='checkbox'][disabled]"
click_on "Save extension settings"

assert_text "Settings updated successfully"
assert_equal "clock_emoji", @user.reload.hackatime_extension_text_type
end

test "editors settings restores server values after a rejected update" do
@user.update!(
hackatime_extension_text_type: :simple_text,
show_goals_in_statusbar: false
)

visit my_settings_editors_path
@user.update_column(:country_code, "ZZ")

find("[role='checkbox']").click
choose_select_option("extension_type", "Clock emoji")
click_on "Save extension settings"

assert_text "Country code is not included in the list"

choose_select_option("extension_type", "Simple text")
assert_selector "[role='checkbox'][aria-checked='false']:not([disabled])"
end
end