debian-mirror-gitlab/app/assets/javascripts/diffs/components/settings_dropdown.vue

117 lines
3.2 KiB
Vue
Raw Normal View History

2019-03-02 22:35:43 +05:30
<script>
2021-09-04 01:27:46 +05:30
import {
GlButtonGroup,
GlButton,
GlDropdown,
GlFormCheckbox,
GlTooltipDirective,
} from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions, mapGetters, mapState } from 'vuex';
2021-02-22 17:27:13 +05:30
import { SETTINGS_DROPDOWN } from '../i18n';
2019-03-02 22:35:43 +05:30
export default {
2021-02-22 17:27:13 +05:30
i18n: SETTINGS_DROPDOWN,
2021-09-04 01:27:46 +05:30
directives: {
GlTooltip: GlTooltipDirective,
},
2019-03-02 22:35:43 +05:30
components: {
2020-11-24 15:15:51 +05:30
GlButtonGroup,
GlButton,
GlDropdown,
2021-02-22 17:27:13 +05:30
GlFormCheckbox,
2019-03-02 22:35:43 +05:30
},
computed: {
...mapGetters('diffs', ['isInlineView', 'isParallelView']),
2021-02-22 17:27:13 +05:30
...mapState('diffs', ['renderTreeList', 'showWhitespace', 'viewDiffsFileByFile']),
2020-11-24 15:15:51 +05:30
},
2019-03-02 22:35:43 +05:30
methods: {
...mapActions('diffs', [
'setInlineDiffViewType',
'setParallelDiffViewType',
'setRenderTreeList',
'setShowWhitespace',
2021-04-17 20:07:23 +05:30
'setFileByFile',
2019-03-02 22:35:43 +05:30
]),
2021-02-22 17:27:13 +05:30
toggleFileByFile() {
2021-04-17 20:07:23 +05:30
this.setFileByFile({ fileByFile: !this.viewDiffsFileByFile });
},
toggleWhitespace(updatedSetting) {
2021-09-04 01:27:46 +05:30
this.setShowWhitespace({ showWhitespace: updatedSetting });
2020-11-24 15:15:51 +05:30
},
2019-03-02 22:35:43 +05:30
},
};
</script>
<template>
2021-02-22 17:27:13 +05:30
<gl-dropdown
2021-09-04 01:27:46 +05:30
v-gl-tooltip
2021-02-22 17:27:13 +05:30
icon="settings"
2021-09-04 01:27:46 +05:30
:title="$options.i18n.preferences"
:text="$options.i18n.preferences"
2021-02-22 17:27:13 +05:30
:text-sr-only="true"
2021-09-04 01:27:46 +05:30
:aria-label="$options.i18n.preferences"
:header-text="$options.i18n.preferences"
2021-02-22 17:27:13 +05:30
toggle-class="js-show-diff-settings"
right
>
2020-11-24 15:15:51 +05:30
<div class="gl-px-3">
<span class="gl-font-weight-bold gl-display-block gl-mb-2">{{ __('File browser') }}</span>
<gl-button-group class="gl-display-flex">
<gl-button
:class="{ selected: !renderTreeList }"
class="gl-w-half js-list-view"
2021-10-27 15:23:28 +05:30
@click="setRenderTreeList({ renderTreeList: false })"
2020-11-24 15:15:51 +05:30
>
{{ __('List view') }}
</gl-button>
<gl-button
:class="{ selected: renderTreeList }"
class="gl-w-half js-tree-view"
2021-10-27 15:23:28 +05:30
@click="setRenderTreeList({ renderTreeList: true })"
2020-11-24 15:15:51 +05:30
>
{{ __('Tree view') }}
</gl-button>
</gl-button-group>
</div>
<div class="gl-mt-3 gl-px-3">
<span class="gl-font-weight-bold gl-display-block gl-mb-2">{{ __('Compare changes') }}</span>
<gl-button-group class="gl-display-flex js-diff-view-buttons">
<gl-button
id="inline-diff-btn"
:class="{ selected: isInlineView }"
class="gl-w-half js-inline-diff-button"
data-view-type="inline"
@click="setInlineDiffViewType"
>
{{ __('Inline') }}
</gl-button>
<gl-button
id="parallel-diff-btn"
:class="{ selected: isParallelView }"
class="gl-w-half js-parallel-diff-button"
data-view-type="parallel"
@click="setParallelDiffViewType"
>
{{ __('Side-by-side') }}
</gl-button>
</gl-button-group>
</div>
2021-04-17 20:07:23 +05:30
<gl-form-checkbox
data-testid="show-whitespace"
class="gl-mt-3 gl-ml-3"
:checked="showWhitespace"
@input="toggleWhitespace"
>
{{ $options.i18n.whitespace }}
</gl-form-checkbox>
<gl-form-checkbox
data-testid="file-by-file"
class="gl-ml-3 gl-mb-0"
:checked="viewDiffsFileByFile"
@input="toggleFileByFile"
>
{{ $options.i18n.fileByFile }}
</gl-form-checkbox>
2020-11-24 15:15:51 +05:30
</gl-dropdown>
2019-03-02 22:35:43 +05:30
</template>