diff --git a/app/assets/images/new_nav.png b/app/assets/images/new_nav.png new file mode 100644 index 0000000000000000000000000000000000000000..8879d26d341186a1161a7dd1d83f108ad9fe5b12 Binary files /dev/null and b/app/assets/images/new_nav.png differ diff --git a/app/assets/images/old_nav.png b/app/assets/images/old_nav.png new file mode 100644 index 0000000000000000000000000000000000000000..23fae7aa19e9f20fd8d258bcea1196844b3b3f08 Binary files /dev/null and b/app/assets/images/old_nav.png differ diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 88b4b567fa9e76d9ca4b45573fb0364938fea49e..31a86090242b793ca103ac4692dd811c08976a36 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -55,6 +55,7 @@ import RefSelectDropdown from './ref_select_dropdown'; import GfmAutoComplete from './gfm_auto_complete'; import ShortcutsBlob from './shortcuts_blob'; import initSettingsPanels from './settings_panels'; +import initExperimentalFlags from './experimental_flags'; (function() { var Dispatcher; @@ -120,6 +121,9 @@ import initSettingsPanels from './settings_panels'; } switch (page) { + case 'profiles:preferences:show': + initExperimentalFlags(); + break; case 'sessions:new': new UsernameValidator(); new ActiveTabMemoizer(); diff --git a/app/assets/javascripts/experimental_flags.js b/app/assets/javascripts/experimental_flags.js new file mode 100644 index 0000000000000000000000000000000000000000..5564df2515950bb4d3ec0d05c246fb4f0dd83ec5 --- /dev/null +++ b/app/assets/javascripts/experimental_flags.js @@ -0,0 +1,11 @@ +import Cookies from 'js-cookie'; + +export default () => { + $('.js-expirement-feature-toggle').on('change', (e) => { + const el = e.target; + + Cookies.set(el.name, el.value, { + expires: 365 * 10, + }); + }); +}; diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index 249253f49069acf7968c65878567746d851020ed..34dcde3890889ae61a973ccc6f4dd5997497d3f6 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -74,6 +74,8 @@ = link_to "Profile", current_user, class: 'profile-link', data: { user: current_user.username } %li = link_to "Settings", profile_path + %li + = link_to "Turn on new nav", profile_preferences_path(anchor: "new-navigation") %li.divider %li = link_to "Sign out", destroy_user_session_path, method: :delete, class: "sign-out-link" diff --git a/app/views/layouts/header/_new.html.haml b/app/views/layouts/header/_new.html.haml index db3650e52a4addde5bfe0a6f7e8ca5a10a07d8ac..e4b5e5302afde74dccecd7b4df0078699f44c487 100644 --- a/app/views/layouts/header/_new.html.haml +++ b/app/views/layouts/header/_new.html.haml @@ -74,6 +74,8 @@ = link_to "Profile", current_user, class: 'profile-link', data: { user: current_user.username } %li = link_to "Settings", profile_path + %li + = link_to "Turn off new nav", profile_preferences_path(anchor: "new-navigation") %li.divider %li = link_to "Sign out", destroy_user_session_path, method: :delete, class: "sign-out-link" diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml index 0ff19b3eab13399ccb971267eb5cbba17576f2ad..8a6dc4a12a8e84a229833b9f2fc12bbf2d114ae9 100644 --- a/app/views/profiles/preferences/show.html.haml +++ b/app/views/profiles/preferences/show.html.haml @@ -17,6 +17,24 @@ = scheme.name .col-sm-12 %hr + .col-lg-3.profile-settings-sidebar#new-navigation + %h4.prepend-top-0 + New Navigation + %p + This setting allows you to turn on or off the new upcoming navigation concept. + = succeed '.' do + = link_to 'Learn more', '', target: '_blank' + .col-lg-9.syntax-theme + = label_tag do + .preview= image_tag "old_nav.png" + %input.js-expirement-feature-toggle{ type: "radio", value: "false", name: "new_nav", checked: !show_new_nav? } + Old + = label_tag do + .preview= image_tag "new_nav.png" + %input.js-expirement-feature-toggle{ type: "radio", value: "true", name: "new_nav", checked: show_new_nav? } + New + .col-sm-12 + %hr .col-lg-3.profile-settings-sidebar %h4.prepend-top-0 Behavior