Commit 8dc7efb2 authored by Luke Bennett's avatar Luke Bennett

Improve project avatar settings

Prioritize and simplify project settings content.
parent 13cd7cd7
import $ from 'jquery'; import $ from 'jquery';
export default function groupAvatar() { export default function initAvatarPicker() {
$('.js-choose-group-avatar-button').on('click', function onClickGroupAvatar() { $('.js-choose-avatar-button').on('click', function onClickAvatar() {
const form = $(this).closest('form'); const form = $(this).closest('form');
return form.find('.js-group-avatar-input').click(); return form.find('.js-avatar-input').click();
}); });
$('.js-group-avatar-input').on('change', function onChangeAvatarInput() {
$('.js-avatar-input').on('change', function onChangeAvatarInput() {
const form = $(this).closest('form'); const form = $(this).closest('form');
const filename = $(this) const filename = $(this)
.val() .val()
......
import groupAvatar from '~/group_avatar'; import initAvatarPicker from '~/avatar_picker';
document.addEventListener('DOMContentLoaded', groupAvatar); document.addEventListener('DOMContentLoaded', initAvatarPicker);
import BindInOut from '../../../../behaviors/bind_in_out'; import BindInOut from '../../../../behaviors/bind_in_out';
import Group from '../../../../group'; import Group from '../../../../group';
import groupAvatar from '../../../../group_avatar'; import initAvatarPicker from '~/avatar_picker';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
BindInOut.initAll(); BindInOut.initAll();
new Group(); // eslint-disable-line no-new new Group(); // eslint-disable-line no-new
groupAvatar(); initAvatarPicker();
}); });
import groupAvatar from '~/group_avatar'; import initAvatarPicker from '~/avatar_picker';
import TransferDropdown from '~/groups/transfer_dropdown'; import TransferDropdown from '~/groups/transfer_dropdown';
import initConfirmDangerModal from '~/confirm_danger_modal'; import initConfirmDangerModal from '~/confirm_danger_modal';
import initSettingsPanels from '~/settings_panels'; import initSettingsPanels from '~/settings_panels';
...@@ -9,7 +9,7 @@ import groupsSelect from '~/groups_select'; ...@@ -9,7 +9,7 @@ import groupsSelect from '~/groups_select';
import projectSelect from '~/project_select'; import projectSelect from '~/project_select';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
groupAvatar(); initAvatarPicker();
new TransferDropdown(); // eslint-disable-line no-new new TransferDropdown(); // eslint-disable-line no-new
initConfirmDangerModal(); initConfirmDangerModal();
initSettingsPanels(); initSettingsPanels();
......
import BindInOut from '~/behaviors/bind_in_out'; import BindInOut from '~/behaviors/bind_in_out';
import Group from '~/group'; import Group from '~/group';
import groupAvatar from '~/group_avatar'; import initAvatarPicker from '~/avatar_picker';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
BindInOut.initAll(); BindInOut.initAll();
new Group(); // eslint-disable-line no-new new Group(); // eslint-disable-line no-new
groupAvatar(); initAvatarPicker();
}); });
...@@ -3,7 +3,7 @@ import initSettingsPanels from '~/settings_panels'; ...@@ -3,7 +3,7 @@ import initSettingsPanels from '~/settings_panels';
import setupProjectEdit from '~/project_edit'; import setupProjectEdit from '~/project_edit';
import initConfirmDangerModal from '~/confirm_danger_modal'; import initConfirmDangerModal from '~/confirm_danger_modal';
import mountBadgeSettings from '~/pages/shared/mount_badge_settings'; import mountBadgeSettings from '~/pages/shared/mount_badge_settings';
import fileUpload from '~/lib/utils/file_upload'; import initAvatarPicker from '~/avatar_picker';
import initProjectLoadingSpinner from '../shared/save_project_loader'; import initProjectLoadingSpinner from '../shared/save_project_loader';
import initProjectPermissionsSettings from '../shared/permissions'; import initProjectPermissionsSettings from '../shared/permissions';
...@@ -12,7 +12,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -12,7 +12,7 @@ document.addEventListener('DOMContentLoaded', () => {
setupProjectEdit(); setupProjectEdit();
// Initialize expandable settings panels // Initialize expandable settings panels
initSettingsPanels(); initSettingsPanels();
fileUpload('.js-choose-project-avatar-button', '.js-project-avatar-input'); initAvatarPicker();
initProjectPermissionsSettings(); initProjectPermissionsSettings();
initConfirmDangerModal(); initConfirmDangerModal();
mountBadgeSettings(PROJECT_BADGE); mountBadgeSettings(PROJECT_BADGE);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
.form-group.row.group-description-holder .form-group.row.group-description-holder
= f.label :avatar, _("Group avatar"), class: 'col-form-label col-sm-2' = f.label :avatar, _("Group avatar"), class: 'col-form-label col-sm-2'
.col-sm-10 .col-sm-10
= render 'shared/choose_group_avatar_button', f: f = render 'shared/choose_avatar_button', f: f
= render 'shared/old_visibility_level', f: f, visibility_level: visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group, with_label: false = render 'shared/old_visibility_level', f: f, visibility_level: visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group, with_label: false
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
.form-group.group-description-holder.col-sm-12 .form-group.group-description-holder.col-sm-12
= f.label :avatar, _("Group avatar"), class: 'label-bold' = f.label :avatar, _("Group avatar"), class: 'label-bold'
%div %div
= render 'shared/choose_group_avatar_button', f: f = render 'shared/choose_avatar_button', f: f
.form-group.col-sm-12 .form-group.col-sm-12
%label.label-bold %label.label-bold
......
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
.avatar-container.rect-avatar.s90 .avatar-container.rect-avatar.s90
= group_icon(@group, alt: '', class: 'avatar group-avatar s90') = group_icon(@group, alt: '', class: 'avatar group-avatar s90')
= f.label :avatar, _('Group avatar'), class: 'label-bold d-block' = f.label :avatar, _('Group avatar'), class: 'label-bold d-block'
= render 'shared/choose_group_avatar_button', f: f = render 'shared/choose_avatar_button', f: f
- if @group.avatar? - if @group.avatar?
%hr %hr
= link_to _('Remove avatar'), group_avatar_path(@group.to_param), data: { confirm: _('Avatar will be removed. Are you sure?')}, method: :delete, class: 'btn btn-danger btn-inverted' = link_to _('Remove avatar'), group_avatar_path(@group.to_param), data: { confirm: _('Avatar will be removed. Are you sure?')}, method: :delete, class: 'btn btn-link'
= render 'shared/visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group = render 'shared/visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group
......
...@@ -40,23 +40,16 @@ ...@@ -40,23 +40,16 @@
= f.label :tag_list, "Topics", class: 'label-bold' = f.label :tag_list, "Topics", class: 'label-bold'
= f.text_field :tag_list, value: @project.tag_list.join(', '), maxlength: 2000, class: "form-control" = f.text_field :tag_list, value: @project.tag_list.join(', '), maxlength: 2000, class: "form-control"
%p.form-text.text-muted Separate topics with commas. %p.form-text.text-muted Separate topics with commas.
%fieldset.features
%h5.prepend-top-0= _("Project avatar") .form-group.prepend-top-default.append-bottom-20
.form-group .avatar-container.s90
- if @project.avatar? = project_icon(@project, alt: _('Project avatar'), class: 'avatar project-avatar s90')
.avatar-container.rect-avatar.s160.append-bottom-15 = f.label :avatar, _('Project avatar'), class: 'label-bold d-block'
= project_icon(@project, alt: '', class: 'avatar project-avatar s160', width: 160, height: 160) = render 'shared/choose_avatar_button', f: f
- if @project.avatar_in_git - if @project.avatar?
%p.light %hr
= _("Project avatar in repository: %{link}").html_safe % { link: @project.avatar_in_git } = link_to _('Remove avatar'), project_avatar_path(@project), data: { confirm: _('Avatar will be removed. Are you sure?')}, method: :delete, class: 'btn btn-link'
.prepend-top-5.append-bottom-10
%button.btn.js-choose-project-avatar-button{ type: 'button' }= _("Choose file...")
%span.file_name.prepend-left-default.js-filename= _("No file chosen")
= f.file_field :avatar, class: "js-project-avatar-input hidden"
.form-text.text-muted= _("The maximum file size allowed is 200KB.")
- if @project.avatar?
%hr
= link_to _('Remove avatar'), project_avatar_path(@project), data: { confirm: _("Avatar will be removed. Are you sure?") }, method: :delete, class: "btn btn-danger btn-inverted"
= f.submit 'Save changes', class: "btn btn-success js-btn-success-general-project-settings" = f.submit 'Save changes', class: "btn btn-success js-btn-success-general-project-settings"
%section.settings.sharing-permissions.no-animate#js-shared-permissions{ class: ('expanded' if expanded) } %section.settings.sharing-permissions.no-animate#js-shared-permissions{ class: ('expanded' if expanded) }
......
%button.btn.js-choose-group-avatar-button{ type: 'button' }= _("Choose File ...") %button.btn.js-choose-avatar-button{ type: 'button' }= _("Choose file…")
%span.file_name.js-avatar-filename= _("No file chosen") %span.file_name.js-avatar-filename= _("No file chosen")
= f.file_field :avatar, class: "js-group-avatar-input hidden" = f.file_field :avatar, class: "js-avatar-input hidden"
.form-text.text-muted= _("The maximum file size allowed is 200KB.") .form-text.text-muted= _("The maximum file size allowed is 200KB.")
---
title: Change project avatar remove button to a link
merge_request: 26589
author:
type: other
...@@ -1482,9 +1482,6 @@ msgstr "" ...@@ -1482,9 +1482,6 @@ msgstr ""
msgid "Choose <strong>Next</strong> at the bottom of the page." msgid "Choose <strong>Next</strong> at the bottom of the page."
msgstr "" msgstr ""
msgid "Choose File ..."
msgstr ""
msgid "Choose a branch/tag (e.g. %{master}) or enter a commit (e.g. %{sha}) to see what's changed or to create a merge request." msgid "Choose a branch/tag (e.g. %{master}) or enter a commit (e.g. %{sha}) to see what's changed or to create a merge request."
msgstr "" msgstr ""
...@@ -1506,7 +1503,7 @@ msgstr "" ...@@ -1506,7 +1503,7 @@ msgstr ""
msgid "Choose between <code>clone</code> or <code>fetch</code> to get the recent application code" msgid "Choose between <code>clone</code> or <code>fetch</code> to get the recent application code"
msgstr "" msgstr ""
msgid "Choose file..." msgid "Choose file"
msgstr "" msgstr ""
msgid "Choose the top-level group for your repository imports." msgid "Choose the top-level group for your repository imports."
...@@ -6241,9 +6238,6 @@ msgstr "" ...@@ -6241,9 +6238,6 @@ msgstr ""
msgid "Project avatar" msgid "Project avatar"
msgstr "" msgstr ""
msgid "Project avatar in repository: %{link}"
msgstr ""
msgid "Project details" msgid "Project details"
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment