Selaa lähdekoodia

Merge pull request #2205 from pixelfed/staging

Update PostComponent, hide edit button after 24 hours. Fixes #2188
daniel 5 vuotta sitten
vanhempi
commit
8baea0b475

+ 1 - 0
CHANGELOG.md

@@ -39,6 +39,7 @@
 - Updated Inbox, move expensive HTTP Signature validation to job queue ([f2ae45e5a](https://github.com/pixelfed/pixelfed/commit/f2ae45e5a))
 - Updated MomentUI, fix bugs and improve UI ([90b89cb8](https://github.com/pixelfed/pixelfed/commit/90b89cb8))
 - Updated PostComponent, improve embed model. Fixes ([#2189](https://github.com/pixelfed/pixelfed/issues/2189)) ([b12e504e](https://github.com/pixelfed/pixelfed/commit/b12e504e))
+- Updated PostComponent, hide edit button after 24 hours. Fixes [#2188](https://github.com/pixelfed/pixelfed/issues/2188)) ([a1fee6a2](https://github.com/pixelfed/pixelfed/commit/a1fee6a2))
 
 
 ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)

BIN
public/js/profile.js


BIN
public/js/status.js


BIN
public/js/timeline.js


BIN
public/mix-manifest.json


+ 11 - 3
resources/assets/js/components/PostComponent.vue

@@ -42,7 +42,7 @@
                   </div>
                   <div v-if="ownerOrAdmin()">
                     <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
-                    <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
+                    <a v-if="canEdit" class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
                     <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
                   </div>
                 </div>
@@ -108,7 +108,7 @@
                           </span>
                           <span v-if="ownerOrAdmin()">
                             <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
-                            <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
+                            <a v-if="canEdit" class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
                             <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost">Delete</a>
                           </span>
                         </div>
@@ -675,7 +675,8 @@ export default {
             ctxEmbedShowCaption: true,
             ctxEmbedShowLikes: false,
             ctxEmbedCompactMode: false,
-            layout: this.profileLayout
+            layout: this.profileLayout,
+            canEdit: false
           }
     },
     watch: {
@@ -773,6 +774,13 @@ export default {
                   self.showComments = true;
                   this.fetchComments();
                 }
+                if(this.ownerOrAdmin()) {
+                  let od = new Date(this.status.created_at).getTime() + (1 * 24 * 60 * 60 * 1000);
+                  let now = new Date().getTime();
+                  if(od > now) {
+                    this.canEdit = true;
+                  }
+                }
                 this.loaded = true;
             }).catch(error => {
               swal('Oops!', 'An error occured, please try refreshing the page.', 'error');

+ 3 - 2
resources/assets/js/components/Profile.vue

@@ -518,7 +518,7 @@
 	size="md"
 	body-class="p-2 rounded">
 	<div>
-		<textarea class="form-control disabled" rows="1" style="border: 1px solid #efefef; font-size: 14px; line-height: 12px; height: 37px; margin: 0 0 7px; resize: none; white-space: nowrap;" v-model="ctxEmbedPayload"></textarea>
+		<textarea class="form-control disabled text-monospace" rows="6" style="overflow-y:hidden;border: 1px solid #efefef; font-size: 12px; line-height: 18px; margin: 0 0 7px;resize:none;" v-model="ctxEmbedPayload" disabled=""></textarea>
 		<hr>
 		<button :class="copiedEmbed ? 'btn btn-primary btn-block btn-sm py-1 font-weight-bold disabed': 'btn btn-primary btn-block btn-sm py-1 font-weight-bold'" @click="ctxCopyEmbed" :disabled="copiedEmbed">{{copiedEmbed ? 'Embed Code Copied!' : 'Copy Embed Code'}}</button>
 		<p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
@@ -1215,7 +1215,8 @@
 			},
 
 			showEmbedProfileModal() {
-				this.ctxEmbedPayload = window.App.util.embed.profile(this.profile.url)
+				this.ctxEmbedPayload = window.App.util.embed.profile(this.profile.url);
+				this.$refs.visitorContextMenu.hide();
 				this.$refs.embedModal.show();
 			},
 

+ 53 - 2
resources/assets/js/components/Timeline.vue

@@ -430,7 +430,29 @@
 	size="md"
 	body-class="p-2 rounded">
 	<div>
-		<textarea class="form-control disabled" rows="1" style="border: 1px solid #efefef; font-size: 14px; line-height: 12px; height: 37px; margin: 0 0 7px; resize: none; white-space: nowrap;" v-model="ctxEmbedPayload"></textarea>
+		<div class="form-group">
+			<textarea class="form-control disabled text-monospace" rows="8" style="overflow-y:hidden;border: 1px solid #efefef; font-size: 12px; line-height: 18px; margin: 0 0 7px;resize:none;" v-model="ctxEmbedPayload" disabled=""></textarea>
+		</div>
+		<div class="form-group pl-2 d-flex justify-content-center">
+			<div class="form-check mr-3">
+				<input class="form-check-input" type="checkbox" v-model="ctxEmbedShowCaption" :disabled="ctxEmbedCompactMode == true">
+				<label class="form-check-label font-weight-light">
+					Show Caption
+				</label>
+			</div>
+			<div class="form-check mr-3">
+				<input class="form-check-input" type="checkbox" v-model="ctxEmbedShowLikes" :disabled="ctxEmbedCompactMode == true">
+				<label class="form-check-label font-weight-light">
+					Show Likes
+				</label>
+			</div>
+			<div class="form-check">
+				<input class="form-check-input" type="checkbox" v-model="ctxEmbedCompactMode">
+				<label class="form-check-label font-weight-light">
+					Compact Mode
+				</label>
+			</div>
+		</div>
 		<hr>
 		<button :class="copiedEmbed ? 'btn btn-primary btn-block btn-sm py-1 font-weight-bold disabed': 'btn btn-primary btn-block btn-sm py-1 font-weight-bold'" @click="ctxCopyEmbed" :disabled="copiedEmbed">{{copiedEmbed ? 'Embed Code Copied!' : 'Copy Embed Code'}}</button>
 		<p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
@@ -603,9 +625,35 @@
 				showTips: true,
 				userStory: false,
 				replySending: false,
+				ctxEmbedShowCaption: true,
+				ctxEmbedShowLikes: false,
+				ctxEmbedCompactMode: false,
+			}
+		},
+		watch: {
+			ctxEmbedShowCaption: function (n,o) {
+				if(n == true) {
+					this.ctxEmbedCompactMode = false;
+				}
+				let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
+				this.ctxEmbedPayload = window.App.util.embed.post(this.ctxMenuStatus.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
+			},
+			ctxEmbedShowLikes: function (n,o) {
+				if(n == true) {
+					this.ctxEmbedCompactMode = false;
+				}
+				let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
+				this.ctxEmbedPayload = window.App.util.embed.post(this.ctxMenuStatus.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
+			},
+			ctxEmbedCompactMode: function (n,o) {
+				if(n == true) {
+					this.ctxEmbedShowCaption = false;
+					this.ctxEmbedShowLikes = false;
+				}
+				let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
+				this.ctxEmbedPayload = window.App.util.embed.post(this.ctxMenuStatus.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
 			}
 		},
-
 		beforeMount() {
 			this.fetchProfile();
 			this.fetchTimelineApi();
@@ -1349,6 +1397,9 @@
 
 			ctxCopyEmbed() {
 				navigator.clipboard.writeText(this.ctxEmbedPayload);
+				this.ctxEmbedShowCaption = true;
+				this.ctxEmbedShowLikes = false;
+				this.ctxEmbedCompactMode = false;
 				this.$refs.ctxEmbedModal.hide();
 			},