Skip to content

Commit af3904f

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 1b9f574 commit af3904f

File tree

77 files changed

+841
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+841
-199
lines changed

.gitlab-ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ workflow:
6363

6464
variables:
6565
PG_VERSION: "12"
66-
DEFAULT_CI_IMAGE: "${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}.patched-golang-1.17-node-16.14-postgresql-${PG_VERSION}:rubygems-3.2-git-2.36-lfs-2.9-chrome-${CHROME_VERSION}-yarn-1.22-graphicsmagick-1.3.36"
66+
DEFAULT_CI_IMAGE: "${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}.patched-golang-${GO_VERSION}-node-16.14-postgresql-${PG_VERSION}:rubygems-3.2-git-2.36-lfs-2.9-chrome-${CHROME_VERSION}-yarn-1.22-graphicsmagick-1.3.36"
6767
RAILS_ENV: "test"
6868
NODE_ENV: "test"
6969
BUNDLE_WITHOUT: "production:development"
@@ -80,6 +80,7 @@ variables:
8080
CHROME_VERSION: "103"
8181
DOCKER_VERSION: "20.10.14"
8282
RUBY_VERSION: "2.7"
83+
GO_VERSION: "1.18"
8384

8485
TMP_TEST_FOLDER: "${CI_PROJECT_DIR}/tmp/tests"
8586
GITLAB_WORKHORSE_FOLDER: "gitlab-workhorse"

.gitlab/ci/workhorse.gitlab-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
workhorse:verify:
22
extends: .workhorse:rules:workhorse
3-
image: ${GITLAB_DEPENDENCY_PROXY}golang:1.17
3+
image: ${GITLAB_DEPENDENCY_PROXY}golang:1.18
44
stage: test
55
needs: []
66
script:
@@ -12,7 +12,7 @@ workhorse:verify:
1212
image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}-golang-${GO_VERSION}:git-2.36
1313
variables:
1414
GITALY_ADDRESS: "tcp://127.0.0.1:8075"
15-
GO_VERSION: "1.17"
15+
GO_VERSION: "1.18"
1616
stage: test
1717
needs:
1818
- setup-test-env
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script>
2+
import MessagesTable from './messages_table.vue';
3+
4+
export default {
5+
name: 'BroadcastMessagesBase',
6+
components: {
7+
MessagesTable,
8+
},
9+
props: {
10+
messages: {
11+
type: Array,
12+
required: true,
13+
},
14+
},
15+
};
16+
</script>
17+
<template>
18+
<div>
19+
<messages-table v-if="messages.length > 0" :messages="messages" />
20+
</div>
21+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script>
2+
import MessagesTableRow from './messages_table_row.vue';
3+
4+
export default {
5+
name: 'MessagesTable',
6+
components: {
7+
MessagesTableRow,
8+
},
9+
props: {
10+
messages: {
11+
type: Array,
12+
required: true,
13+
},
14+
},
15+
};
16+
</script>
17+
<template>
18+
<div>
19+
<messages-table-row v-for="message in messages" :key="message.id" :message="message" />
20+
</div>
21+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script>
2+
export default {
3+
name: 'MessagesTableRow',
4+
props: {
5+
message: {
6+
type: Object,
7+
required: true,
8+
},
9+
},
10+
};
11+
</script>
12+
<template>
13+
<div>
14+
{{ message.id }}
15+
</div>
16+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Vue from 'vue';
2+
import BroadcastMessagesBase from './components/base.vue';
3+
4+
export default () => {
5+
const el = document.querySelector('#js-broadcast-messages');
6+
const { messages } = el.dataset;
7+
8+
return new Vue({
9+
el,
10+
name: 'BroadcastMessagesBase',
11+
render(createElement) {
12+
return createElement(BroadcastMessagesBase, {
13+
props: {
14+
messages: JSON.parse(messages),
15+
},
16+
});
17+
},
18+
});
19+
};
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import initBroadcastMessages from '~/admin/broadcast_messages';
12
import initDeprecatedRemoveRowBehavior from '~/behaviors/deprecated_remove_row_behavior';
23
import initBroadcastMessagesForm from './broadcast_message';
34

4-
initBroadcastMessagesForm();
5-
initDeprecatedRemoveRowBehavior();
5+
if (gon.features.vueBroadcastMessages) {
6+
initBroadcastMessages();
7+
} else {
8+
initBroadcastMessagesForm();
9+
initDeprecatedRemoveRowBehavior();
10+
}

app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue

