-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ : migrate module-description page
- Loading branch information
1 parent
6cc3fa3
commit 3df8a15
Showing
17 changed files
with
265 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 97 additions & 5 deletions
102
src/main/client/app/pages/modules/module-description.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,105 @@ | ||
<template> | ||
<div>This is not the final module description {{ $route.params.moduleId }} page xD</div> | ||
<div | ||
v-if="module" | ||
class="block module_description" | ||
> | ||
<section class="block_head row"> | ||
<div class="col-md-8"> | ||
<div class="row"> | ||
<div class="col-md-2"> | ||
<img | ||
:src="imageUrl" | ||
:alt="module.mainProvider" | ||
> | ||
</div> | ||
<div class="col-md-10"> | ||
<h1> | ||
<span>{{ module.name }}</span> | ||
<app-cli-badge | ||
:cli="module.terraformImage" | ||
badge-style="for-the-badge" | ||
/> | ||
</h1> | ||
<div class="provider"> | ||
{{ module.id }} | ||
</div> | ||
<div class="desc"> | ||
{{ module.description }} | ||
</div> | ||
<hr> | ||
<div class="metadata"> | ||
<p> | ||
Published <strong>{{ module.moduleMetadata.createdAt | dateTimeLong }}</strong> | ||
by <a href="#">{{ module.moduleMetadata.createdBy.username }}</a> | ||
</p> | ||
<p v-if="module.moduleMetadata.updatedAt"> | ||
Last modified <b>{{ module.moduleMetadata.updatedAt | dateTimeLong }}</b> | ||
by <a href="#">{{ module.moduleMetadata.updatedBy.username }}</a> | ||
</p> | ||
<p>Source: <a :href="module.gitRepositoryUrl">{{ module.gitRepositoryUrl }}</a></p> | ||
<p v-if="module.estimatedMonthlyCost"> | ||
Estimated monthly cost: ${{ module.estimatedMonthlyCost }} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<section> | ||
<b-tabs> | ||
<b-tab active> | ||
<template slot="title"> | ||
<i class="fab fa-markdown" /> Readme | ||
</template> | ||
<app-readme :module-id="module.id" /> | ||
</b-tab> | ||
<b-tab v-if="module.estimatedMonthlyCostDescription"> | ||
<template slot="title"> | ||
<i class="fab fa-markdown" /> Cost Of Ownership | ||
</template> | ||
<b-container fluid> | ||
<app-markdown :content="module.estimatedMonthlyCostDescription" /> | ||
</b-container> | ||
</b-tab> | ||
</b-tabs> | ||
</section> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import axios from 'axios'; | ||
import { AppCliBadge, AppMarkdown } from '@/shared/components'; | ||
import AppReadme from './readme.vue'; | ||
export default { | ||
name: 'AppModuleDescription', | ||
}; | ||
</script> | ||
<style scoped> | ||
components: { | ||
AppCliBadge, | ||
AppReadme, | ||
AppMarkdown, | ||
}, | ||
</style> | ||
data: function data() { | ||
return { | ||
module: null, | ||
moduleId: this.$route.params.moduleId, | ||
}; | ||
}, | ||
computed: { | ||
imageUrl() { | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
return require(`@/assets/images/providers/${this.module.mainProvider}.png`); | ||
}, | ||
}, | ||
async created() { | ||
const url = `/api/modules/${this.moduleId}`; | ||
const response = await axios.get(url); | ||
this.module = response.data; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<template id="readme"> | ||
<b-container fluid> | ||
<b-spinner | ||
v-if="!loaded" | ||
label="Loading..." | ||
class="m-5" | ||
style="height: 2.5rem; width: 2.5rem" | ||
/> | ||
<div | ||
v-if="loaded" | ||
class="markdown-body" | ||
> | ||
<!-- eslint-disable-next-line vue/no-v-html --> | ||
<div v-html="content" /> | ||
</div> | ||
</b-container> | ||
</template> | ||
|
||
<script> | ||
import axios from 'axios'; | ||
import marked from 'marked'; | ||
export default { | ||
name: 'AppReadme', | ||
props: { | ||
moduleId: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
data: () => ({ | ||
content: '', | ||
loaded: false, | ||
}), | ||
async created() { | ||
const result = await axios.get(`/api/modules/${this.moduleId}/readme`); | ||
this.content = marked(result.data); | ||
this.loaded = true; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<template> | ||
<div class="markdown-body"> | ||
<!-- eslint-disable-next-line vue/no-v-html --> | ||
<div v-html="convertedContent" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import marked from 'marked'; | ||
export default { | ||
name: 'Markdown', | ||
props: { | ||
content: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
computed: { | ||
convertedContent() { | ||
if (typeof this.content === 'undefined') { | ||
return ''; | ||
} | ||
return marked(this.content); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Vue from 'vue'; | ||
|
||
function formatDate(value, options) { | ||
if (!value) return ''; | ||
return new Intl.DateTimeFormat(undefined, options).format(Date.parse(value)); | ||
} | ||
|
||
export default function initFilters() { | ||
|
||
// display date like "05/04/2020, 4:20:20 AM" | ||
Vue.filter('dateTime', (value) => formatDate(value, { | ||
day: '2-digit', | ||
month: '2-digit', | ||
year: 'numeric', | ||
hour: 'numeric', | ||
minute: '2-digit', | ||
second: '2-digit', | ||
})); | ||
|
||
// display date like "May 04, 2020, 4:20:20 AM" | ||
Vue.filter('dateTimeLong', (value) => formatDate(value, { | ||
day: '2-digit', | ||
month: 'long', | ||
year: 'numeric', | ||
hour: 'numeric', | ||
minute: '2-digit', | ||
second: '2-digit', | ||
})); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.