ContextTab.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="tab-content">
  3. <div class="layout-col">
  4. <DefinitionList
  5. v-for="(contextGroup, groupTitle) in customContextGroups"
  6. :key="groupTitle"
  7. :title="groupTitle"
  8. class="tab-content-section"
  9. >
  10. <DefinitionListRow v-for="(value, key) in contextGroup" :key="key" :label="key">{{
  11. value | upperFirst
  12. }}</DefinitionListRow>
  13. </DefinitionList>
  14. <section v-if="git" class="tab-content-section border-none">
  15. <DefinitionList title="Git">
  16. <DefinitionListRow v-if="repoUrl" label="Repository">
  17. <a class="underline" :href="repoUrl" target="_blank">{{ repoUrl }}</a>
  18. </DefinitionListRow>
  19. <DefinitionListRow v-if="git.message" label="Message">
  20. <a :href="commitUrl" target="_blank">
  21. “{{ git.message }}” –
  22. <code class="code underline">{{ git.hash }}</code>
  23. </a>
  24. </DefinitionListRow>
  25. <DefinitionListRow v-if="git.tag" label="Tag">{{ git.tag }}</DefinitionListRow>
  26. </DefinitionList>
  27. </section>
  28. <DefinitionList title="Environment information" class="tab-content-section">
  29. <DefinitionListRow v-for="(value, key) in env" :key="key" :label="lookupKey(key)">{{
  30. value
  31. }}</DefinitionListRow>
  32. </DefinitionList>
  33. <DefinitionList title="Generic context" class="tab-content-section">
  34. <DefinitionListRow v-for="(value, key) in context" :key="key" :label="key">{{
  35. value
  36. }}</DefinitionListRow>
  37. </DefinitionList>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import gitUrlParse from 'git-url-parse';
  43. import DefinitionList from '../Shared/DefinitionList';
  44. import DefinitionListRow from '../Shared/DefinitionListRow.js';
  45. import upperFirst from 'lodash/upperFirst';
  46. const predefinedKeys = {
  47. laravel_version: 'Laravel version',
  48. laravel_locale: 'Laravel locale',
  49. laravel_config_cached: 'Laravel config cached',
  50. php_version: 'PHP version',
  51. };
  52. const predefinedContextItemGroups = [
  53. 'request',
  54. 'request_data',
  55. 'headers',
  56. 'session',
  57. 'cookies',
  58. 'view',
  59. 'queries',
  60. 'route',
  61. 'user',
  62. 'env',
  63. 'git',
  64. 'context',
  65. 'logs',
  66. 'dumps',
  67. 'exception',
  68. 'livewire',
  69. ];
  70. export default {
  71. inject: ['report'],
  72. components: { DefinitionListRow, DefinitionList },
  73. filters: {
  74. upperFirst,
  75. },
  76. computed: {
  77. git() {
  78. return this.report.context.git;
  79. },
  80. env() {
  81. return this.report.context.env;
  82. },
  83. context() {
  84. return this.report.context.context;
  85. },
  86. repoInfo() {
  87. return gitUrlParse(this.git.remote);
  88. },
  89. repoUrl() {
  90. if (!this.git.remote) {
  91. return null;
  92. }
  93. const git = {
  94. ...this.repoInfo,
  95. git_suffix: false,
  96. };
  97. return gitUrlParse.stringify(git, 'https');
  98. },
  99. commitUrl() {
  100. return `${this.repoUrl}/commit/${this.git.hash.replace(/'/g, '')}`;
  101. },
  102. tagUrl() {
  103. return this.git.tag ? `${this.repoUrl}/releases/tag/${this.git.tag}` : this.repoUrl;
  104. },
  105. customContextGroups() {
  106. const customGroups = Object.keys(this.report.context).filter(
  107. key => !predefinedContextItemGroups.includes(key),
  108. );
  109. return Object.assign(
  110. {},
  111. ...customGroups.map(prop => {
  112. return {
  113. [prop]: this.report.context[prop],
  114. };
  115. }),
  116. );
  117. },
  118. },
  119. methods: {
  120. lookupKey(key) {
  121. return predefinedKeys[key] || key;
  122. },
  123. },
  124. };
  125. </script>