+65-22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
GlFormInput,
1010
GlFormSelect,
1111
} from '@gitlab/ui';
12+
import { getDraft, clearDraft, updateDraft } from '~/lib/utils/autosave';
1213
import csrf from '~/lib/utils/csrf';
1314
import { setUrlFragment } from '~/lib/utils/url_utility';
1415
import { s__, sprintf } from '~/locale';
@@ -33,6 +34,29 @@ const MARKDOWN_LINK_TEXT = {
3334
org: '[[page-slug]]',
3435
};
3536
37+
function getPagePath(pageInfo) {
38+
return pageInfo.persisted ? pageInfo.path : pageInfo.createPath;
39+
}
40+
41+
const autosaveKey = (pageInfo, field) => {
42+
const path = pageInfo.persisted ? pageInfo.path : pageInfo.createPath;
43+
44+
return `${path}/${field}`;
45+
};
46+
47+
const titleAutosaveKey = (pageInfo) => autosaveKey(pageInfo, 'title');
48+
const formatAutosaveKey = (pageInfo) => autosaveKey(pageInfo, 'format');
49+
const contentAutosaveKey = (pageInfo) => autosaveKey(pageInfo, 'content');
50+
const commitAutosaveKey = (pageInfo) => autosaveKey(pageInfo, 'commit');
51+
52+
const getTitle = (pageInfo) => getDraft(titleAutosaveKey(pageInfo)) || pageInfo.title?.trim() || '';
53+
const getFormat = (pageInfo) =>
54+
getDraft(formatAutosaveKey(pageInfo)) || pageInfo.format || 'markdown';
55+
const getContent = (pageInfo) => getDraft(contentAutosaveKey(pageInfo)) || pageInfo.content || '';
56+
const getCommitMessage = (pageInfo) =>
57+
getDraft(commitAutosaveKey(pageInfo)) || pageInfo.commitMessage || '';
58+
const getIsFormDirty = (pageInfo) => Boolean(getDraft(titleAutosaveKey(pageInfo)));
59+
3660
export default {
3761
i18n: {
3862
title: {
@@ -87,13 +111,14 @@ export default {
87111
data() {
88112
return {
89113
editingMode: 'source',
90-
title: this.pageInfo.title?.trim() || '',
91-
format: this.pageInfo.format || 'markdown',
92-
content: this.pageInfo.content || '',
93-
commitMessage: '',
94-
isDirty: false,
114+
title: getTitle(this.pageInfo),
115+
format: getFormat(this.pageInfo),
116+
content: getContent(this.pageInfo),
117+
commitMessage: getCommitMessage(this.pageInfo),
95118
contentEditorEmpty: false,
96119
isContentEditorActive: false,
120+
switchEditingControlDisabled: false,
121+
isFormDirty: getIsFormDirty(this.pageInfo),
97122
};
98123
},
99124
computed: {
@@ -104,7 +129,7 @@ export default {
104129
return csrf.token;
105130
},
106131
formAction() {
107-
return this.pageInfo.persisted ? this.pageInfo.path : this.pageInfo.createPath;
132+
return getPagePath(this.pageInfo);
108133
},
109134
helpPath() {
110135
return setUrlFragment(
@@ -151,7 +176,7 @@ export default {
151176
},
152177
},
153178
mounted() {
154-
this.updateCommitMessage();
179+
if (!this.commitMessage) this.updateCommitMessage();
155180
156181
window.addEventListener('beforeunload', this.onPageUnload);
157182
},
@@ -160,6 +185,8 @@ export default {
160185
},
161186
methods: {
162187
async handleFormSubmit(e) {
188+
this.isFormDirty = false;
189+
163190
e.preventDefault();
164191
165192
this.trackFormSubmit();
@@ -169,18 +196,33 @@ export default {
169196
await this.$nextTick();
170197
171198
e.target.submit();
199+
},
172200
173-
this.isDirty = false;
201+
updateDrafts() {
202+
updateDraft(titleAutosaveKey(this.pageInfo), this.title);
203+
updateDraft(formatAutosaveKey(this.pageInfo), this.format);
204+
updateDraft(contentAutosaveKey(this.pageInfo), this.content);
205+
updateDraft(commitAutosaveKey(this.pageInfo), this.commitMessage);
174206
},
175207
176-
onPageUnload(event) {
177-
if (!this.isDirty) return undefined;
208+
clearDrafts() {
209+
clearDraft(titleAutosaveKey(this.pageInfo));
210+
clearDraft(formatAutosaveKey(this.pageInfo));
211+
clearDraft(contentAutosaveKey(this.pageInfo));
212+
clearDraft(commitAutosaveKey(this.pageInfo));
213+
},
178214
179-
event.preventDefault();
215+
handleContentEditorChange({ empty, markdown }) {
216+
this.contentEditorEmpty = empty;
217+
this.content = markdown;
218+
},
180219
181-
// eslint-disable-next-line no-param-reassign
182-
event.returnValue = '';
183-
return '';
220+
onPageUnload() {
221+
if (this.isFormDirty) {
222+
this.updateDrafts();
223+
} else {
224+
this.clearDrafts();
225+
}
184226
},
185227
186228
updateCommitMessage() {
@@ -222,10 +264,6 @@ export default {
222264
trackContentEditorLoaded() {
223265
this.track(CONTENT_EDITOR_LOADED_ACTION);
224266
},
225-
226-
checkDirty(markdown) {
227-
this.isDirty = this.pageInfo.content !== markdown;
228-
},
229267
},
230268
};
231269
</script>
@@ -236,6 +274,7 @@ export default {
236274
method="post"
237275
class="wiki-form common-note-form gl-mt-3 js-quick-submit"
238276
@submit="handleFormSubmit"
277+
@input="isFormDirty = true"
239278
>
240279
<input :value="csrfToken" type="hidden" name="authenticity_token" />
241280
<input v-if="pageInfo.persisted" type="hidden" name="_method" value="put" />
@@ -306,7 +345,6 @@ export default {
306345
form-field-name="wiki[content]"
307346
@contentEditor="notifyContentEditorActive"
308347
@markdownField="notifyContentEditorInactive"
309-
@input="checkDirty"
310348
/>
311349
<div class="form-text gl-text-gray-600">
312350
<gl-sprintf
@@ -358,9 +396,14 @@ export default {
358396
:disabled="disableSubmitButton"
359397
>{{ submitButtonText }}</gl-button
360398
>
361-
<gl-button data-testid="wiki-cancel-button" :href="cancelFormPath" class="float-right">{{
362-
$options.i18n.cancel
363-
}}</gl-button>
399+
<gl-button
400+
data-testid="wiki-cancel-button"
401+
:href="cancelFormPath"
402+
class="float-right"
403+
@click="isFormDirty = false"
404+
>
405+
{{ $options.i18n.cancel }}</gl-button
406+
>
364407
</div>
365408
</gl-form>
366409
</template>

0 commit comments

Comments
 (0)