diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index a83fa55f540ce1834c16037b8683254cc649056e..be08dbfc4b186852923b9349bf0b5de44e4733b4 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1090,6 +1090,7 @@ "Require_password_change": "Require password change", "Resend_verification_email": "Resend verification email", "Reset": "Reset", + "Reset_section_settings": "Reset section settings", "Reset_password": "Reset password", "Restart": "Restart", "Restart_the_server": "Restart the server", @@ -1516,4 +1517,4 @@ "your_message_optional": "your message (optional)", "Your_password_is_wrong": "Your password is wrong!", "Your_push_was_sent_to_s_devices": "Your push was sent to %s devices" -} \ No newline at end of file +} diff --git a/packages/rocketchat-theme/assets/stylesheets/base.less b/packages/rocketchat-theme/assets/stylesheets/base.less index 47eef3f630cb21a27a530e6dd596243596bc2b31..ee412859e067b86bf33a8f8397648ed03d7582ed 100644 --- a/packages/rocketchat-theme/assets/stylesheets/base.less +++ b/packages/rocketchat-theme/assets/stylesheets/base.less @@ -1830,77 +1830,84 @@ label.required::after { display: none; } } + } - .section-title { - display: flex; - font-size: 24px; - font-weight: 600; - line-height: 40px; + .section-title { + display: flex; + font-size: 24px; + font-weight: 600; + line-height: 40px; - .section-title-text { - flex-grow: 1; - } + .section-title-text { + flex-grow: 1; + } - .section-title-right { - line-height: 0; - } + .section-title-right { + line-height: 0; } + } - .section-content { - border: none !important; - border-radius: 0 !important; - padding: 20px 0 0 !important; + .section-content { + border: none !important; + border-radius: 0 !important; + padding: 20px 0 0 !important; - .input-line { - border-bottom: 1px solid #eeeeee; - padding: 20px 0; - margin-bottom: 0; + .input-line { + border-bottom: 1px solid #eeeeee; + padding: 20px 0; + margin-bottom: 0; + display: flex; + align-items: center; - &:last-child { - border-bottom: none; - padding-bottom: 0; - } + &:last-child { + border-bottom: none; + padding-bottom: 0; + } - &:first-child { - padding-top: 0; - } + &:first-child { + padding-top: 0; + } - > label { - text-align: left; - font-weight: 500; - font-size: 16px; - line-height: 20px; - } + .horizontal { + display: flex; + } - .settings-description { - padding: 5px; - line-height: 20px; - } + .flex-grow-1 { + flex-grow: 1; + } + } - .settings-alert { - border-width: 1px; - font-weight: bold; - padding: 5px; - } + .reset-setting { + margin-left: 20px; + } - .horizontal { - display: flex; - } + .setting-label { + text-align: left; + font-weight: 500; + font-size: 16px; + line-height: 20px; + width: 25%; + } - .flex-grow-1 { - flex-grow: 1; - } + .settings-description { + padding: 5px; + line-height: 20px; + } - .color-editor { - width: 150px; - position: relative; - } - } + .settings-alert { + border-width: 1px; + font-weight: bold; + padding: 5px; + } - .selected-rooms { - .remove-room { - cursor: pointer; - } + .color-editor { + width: 150px; + position: relative; + } + + .selected-rooms { + .remove-room { + cursor: pointer; } } } diff --git a/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less b/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less index 556073235a8d8b964356706a4a730b18f0c9b6c6..fdd2165c524942e8082713a10d286c27ed3986ea 100755 --- a/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less +++ b/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less @@ -256,6 +256,12 @@ a:hover { color: @secondary-font-color; } } + + .section-content { + .reset-setting i { + color: @error-contrast; + } + } } .page-list, diff --git a/packages/rocketchat-ui-admin/admin/admin.coffee b/packages/rocketchat-ui-admin/admin/admin.coffee index 31ed03cf61aa95fd59dfb5a948755f6d34070877..20369d3af7be93e8ffe93d1220d492c72185ea1f 100644 --- a/packages/rocketchat-ui-admin/admin/admin.coffee +++ b/packages/rocketchat-ui-admin/admin/admin.coffee @@ -7,6 +7,31 @@ updateColorComponent = (input = $('input.minicolors')) -> theme: 'rocketchat' letterCase: 'uppercase' +getDefaultSetting = (settingId) -> + return RocketChat.settings.cachedCollectionPrivate.collection.findOne({_id: settingId}) + +setFieldValue = (settingId, value, type, editor) -> + input = $('.page-settings').find('[name="' + settingId + '"]') + + switch type + when 'boolean' + $('.page-settings').find('[name="' + settingId + '"][value="' + Number(value) + '"]').prop('checked', true).change() + when 'code' + input.next()[0].CodeMirror.setValue(value) + when 'color' + editorColor = editor is 'color' + input.parents('.horizontal').find('select[name="color-editor"]').val(editor).change() + input.val(value).change() + + if editorColor + Meteor.setTimeout -> + updateColorComponent(input) + input.minicolors('value', value) + , 100 + + else + input.val(value).change() + Template.admin.onCreated -> if not RocketChat.settings.cachedCollectionPrivate? RocketChat.settings.cachedCollectionPrivate = new RocketChat.CachedCollection({ name: 'private-settings', eventType: 'onAll' }) @@ -279,33 +304,35 @@ Template.admin.events group: group changed: true - settings = TempSettings.find(query, {fields: {_id: 1, value: 1, editor: 1}}).fetch() + settings = TempSettings.find(query, {fields: {_id: 1}}).fetch() settings.forEach (setting) -> - oldSetting = RocketChat.settings.cachedCollectionPrivate.collection.findOne({"_id": setting._id}) - input = $('.page-settings').find('[name="' + setting._id + '"]') - - switch oldSetting.type - when 'boolean' - input.not(':checked').prop('checked', true).change() - when 'code' - input.next()[0].CodeMirror.setValue(oldSetting.value) - when 'color' - oldEditorColor = oldSetting.editor is 'color' - input.parents('.horizontal').find('select[name="color-editor"]').val(oldSetting.editor).change() - - if oldEditorColor && setting.editor is 'color' - input.minicolors('value', oldSetting.value) - else - input.val(oldSetting.value).change() - - if oldEditorColor - Meteor.setTimeout -> - updateColorComponent(input) - , 100 + oldSetting = RocketChat.settings.cachedCollectionPrivate.collection.findOne({_id: setting._id}, {fields: {value: 1, type:1, editor: 1}}) - else - input.val(oldSetting.value).change() + setFieldValue(setting._id, oldSetting.value, oldSetting.type, oldSetting.editor) + + "click .reset-setting": (e, t) -> + e.preventDefault(); + settingId = $(e.target).data('setting') + if typeof settingId is 'undefined' then settingId = $(e.target).parent().data('setting') + + defaultValue = getDefaultSetting(settingId) + + setFieldValue(settingId, defaultValue.packageValue, defaultValue.type, defaultValue.editor) + + "click .reset-group": (e, t) -> + e.preventDefault(); + group = FlowRouter.getParam('group') + section = $(e.target).data('section') + + if section is "" + settings = TempSettings.find({group: group, section: {$exists: false}}, {fields: {_id: 1}}).fetch() + else + settings = TempSettings.find({group: group, section: section}, {fields: {_id: 1}}).fetch() + + settings.forEach (setting) -> + defaultValue = getDefaultSetting(setting._id) + setFieldValue(setting._id, defaultValue.packageValue, defaultValue.type, defaultValue.editor) "click .submit .save": (e, t) -> group = FlowRouter.getParam('group') diff --git a/packages/rocketchat-ui-admin/admin/admin.html b/packages/rocketchat-ui-admin/admin/admin.html index 9fedc720141d724077ba07a590cb3f27dfb5571e..68833b1efe58531cc54d6eec287ff0297eb1daf6 100644 --- a/packages/rocketchat-ui-admin/admin/admin.html +++ b/packages/rocketchat-ui-admin/admin/admin.html @@ -51,8 +51,8 @@ {{/if}} {{#each settings}} <div class="input-line double-col {{#if changed}}setting-changed{{/if}}" {{isDisabled}}> - <label>{{label}}</label> - <div> + <label class="setting-label">{{label}}</label> + <div class="setting-field"> {{#if $eq type 'string'}} {{#if multiline}} <textarea class="input-monitor" name="{{_id}}" rows="4" style="height: auto" {{isDisabled}}>{{value}}</textarea> @@ -194,9 +194,25 @@ <div class="settings-alert"><i class="icon-attention"></i>{{{_ alert}}}</div> {{/if}} </div> + {{#unless $eq group._id 'Assets'}} + <button text="{{_ 'Reset'}}" data-setting="{{_id}}" class="reset-setting button danger"> + <i class="icon-ccw"></i> + </button> + {{/unless}} </div> {{/each}} + {{#unless $eq group._id 'Assets'}} + <div class="input-line double-col"> + <label class="setting-label">{{_ "Reset_section_settings"}}</label> + <div class="setting-field"> + <button data-section="{{section}}" class="reset-group button danger"> + {{_ "Reset"}} + </button> + </div> + </div> + {{/unless}} + {{#if section}} {{#if sectionIsCustomOAuth section}} <div class="submit">