-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.js
1 lines (1 loc) · 14.8 KB
/
index.js
1
(function(){"use strict";var W={};function x(){return W}function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function m(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function l(e){m(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||M(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function y(e,t){m(2,arguments);var n=l(e),a=l(t),r=n.getTime()-a.getTime();return r<0?-1:r>0?1:r}function O(e,t){m(2,arguments);var n=l(e),a=l(t),r=n.getFullYear()-a.getFullYear(),s=n.getMonth()-a.getMonth();return r*12+s}function F(e){m(1,arguments);var t=l(e);return t.setHours(23,59,59,999),t}function N(e){m(1,arguments);var t=l(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function R(e){m(1,arguments);var t=l(e);return F(t).getTime()===N(t).getTime()}function $(e,t){m(2,arguments);var n=l(e),a=l(t),r=y(n,a),s=Math.abs(O(n,a)),i;if(s<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*s);var c=y(n,a)===-r;R(l(e))&&s===1&&y(e,a)===1&&(c=!1),i=r*(s-Number(c))}return i===0?0:i}function A(e,t){return m(2,arguments),l(e).getTime()-l(t).getTime()}var k={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},I="trunc";function X(e){return e?k[e]:k[I]}function E(e,t,n){m(2,arguments);var a=A(e,t)/1e3;return X(n==null?void 0:n.roundingMethod)(a)}var Y={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},j=function(t,n,a){var r,s=Y[t];return typeof s=="string"?r=s:n===1?r=s.one:r=s.other.replace("{{count}}",n.toString()),a!=null&&a.addSuffix?a.comparison&&a.comparison>0?"in "+r:r+" ago":r};const z=j;function w(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth,a=e.formats[n]||e.formats[e.defaultWidth];return a}}var V={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},L={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},B={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},q={date:w({formats:V,defaultWidth:"full"}),time:w({formats:L,defaultWidth:"full"}),dateTime:w({formats:B,defaultWidth:"full"})};const U=q;var H={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},J=function(t,n,a,r){return H[t]};const Q=J;function b(e){return function(t,n){var a=n!=null&&n.context?String(n.context):"standalone",r;if(a==="formatting"&&e.formattingValues){var s=e.defaultFormattingWidth||e.defaultWidth,i=n!=null&&n.width?String(n.width):s;r=e.formattingValues[i]||e.formattingValues[s]}else{var c=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;r=e.values[o]||e.values[c]}var u=e.argumentCallback?e.argumentCallback(t):t;return r[u]}}var G={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},K={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Z={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},tt={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},et={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},nt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},at=function(t,n){var a=Number(t),r=a%100;if(r>20||r<10)switch(r%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},rt={ordinalNumber:at,era:b({values:G,defaultWidth:"wide"}),quarter:b({values:K,defaultWidth:"wide",argumentCallback:function(t){return t-1}}),month:b({values:Z,defaultWidth:"wide"}),day:b({values:tt,defaultWidth:"wide"}),dayPeriod:b({values:et,defaultWidth:"wide",formattingValues:nt,defaultFormattingWidth:"wide"})};const it=rt;function p(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.width,r=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],s=t.match(r);if(!s)return null;var i=s[0],c=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],o=Array.isArray(c)?st(c,function(h){return h.test(i)}):ot(c,function(h){return h.test(i)}),u;u=e.valueCallback?e.valueCallback(o):o,u=n.valueCallback?n.valueCallback(u):u;var v=t.slice(i.length);return{value:u,rest:v}}}function ot(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(e[n]))return n}function st(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n}function ut(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=t.match(e.matchPattern);if(!a)return null;var r=a[0],s=t.match(e.parsePattern);if(!s)return null;var i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;var c=t.slice(r.length);return{value:i,rest:c}}}var lt=/^(\d+)(th|st|nd|rd)?/i,ct=/\d+/i,dt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ht={any:[/^b/i,/^(a|c)/i]},ft={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},mt={any:[/1/i,/2/i,/3/i,/4/i]},vt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},gt={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},bt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},pt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},yt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Mt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},wt={ordinalNumber:ut({matchPattern:lt,parsePattern:ct,valueCallback:function(t){return parseInt(t,10)}}),era:p({matchPatterns:dt,defaultMatchWidth:"wide",parsePatterns:ht,defaultParseWidth:"any"}),quarter:p({matchPatterns:ft,defaultMatchWidth:"wide",parsePatterns:mt,defaultParseWidth:"any",valueCallback:function(t){return t+1}}),month:p({matchPatterns:vt,defaultMatchWidth:"wide",parsePatterns:gt,defaultParseWidth:"any"}),day:p({matchPatterns:bt,defaultMatchWidth:"wide",parsePatterns:pt,defaultParseWidth:"any"}),dayPeriod:p({matchPatterns:yt,defaultMatchWidth:"any",parsePatterns:Mt,defaultParseWidth:"any"})},_t={code:"en-US",formatDistance:z,formatLong:U,formatRelative:Q,localize:it,match:wt,options:{weekStartsOn:0,firstWeekContainsDate:1}};const Dt=_t;function S(e,t){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function kt(e){return S({},e)}function P(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}var T=1440,St=2520,_=43200,Pt=86400;function Tt(e,t,n){var a,r;m(2,arguments);var s=x(),i=(a=(r=n==null?void 0:n.locale)!==null&&r!==void 0?r:s.locale)!==null&&a!==void 0?a:Dt;if(!i.formatDistance)throw new RangeError("locale must contain formatDistance property");var c=y(e,t);if(isNaN(c))throw new RangeError("Invalid time value");var o=S(kt(n),{addSuffix:!!(n!=null&&n.addSuffix),comparison:c}),u,v;c>0?(u=l(t),v=l(e)):(u=l(e),v=l(t));var h=E(v,u),f=(P(v)-P(u))/1e3,d=Math.round((h-f)/60),g;if(d<2)return n!=null&&n.includeSeconds?h<5?i.formatDistance("lessThanXSeconds",5,o):h<10?i.formatDistance("lessThanXSeconds",10,o):h<20?i.formatDistance("lessThanXSeconds",20,o):h<40?i.formatDistance("halfAMinute",0,o):h<60?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",1,o):d===0?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",d,o);if(d<45)return i.formatDistance("xMinutes",d,o);if(d<90)return i.formatDistance("aboutXHours",1,o);if(d<T){var Rt=Math.round(d/60);return i.formatDistance("aboutXHours",Rt,o)}else{if(d<St)return i.formatDistance("xDays",1,o);if(d<_){var $t=Math.round(d/T);return i.formatDistance("xDays",$t,o)}else if(d<Pt)return g=Math.round(d/_),i.formatDistance("aboutXMonths",g,o)}if(g=$(v,u),g<12){var At=Math.round(d/_);return i.formatDistance("xMonths",At,o)}else{var C=g%12,D=Math.floor(g/12);return C<3?i.formatDistance("aboutXYears",D,o):C<9?i.formatDistance("overXYears",D,o):i.formatDistance("almostXYears",D+1,o)}}function Ct(e,t,n,a,r,s,i,c){var o=typeof e=="function"?e.options:e;t&&(o.render=t,o.staticRenderFns=n,o._compiled=!0),a&&(o.functional=!0),s&&(o._scopeId="data-v-"+s);var u;if(i?(u=function(f){f=f||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!f&&typeof __VUE_SSR_CONTEXT__<"u"&&(f=__VUE_SSR_CONTEXT__),r&&r.call(this,f),f&&f._registeredComponents&&f._registeredComponents.add(i)},o._ssrRegister=u):r&&(u=c?function(){r.call(this,(o.functional?this.parent:this).$root.$options.shadowRoot)}:r),u)if(o.functional){o._injectStyles=u;var v=o.render;o.render=function(d,g){return u.call(g),v(d,g)}}else{var h=o.beforeCreate;o.beforeCreate=h?[].concat(h,u):[u]}return{exports:e,options:o}}const Wt={name:"GitContent",props:{status:{type:Object},log:{type:Array,default:[]},branch:{type:String,default:""},disableBranchManagement:{type:Boolean,default:!1},helpText:{}},computed:{commitItems(){const e=[];return this.log.forEach(t=>{e.push({text:t.message,info:this.formatRelative(t.date)+" / "+t.hash.substr(0,7),link:!1})}),e},statusItems(){const e=[];return this.status.files.forEach(t=>{e.push({text:t.filename,info:t.code,link:!1})}),e},remoteStatus(){if(!this.status.hasRemote)return{text:"No remote branch found.",theme:"negative"};if(this.status.diffFromOrigin===0)return{text:"Your branch is up to date with origin/"+this.branch,theme:"positive"};const e=Math.abs(this.status.diffFromOrigin);return{text:`Your branch is ${this.status.diffFromOrigin>0?"ahead":"behind"} of origin/${this.branch} by ${e} commit${e!==1?"s":""}.`,theme:"notice"}}},methods:{pull:async function(){await panel.app.$api.post("/git-content/pull"),this.$reload()},push:async function(){await panel.app.$api.post("/git-content/push"),this.$reload()},revert:async function(){this.$dialog("git-content/revert")},commit:async function(){this.$dialog("git-content/commit")},switchBranch:async function(){this.$dialog("git-content/branch")},createBranch:async function(){this.$dialog("git-content/create-branch")},formatRelative(e){return Tt(new Date(e),new Date,{addSuffix:!0})}}};var xt=function(){var t=this,n=t._self._c;return n("k-inside",[n("k-view",{staticClass:"k-git-content-view"},[n("k-header",[t._v("Git Content "+t._s(t.size))]),t.helpText?n("section",{staticClass:"k-section"},[n("k-box",{attrs:{text:t.helpText,html:"true",theme:"info"}})],1):t._e(),t.status.files.length?n("section",{staticClass:"k-section"},[n("header",{staticClass:"k-section-header"},[n("k-headline",[t._v("Uncommitted changes")]),n("k-button-group",{attrs:{buttons:[{text:"Revert Changes",icon:"undo",click:t.revert},{text:"Commit Changes",icon:"check",click:t.commit}]}})],1),n("k-collection",{attrs:{items:t.statusItems,help:"Refer to the <a target='_blank' href='https://git-scm.com/docs/git-status#_short_format'>Git documentation</a> on how to interpret the status codes to the right."}})],1):t._e(),n("section",{staticClass:"k-section"},[n("header",{staticClass:"k-section-header"},[n("k-headline",[t._v("Remote synchronization")]),n("k-button-group",{attrs:{buttons:[{text:"Pull",icon:"download",click:t.pull},{text:"Push",icon:"upload",click:t.push}]}})],1),n("k-box",{attrs:{text:t.remoteStatus.text,theme:t.remoteStatus.theme}})],1),n("section",{staticClass:"k-section"},[n("header",{staticClass:"k-section-header"},[n("k-headline",[t._v("Latest "+t._s(t.log.length)+" changes on branch »"+t._s(t.branch)+"«")]),t.disableBranchManagement?t._e():n("k-button-group",{attrs:{buttons:[{text:"Create Branch",icon:"add",click:t.createBranch},{text:"Switch Branch",icon:"refresh",click:t.switchBranch}]}})],1),n("k-collection",{attrs:{items:t.commitItems}})],1)],1)],1)},Ot=[],Ft=Ct(Wt,xt,Ot,!1,null,null,null,null);const Nt=Ft.exports;panel.plugin("thathoff/git-content",{components:{"git-content":Nt}})})();