bfg-common 1.1.24 → 1.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -151,7 +151,7 @@ html.dark-theme {
151
151
 
152
152
  .router-link-exact-active {
153
153
  .text {
154
- background-color: transparent !important;
154
+ background-color: #29414e!important;
155
155
  }
156
156
  }
157
157
  }
@@ -0,0 +1,83 @@
1
+ <template>
2
+ <div>
3
+ <nuxt-link
4
+ class="unit"
5
+ :to="navigate"
6
+ :title="props.item.navigateTo"
7
+ @click="changeLastNavigation"
8
+ >
9
+ <span :class="['unit-icon', props.item.iconClassName]" />
10
+ <div class="unit-text" :title="props.item.text">
11
+ {{ props.item.text }}
12
+ </div>
13
+ </nuxt-link>
14
+ </div>
15
+ </template>
16
+ <script setup lang="ts">
17
+ import type { UI_I_BlockItem } from '~/components/common/shortcuts/models/interfaces'
18
+
19
+ const props = defineProps<{
20
+ item: UI_I_BlockItem
21
+ }>()
22
+
23
+ const navigate = computed<string>(() => '/' + props.item.navigateTo)
24
+
25
+ const changeLastNavigation = (): void => {
26
+ if (!props.item.nav) return
27
+
28
+ const lastSelectedInventory = 'lastSelectedInventoryTreeIdStorageKey'
29
+ useLocalStorage(lastSelectedInventory, props.item.nav)
30
+ }
31
+ </script>
32
+ <style lang="scss" scoped>
33
+ .unit {
34
+ display: flex;
35
+ flex-direction: column;
36
+ justify-content: center;
37
+ align-items: center;
38
+ width: 95px;
39
+ margin: 21px 10px;
40
+ text-decoration-line: none;
41
+ &-icon {
42
+ margin: 0px 10px 15px 10px;
43
+ min-width: 34px;
44
+ min-height: 34px;
45
+ display: inline-block;
46
+ color: var(--global-font-color3);
47
+
48
+ &.icon-lifecycle-manager,
49
+ &.icon-cloud-provider-services {
50
+ background-size: contain;
51
+ background-repeat: no-repeat;
52
+ }
53
+ &.icon-lifecycle-manager {
54
+ background-image: url('assets/img/icons/icon-life-m-light.svg');
55
+ html.dark-theme & {
56
+ background-image: url('assets/img/icons/icon-life-m-dark.svg');
57
+ color: var(--global-font-color3);
58
+ }
59
+ }
60
+ &.icon-cloud-provider-services {
61
+ background-image: url('assets/img/icons/icon-cps.png');
62
+ html.dark-theme & {
63
+ background-image: url('assets/img/icons/icon-cps-dark-mode.png');
64
+ }
65
+ }
66
+ &.icon-vm-customizationManager-32x,
67
+ &.icon-storage-profile-32x,
68
+ &.icon-Host_Policy-32x,
69
+ &.icon-certificate-32x {
70
+ width: 34px;
71
+ height: 34px;
72
+ }
73
+ }
74
+ &-text {
75
+ color: var(--global-font-color3);
76
+ font-size: 13px;
77
+ line-height: 13px;
78
+ font-weight: 400;
79
+ padding-bottom: 2px;
80
+ text-align: center;
81
+ }
82
+ }
83
+ </style>
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div class="category">
3
+ <span class="category-text" :title="props.title">
4
+ {{ props.title }}
5
+ </span>
6
+ <div class="category-block">
7
+ <common-shortcuts-block
8
+ v-for="(item, key) in props.blockItems"
9
+ :key="key"
10
+ :item="item"
11
+ />
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ import type { UI_I_BlockItem } from '~/components/common/shortcuts/models/interfaces'
18
+
19
+ const props = defineProps<{
20
+ title: string
21
+ blockItems: UI_I_BlockItem[]
22
+ }>()
23
+ </script>
24
+ <style lang="scss" scoped>
25
+ .category {
26
+ &-text {
27
+ color: var(--light-white-100);
28
+ font-size: 18px;
29
+ line-height: 21px;
30
+ font-weight: 400;
31
+ }
32
+ &-block {
33
+ display: flex;
34
+ flex-direction: row;
35
+ justify-content: flex-start;
36
+ border-top: 1px solid var(--global-border-color);
37
+ margin-top: -4px;
38
+ }
39
+ }
40
+ </style>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <div class="shortcut">
3
+ <h1>{{ localization.shortcuts }}</h1>
4
+ <template v-for="item in props.shortcutsItems">
5
+ <div class="shortcut-category">
6
+ <common-shortcuts-category
7
+ :title="item.title"
8
+ :block-items="item.blockItems"
9
+ />
10
+ </div>
11
+ </template>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import type { UI_I_Localization } from '~/models/interfaces'
17
+ import { UI_I_ShortcutsItems } from '~/components/common/shortcuts/models/interfaces'
18
+
19
+ const props = defineProps<{
20
+ shortcutsItems: UI_I_ShortcutsItems[]
21
+ }>()
22
+
23
+ const localization = computed<UI_I_Localization>(() => useLocal())
24
+ </script>
25
+
26
+ <style lang="scss" scoped>
27
+ .shortcut {
28
+ margin: 20px;
29
+ width: 100%;
30
+ height: 100%;
31
+ overflow-y: scroll;
32
+
33
+ h1 {
34
+ line-height: 26px;
35
+ font-size: 22px;
36
+ font-weight: 200;
37
+ letter-spacing: normal;
38
+ }
39
+
40
+ &-category {
41
+ margin: 30px 20px 0 0;
42
+ }
43
+ }
44
+ </style>
@@ -0,0 +1,11 @@
1
+ export interface UI_I_BlockItem {
2
+ text: string
3
+ iconClassName: string
4
+ navigateTo?: string
5
+ nav?: string
6
+ }
7
+
8
+ export interface UI_I_ShortcutsItems {
9
+ title: string
10
+ blockItems: UI_I_BlockItem[]
11
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.1.24",
4
+ "version": "1.1.26",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -1,80 +0,0 @@
1
- import { defineNuxtModule } from '@nuxt/kit'
2
- const fs = require('fs')
3
- const path = require('path')
4
- import {
5
- replaceFileContent,
6
- removeNonImageFiles,
7
- removeImagesFromContent,
8
- updateImagesPathAndCustomComponents,
9
- } from './utils/methods'
10
-
11
- // const npmDev = (): void => {
12
- // const contentPath = path.join(
13
- // __dirname.replace('/node_modules/bfg-common/modules/fixContentBuild', ''),
14
- // 'content',
15
- // 'help'
16
- // )
17
- // // Заменяем кастомные тэги
18
- // updateCustomComponents(contentPath)
19
- // }
20
-
21
- const npmGenerate = (): void => {
22
- // Правим путь к файлу
23
- const filePath = path.join(
24
- __dirname.replace('/bfg-common/modules/fixContentBuild', ''),
25
- '@nuxt',
26
- 'content',
27
- 'dist',
28
- 'runtime',
29
- 'legacy',
30
- 'composables',
31
- 'query.mjs'
32
- )
33
- const searchString = '/query/${hash(params)}'
34
- const replacementString = 'cache'
35
- replaceFileContent(filePath, searchString, replacementString)
36
- // End block
37
-
38
- // Переносим весь контент и удаляем все файлы кроме картинок
39
- const contentPath = path.join(
40
- __dirname.replace('/node_modules/bfg-common/modules/fixContentBuild', ''),
41
- 'content',
42
- 'help'
43
- )
44
- if (!fs.existsSync(contentPath)) return
45
-
46
- const publicPath = path.join(
47
- __dirname.replace('/node_modules/bfg-common/modules/fixContentBuild', ''),
48
- 'public',
49
- 'help',
50
- 'images'
51
- )
52
- fs.cp(contentPath, publicPath, { recursive: true }, () => {
53
- // Удаляем все файлы кроме картинок
54
- removeNonImageFiles(publicPath)
55
-
56
- // Удаляем картинки из папки content
57
- removeImagesFromContent(contentPath)
58
-
59
- // Правим путь к картинкам и заменяем кастомные тэги
60
- updateImagesPathAndCustomComponents(contentPath)
61
- })
62
- // End block
63
- }
64
-
65
- export default defineNuxtModule({
66
- meta: {
67
- name: 'fix-content-build',
68
- configKey: 'fixContentBuild',
69
- },
70
- setup() {
71
- switch (process.env.npm_command) {
72
- case 'run-script':
73
- // npmDev()
74
- break
75
- case 'exec':
76
- npmGenerate()
77
- break
78
- }
79
- },
80
- })
@@ -1,114 +0,0 @@
1
- import path from 'path'
2
- import fs from 'fs'
3
-
4
- const isImage = (fileName: string) => {
5
- const imageExtensions = ['.png', '.jpeg', '.jpg']
6
- return imageExtensions.some(
7
- (ext) => path.extname(fileName).toLowerCase() === ext
8
- )
9
- }
10
- const isMdFile = (fileName: string) => {
11
- return path.extname(fileName).toLowerCase() === '.md'
12
- }
13
-
14
- export const removeNonImageFiles = (dirPath: string) => {
15
- fs.readdirSync(dirPath).forEach((file: string) => {
16
- const filePath = path.join(dirPath, file)
17
- const isDir = fs.lstatSync(filePath).isDirectory()
18
-
19
- if (isDir) {
20
- removeNonImageFiles(filePath)
21
- } else {
22
- if (!isImage(file)) {
23
- fs.unlinkSync(filePath)
24
- }
25
- }
26
- })
27
- }
28
-
29
- export const removeImagesFromContent = (dirPath: string) => {
30
- fs.readdirSync(dirPath).forEach((file: string) => {
31
- const filePath = path.join(dirPath, file)
32
- const isDir = fs.lstatSync(filePath).isDirectory()
33
-
34
- if (isDir) {
35
- removeImagesFromContent(filePath)
36
- } else {
37
- if (isImage(file)) {
38
- fs.unlinkSync(filePath)
39
- } else if (isMdFile(file) && filePath.includes('_index.md')) {
40
- // Удаляем префикс "_" у индексных файлов
41
- const filePathWidthOutPrefix = filePath.replace('_index.md', 'index.md')
42
- fs.rename(filePath, filePathWidthOutPrefix, (err: any) => {
43
- if (err) {
44
- console.error(`Error renaming file: ${err}`)
45
- }
46
- })
47
- }
48
- }
49
- })
50
- }
51
-
52
- export const updateImagesPathAndCustomComponents = (dirPath: string) => {
53
- fs.readdirSync(dirPath).forEach((file: string) => {
54
- const filePath = path.join(dirPath, file)
55
- const isDir = fs.lstatSync(filePath).isDirectory()
56
-
57
- if (isDir) {
58
- updateImagesPathAndCustomComponents(filePath)
59
- } else {
60
- if (isMdFile(file)) {
61
- // @ts-ignore
62
- // Правим путь к картинкам
63
- const imagePath = filePath
64
- .replaceAll('\\', '/')
65
- .match(/\/content.+\//)[0]
66
- .replace('/content/help', '/help/images')
67
- replaceFileContent(
68
- filePath,
69
- /!\[(.*)\]\((.*?)\)/g,
70
- `![$1](${imagePath}$2)`
71
- ).then(() => {
72
- // Заменяем кастомные тэги
73
- replaceFileContent(
74
- filePath,
75
- /\{\{ *< *hint *(info) *> *\}\}|\{\{ *< *\/hint *> *\}\}/g,
76
- (_match: any, hintInfo: string) => {
77
- return hintInfo ? '\n::hint\n' : '\n::\n'
78
- }
79
- )
80
- })
81
- }
82
- }
83
- })
84
- }
85
-
86
- export const replaceFileContent = async (
87
- filePath: string,
88
- searchString: string | RegExp,
89
- replacementString: any
90
- ): Promise<void> => {
91
- return new Promise((resolve, reject) => {
92
- fs.readFile(filePath, 'utf8', (err: any, data: string) => {
93
- if (err) {
94
- reject()
95
- return console.log(err)
96
- }
97
-
98
- if (data.match(replacementString)) {
99
- resolve()
100
- return
101
- }
102
-
103
- const updatedContent = data.replace(searchString, replacementString)
104
-
105
- fs.writeFile(filePath, updatedContent, 'utf8', (err: any) => {
106
- if (err) {
107
- reject()
108
- return console.log(err)
109
- }
110
- resolve()
111
- })
112
- })
113
- })
114
- }