Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 20x 20x 20x 20x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 18x 1x 1x 1x 1x 1x 1x 1x 1x 128x 1x 1x 1x 1x 1x 1x 1x 1x 1x 110x 1x 1x 1x 1x 1x 1x 1x 1x 1x 20x 20x 20x 20x 1x 1x 1x 1x 1x 1x 1x 1x 1x 20x 20x 20x 1x 1x 1x 1x 1x 1x 1x 1x 20x 1x 1x 1x 1x 1x 1x 1x 1x 17x 1x 1x 1x 1x 1x 1x 1x 1x 17x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 40x 40x 40x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 11x 11x 11x 11x 11x 11x 9x 11x 2x 2x 2x 2x 2x 2x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | <!-- WikiLambda Vue component for the Publish Dialog. @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt @license MIT --> <template> <div class="ext-wikilambda-app-publish-dialog" data-testid="confirm-publish-dialog" > <cdx-dialog data-testid="publish-dialog" :open="showDialog" :title="publishDialogTitle" :close-button-label="$i18n( 'wikilambda-dialog-close' ).text()" :primary-action="primaryAction" :default-action="defaultAction" @default="closeDialog" @primary="publishZObject" @update:open="closeDialog" > <!-- Error and Warning section --> <div v-if="hasErrors" class="ext-wikilambda-app-publish-dialog__errors" > <cdx-message v-for="( error, index ) in errors" :key="'dialog-error-' + index" class="ext-wikilambda-app-publish-dialog__error" :type="error.type" > <!-- eslint-disable vue/no-v-html --> <div v-html="getErrorMessage( error )"></div> </cdx-message> </div> <!-- Summary section --> <cdx-field :status="status"> <cdx-text-input v-model="summary" class="ext-wikilambda-app-publish-dialog__summary-input" :aria-label="summaryLabel" :placeholder="summaryPlaceholder" @keydown="handleSummaryKeydown" ></cdx-text-input> <template #label> {{ $i18n( 'wikilambda-editor-publish-dialog-summary-help-text' ).text() }} </template> <cdx-message v-if="hasKeyboardSubmitWarning" class="ext-wikilambda-app-publish-dialog__keyboard-submit-warning" type="warning" :inline="true" > <div v-html="keyboardSubmitMessage"></div> </cdx-message> </cdx-field> <!-- Legal text --> <template #footer-text> <div class="ext-wikilambda-app-publish-dialog__legal-text" v-html="legalText" ></div> </template> </cdx-dialog> </div> </template> <script> const { CdxField, CdxTextInput, CdxMessage, CdxDialog } = require( '@wikimedia/codex' ); const { defineComponent } = require( 'vue' ); const Constants = require( '../../../Constants.js' ), eventLogUtils = require( '../../../mixins/eventLogUtils.js' ), errorUtils = require( '../../../mixins/errorUtils.js' ), { mapGetters, mapActions } = require( 'vuex' ); const enterKeyChar = ` <kbd class="ext-wikilambda-app-publish-dialog__kbd"> <span class="ext-wikilambda-app-publish-dialog__kbd-enter">↵</span> </kbd> `; const cmdKeyChar = ` <kbd class="ext-wikilambda-app-publish-dialog__kbd"> <span class="ext-wikilambda-app-publish-dialog__kbd-cmd">⌘</span> </kbd> `; const ctrlKeyChar = ` <kbd class="ext-wikilambda-app-publish-dialog__kbd"> <span class="ext-wikilambda-app-publish-dialog__kbd-ctrl">Ctrl</span> </kbd> `; module.exports = exports = defineComponent( { name: 'wl-publish-dialog', components: { 'cdx-field': CdxField, 'cdx-text-input': CdxTextInput, 'cdx-message': CdxMessage, 'cdx-dialog': CdxDialog }, mixins: [ eventLogUtils, errorUtils ], inject: { viewmode: { default: false } }, props: { showDialog: { type: Boolean, required: true, default: false }, functionSignatureChanged: { type: Boolean, required: false, default: false } }, data: function () { return { summary: '', hasKeyboardSubmitWarning: false }; }, computed: Object.assign( mapGetters( [ 'getUserLangCode', 'getCurrentZObjectId', 'getCurrentZObjectType', 'getCurrentZImplementationType', 'getErrors', 'getUserLangZid' ] ), { /** * Returns the status of the summary text field. * * @return {string} */ status: function () { return this.hasKeyboardSubmitWarning ? 'warning' : 'default'; }, /** * Returns the array of errors and warnings of the page * * @return {Array} */ errors: function () { return this.getErrors( 0 ); }, /** * Returns whether there are any errors in the page * to show in the publish dialog * * @return { boolean } */ hasErrors: function () { return this.errors.length !== 0; }, /** * Returns an object of type PrimaryDialogAction that describes * the action of the primary (save or publish) dialog button. * * @return {Object} */ primaryAction: function () { return { actionType: 'progressive', label: this.$i18n( 'wikilambda-publishnew' ).text() }; }, /** * Returns an object of type DialogAction that describes * the action of the secondary (cancel) button. * * @return {Object} */ defaultAction: function () { return { label: this.$i18n( 'wikilambda-cancel' ).text() }; }, /** * Returns the title for the Publish dialog * * @return {string} */ publishDialogTitle: function () { return this.$i18n( 'wikilambda-editor-publish-dialog-header' ).text(); }, /** * Returns the label for the summary text field * * @return {string} */ summaryLabel: function () { return this.$i18n( 'wikilambda-editor-publish-dialog-summary-label' ).text(); }, /** * Returns the placeholder for the summary text field * * @return {string} */ summaryPlaceholder: function () { return this.$i18n( 'wikilambda-editor-publish-dialog-summary-placeholder' ).text(); }, /** * Returns the legal text to display in the Publish Dialog, depending * on the type of object that is being submitted: * * Special message for implementations (Apache 2.0 licence for code). * * General message for all other kinds of ZObjects (CC0). * * @return { string } */ legalText: function () { return ( this.getCurrentZObjectType === Constants.Z_IMPLEMENTATION ) ? this.$i18n( 'wikifunctions-editing-copyrightwarning-implementation' ).parse() : this.$i18n( 'wikifunctions-editing-copyrightwarning-function' ).parse(); }, /** * Returns a warning message which informs the user that they can submit using Ctrl/CMD + Enter; * * @return {string} */ keyboardSubmitMessage: function () { const isMac = /Mac|iPod|iPhone|iPad/.test( navigator.userAgent ); return this.$i18n( 'wikilambda-editor-publish-dialog-keyboard-submit-warning', isMac ? cmdKeyChar : ctrlKeyChar, enterKeyChar ); } } ), methods: Object.assign( mapActions( [ 'submitZObject', 'setError', 'setDirty', 'clearAllErrors' ] ), { /** * Handle pressing the Enter key on the summary field. * * @param {Event} event The keydown event. */ handleSummaryEnter: function ( event ) { event.preventDefault(); this.hasKeyboardSubmitWarning = true; }, /** * Handles the keydown event on the summary text field. * - If the user presses Ctrl/Cmd + Enter, publishes the ZObject. * - If the user presses Enter, shows a warning message. * * @param {Event} event The keydown event. */ handleSummaryKeydown: function ( event ) { const enterKey = event.key === 'Enter'; // If the user presses Ctrl/Cmd + Enter, publish the ZObject if ( ( event.metaKey || event.ctrlKey ) && enterKey ) { this.publishZObject(); return; } // If the user presses Enter, show a warning message if ( enterKey ) { this.handleSummaryEnter( event ); } }, /** * Clears the error notifications and emits a close-dialog * event for the Publish widget to close the dialog. */ closeDialog: function () { this.hasKeyboardSubmitWarning = false; if ( this.hasErrors ) { this.clearAllErrors(); } this.$emit( 'close-dialog' ); }, /** * Before exiting the page after successful publishing, handle * state and remove exit event listeners. * * @param {string | undefined} pageTitle */ successfulExit: function ( pageTitle ) { this.$emit( 'before-exit' ); this.setDirty( false ); this.closeDialog(); window.location.href = !pageTitle ? new mw.Title( Constants.PATHS.MAIN_PAGE ).getUrl() : `/view/${ this.getUserLangCode }/${ pageTitle }?success=true`; }, /** * Submits the ZObject to the wikilambda_edit API * and handles the return value: * 1. If the response contains an error, saves the error * in the store/errors module and displays the error messages * in the Publish Dialog notification block. * 2. If the response is successful, navigates to the ZObject * page. */ publishZObject: function () { const summary = this.summary; const disconnectFunctionObjects = this.functionSignatureChanged; this.submitZObject( { summary, disconnectFunctionObjects } ).then( ( response ) => { this.successfulExit( response.page ); } ).catch( ( /* ApiError */ error ) => { this.clearAllErrors(); this.setError( { rowId: 0, errorType: Constants.errorTypes.ERROR, errorMessage: error.messageOrFallback( Constants.errorCodes.UNKNOWN_SAVE_ERROR ) } ); } ).finally( () => { // After receiving the response, log an event using Metrics Platform's core interaction events const interactionData = { zobjecttype: this.getCurrentZObjectType || null, zobjectid: this.getCurrentZObjectId || null, zlang: this.getUserLangZid || null, implementationtype: this.getCurrentZImplementationType || null, haserrors: this.hasErrors }; this.submitInteraction( 'publish', interactionData ); } ); } } ) } ); </script> <style lang="less"> @import '../../../ext.wikilambda.app.variables.less'; .ext-wikilambda-app-publish-dialog { .ext-wikilambda-app-publish-dialog__errors { margin-bottom: @spacing-200; } .ext-wikilambda-app-publish-dialog__kbd { font-size: @font-size-x-small; font-weight: @font-weight-normal; line-height: @line-height-x-small; color: @color-base; background-color: @background-color-interactive-subtle; border: @border-width-base @border-style-base @border-color-subtle; border-radius: @border-radius-base; padding: (@spacing-12 / 2) @spacing-25; box-shadow: @box-shadow-drop-small; font-family: inherit; display: inline-block; } .ext-wikilambda-app-publish-dialog__kbd-enter { position: relative; top: (@spacing-12 / 2); } .ext-wikilambda-app-publish-dialog__keyboard-submit-warning { margin-top: @spacing-25; } .ext-wikilambda-app-publish-dialog__legal-text { color: @color-placeholder; } } </style> |