@timus-networks/theme 2.3.2 → 2.3.4

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.
@@ -2,82 +2,157 @@
2
2
  <div class="flex gap-4 items-center">
3
3
  <template v-if="false">
4
4
  <!-- Back butonu entegre etmek istersek bu v-if'i silmek işi çözer -->
5
- <el-button v-if="$route.path !== '/'" class="isax-arrow-left outline" size="mini" @click="$router.go(-1)" />
5
+ <el-button v-if="route.path !== '/'" class="isax-arrow-left outline" size="mini" @click="goBack" />
6
6
  </template>
7
7
  <el-breadcrumb separator="">
8
8
  <el-breadcrumb-item v-for="(crumb, index) in list" :key="index" v-bind="index < list.length - 1 ? { to: { path: crumb.path } } : {}">
9
- {{ $t(crumb.label) }}
9
+ {{ crumb }}
10
10
  <!--{{ crumb }} Tüm Objeyi Görüntülemek İçin Bunu Kullan -->
11
11
  </el-breadcrumb-item>
12
12
  </el-breadcrumb>
13
13
  </div>
14
14
  </template>
15
15
 
16
- <script>
17
- export default {
18
- props: {
19
- onChange: {
20
- type: Array,
21
- default: () => []
22
- },
23
- paths: {
24
- type: Array,
25
- default: () => []
26
- }
27
- },
28
- computed: {
29
- list() {
30
- const pathArray = this.$route.path.split("/");
31
- const { tab, id } = this.$route.query;
32
- const breadcrumbs = [];
33
- let link = "";
34
- breadcrumbs.push({
35
- path: "/",
36
- label: "header.home.text"
37
- });
38
- pathArray.filter(Boolean).forEach((path, index) => {
39
- link += "/" + path;
40
- index === pathArray.length - 2 && id && !tab && (link += "?id=" + id);
41
- const matched = this.findBestMatch(link);
42
- matched && !matched?.hidden && breadcrumbs.push(matched);
43
- });
44
- if (tab) {
45
- const matched = this.findBestMatch(link + "/" + tab);
46
- matched && !matched?.hidden && breadcrumbs.push(matched);
16
+ <script lang="ts">
17
+ /**
18
+ * tab,id,action gibi query parametrelerini alır route'un sonuna ekler ve onları da route.path gibi gösterir.
19
+ * bu parametresi sadece mevcutsa eklenir. Örnek: http://localhost:3000/customers/123?tab=details
20
+ * bu route'da tab=details olacak ve path'i resolve ederken ['customers', '123', 'details'] şu şekilde bir listeye dikkat edecektir.
21
+ *
22
+ * `hidden` ile match eden route `hidden` olarak tanimlanabilmektedir. Mesela http://localhost:3000/customers/details/123 adresinde
23
+ * {regex: `^\/customers\/details$`, hidden: true} gibi bir route tanımlandığında detail ile ilgili bir route breadrump'a eklenmez. Ama öncesindeki
24
+ * customers ve sonrasında 123 ile ilgili tanımlar yapıldıysa onlar eklenir (yapılmadıysa otomatik ekleyecektir).
25
+ *
26
+ * `rest` olarak tanımlanmışsa, match eden route'un sonrasında kalan path'a bakar ve rest ile belirtilen regex bu path ile match
27
+ * ederse o zaman ister `hidden` ile gizlersiniz, isterseniz `label` ile text'ini güncellersiniz. Örneğin birbirinin benzeri 2 adet link var diyelim.
28
+ * http://localhost:3000/customers/123, http://localhost:3000/customers/123/subscriptions gibi. 123 ile biten route'a bir text yazdırmak isterken
29
+ * diğerinin 123'e ait path'ine bir şey yazdırmak istemiyor olabilirsiniz.
30
+ * O zaman ilk route için {regex: `^\/customers\/([A-Za-z0-9\-_]+)$`, label: 'header.customers.details.text'} tanımlarken
31
+ * ikincisi için {regex: `^\/customers\/([A-Za-z0-9\-_]+)$`, rest: `^\/subscriptions$`, hidden: true} demeniz yeterli olacaktır.
32
+ * Rest burada ikinci bir condition gibi çalışmakadır.
33
+ *
34
+ * `path` ile match eden route tıklanıldığında path ile belirtilen route'a yönlendirilir. Tanımlanmazsa kendi path'ini alacaktır.
35
+ *
36
+ *`label` ile istediğiniz match eden route'a text verebilirsiniz.
37
+ *
38
+ * Rest ile ilgili detaylı açıklama:
39
+ *
40
+ * bu `customers/1363/subscriptions` gibi bir linki resolve ederken `1363` ile ilgili bir şey yazmasına engel olacaktır.
41
+ * bunu yaparken regex'i match eden route'un (customers/1363) sonrasında kalan path'a bakar, `rest` ile belirtilen
42
+ * Regex ile uyuşuyorsa (buradaki örnekte `subscriptions`) parantez içerisinde belirtilen kısmı navigasyona eklemez.
43
+ * Sonuç: `customers/subscriptions` şeklinde algılar.
44
+ *
45
+ * Dilerseniz `hidden:true` ile bu route gizleyebilirsiniz. Bu durumda breadcrumbda `home > customer > subscription` gibi bir sıralama yapılacaktır.
46
+ * Ya da `label` ile yeni bir isim verebilirsiniz.
47
+ * {
48
+ * regex: /^\/customers\/([A-Za-z0-9\-_]+)$/,
49
+ * rest: /^subscriptions$/,
50
+ * hidden: true,
51
+ * },
52
+ * {
53
+ * regex: /^\/customers\/([A-Za-z0-9\-_]+)$/,
54
+ * rest: /^subscriptions$/,
55
+ * label: "yeni isim",
56
+ * },
57
+ */
58
+ </script>
59
+
60
+ <script setup lang="ts">
61
+ import { computed } from 'vue';
62
+
63
+ interface Breadcrumb {
64
+ regex: string;
65
+ path: string;
66
+ label: string;
67
+ hidden?: boolean;
68
+ rest?: string;
69
+ auto?: boolean;
70
+ value?: string;
71
+ }
72
+
73
+ interface Props {
74
+ onChange?: Array<() => void>;
75
+ paths: Array<Breadcrumb>;
76
+ }
77
+
78
+ const props = withDefaults(defineProps<Props>(), {
79
+ onChange: () => [],
80
+ paths: () => [],
81
+ });
82
+ const route = useRoute();
83
+ const list = computed<Breadcrumb[]>(() => {
84
+ const pathArray = route.path.split('/');
85
+ const { tab, id } = route.query;
86
+ const breadcrumbs: Breadcrumb[] = [];
87
+ let link = '';
88
+
89
+ breadcrumbs.push({
90
+ path: '/',
91
+ label: 'header.home.text',
92
+ regex: '\/',
93
+ });
94
+
95
+ pathArray.filter(Boolean).forEach((path, index) => {
96
+ link += '/' + path;
97
+ if (index === pathArray.length - 2 && id && !tab) {
98
+ link += '?id=' + id;
99
+ }
100
+ const matched = findBestMatch(link);
101
+
102
+ if (matched && !matched?.hidden) {
103
+ breadcrumbs.push(matched);
104
+ }
105
+ });
106
+
107
+ if (tab) {
108
+ const matched = findBestMatch(link + '/' + tab);
109
+
110
+ if (matched && !matched?.hidden) {
111
+ breadcrumbs.push(matched);
47
112
  }
48
- return breadcrumbs;
49
113
  }
50
- },
51
- methods: {
52
- findBestMatch(url) {
53
- let bestMatch = null;
54
- let maxMatchLength = 0;
55
- this.paths.forEach((route) => {
56
- const regex = new RegExp(route.regex);
57
- if (regex.test(url)) {
58
- const match = url?.match(regex);
59
- if (match[0].length > maxMatchLength) {
60
- maxMatchLength = match.length;
61
- route.path = route.path ?? match[0];
62
- match[1] && ([, route.value] = match);
63
- bestMatch = route;
64
- }
114
+
115
+ return breadcrumbs;
116
+ });
117
+ const findBestMatch = (url: string): Breadcrumb | null => {
118
+ let bestMatch: Breadcrumb | null = null;
119
+ let maxMatchLength = 0;
120
+
121
+ props.paths.forEach((route: Breadcrumb) => {
122
+ const regex = new RegExp(route.regex);
123
+
124
+ if (regex.test(url)) {
125
+ const match = url.match(regex);
126
+
127
+ if (match && match[0].length > maxMatchLength) {
128
+ maxMatchLength = match[0].length;
129
+ route.path = route.path ?? match[0]; // route.path tanımsızsa match[0] ile güncelle
130
+
131
+ if (match[1]) [, route.value] = match; // match[1] mevcutsa route.value güncelle, yoksa eski değeri koru
132
+
133
+ bestMatch = route;
65
134
  }
66
- });
67
- if (!bestMatch) {
68
- let label = "header";
69
- let filteredArray = url.split("/").filter(Boolean);
70
- filteredArray.forEach((path) => {
71
- label = label + `.${path}`;
72
- });
73
- bestMatch = {
74
- label: label + ".text",
75
- path: url,
76
- auto: true
77
- };
78
135
  }
79
- return bestMatch;
136
+ });
137
+
138
+ if (!bestMatch) {
139
+ let label = 'header';
140
+ const filteredArray = url.split('/').filter(Boolean);
141
+
142
+ filteredArray.forEach((path) => {
143
+ label = label + `.${path}`;
144
+ });
145
+
146
+ bestMatch = {
147
+ label: label + '.text',
148
+ path: url,
149
+ auto: true,
150
+ regex: '',
151
+ };
80
152
  }
81
- }
82
- };
153
+
154
+ return bestMatch;
155
+ };
156
+ const router = useRouter();
157
+ const goBack = () => router.go(-1);
83
158
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timus-networks/theme",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "A comprehensive Nuxt.js module providing a tailored theme experience with integrated TailwindCSS support for applications.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -27,7 +27,7 @@
27
27
  "sass": "node generate-sass.js",
28
28
  "prepack": "nuxt-module-build build",
29
29
  "release-old": "npm run prepack && changelogen --release && npm run pub && git push --follow-tags",
30
- "version": "standard-version",
30
+ "version": "standard-version --release-as ${npm_config_type:-patch}",
31
31
  "release": "npm run prepack && npm run version && npm run pub && git push --follow-tags origin main"
32
32
  },
33
33
  "standard-version": {
@@ -1,36 +0,0 @@
1
- export declare const path: ({
2
- regex: RegExp;
3
- label: string;
4
- path?: undefined;
5
- hidden?: undefined;
6
- deep?: undefined;
7
- parameter?: undefined;
8
- } | {
9
- regex: RegExp;
10
- label: string;
11
- path: string;
12
- hidden?: undefined;
13
- deep?: undefined;
14
- parameter?: undefined;
15
- } | {
16
- regex: RegExp;
17
- label: string;
18
- hidden: boolean;
19
- path?: undefined;
20
- deep?: undefined;
21
- parameter?: undefined;
22
- } | {
23
- regex: RegExp;
24
- hidden: boolean;
25
- label?: undefined;
26
- path?: undefined;
27
- deep?: undefined;
28
- parameter?: undefined;
29
- } | {
30
- regex: RegExp;
31
- label: string;
32
- path: string;
33
- deep: boolean;
34
- parameter: string;
35
- hidden?: undefined;
36
- })[];
@@ -1,224 +0,0 @@
1
- export const path = [
2
- /* Users */
3
- {
4
- regex: /^\/about$/,
5
- label: "header.about.text"
6
- },
7
- {
8
- regex: /^\/users$/,
9
- label: "header.users.text",
10
- path: "/users?tab=users"
11
- },
12
- {
13
- regex: /^\/users\/(\d+)/,
14
- label: "header.users.detail.text"
15
- },
16
- {
17
- regex: /^\/teams/,
18
- label: "header.teams.text",
19
- path: "/users?tab=teams"
20
- },
21
- {
22
- regex: /^\/teams\/(\d+)/,
23
- label: "header.teams.detail.text"
24
- },
25
- /* Devices */
26
- {
27
- regex: /^\/devices\/telemetry\/([A-Za-z0-9\-_]+)/,
28
- label: "header.devices.detail.text",
29
- hidden: true
30
- },
31
- {
32
- regex: /^\/devices\/(?![telemetry])([A-Za-z0-9\-_]+)/,
33
- // regex: /^\/devices\/details(?:\/([A-Za-z0-9\-_]+))?$/,
34
- label: "header.devices.posture_details.text"
35
- },
36
- /* Sites */
37
- {
38
- regex: /^\/sites\/(\d+)/,
39
- label: "header.sites.detail.text"
40
- },
41
- /* Sites Custom Port */
42
- {
43
- regex: /^\/sites\/([^/]+)\/custom-ports/,
44
- label: "header.sites.custom_ports.text"
45
- },
46
- /* Rules */
47
- {
48
- regex: /^\/rules$/,
49
- label: "header.rules.text",
50
- path: "/rules/firewall"
51
- },
52
- {
53
- regex: /^\/rules\/firewall\/create/,
54
- label: "header.rules.firewall.create.text"
55
- },
56
- {
57
- regex: /^\/rules\/firewall\/(?!create)([A-Za-z0-9\-_]+)/,
58
- label: "header.rules.firewall.detail.text"
59
- },
60
- {
61
- regex: /^\/rules\/forwarding\/(?!create)([A-Za-z0-9\-_]+)/,
62
- label: "header.rules.forwarding.detail.text"
63
- },
64
- {
65
- regex: /^\/rules\/acls\/([A-Za-z0-9\-_]+)/,
66
- label: "header.rules.acls.edit.text"
67
- },
68
- /* Ztna - Zero Trust Security */
69
- {
70
- regex: /^\/ztna$/,
71
- label: "header.ztna.text",
72
- path: "/ztna/dashboard"
73
- },
74
- {
75
- regex: /^\/ztna\/device-posture-check\/(view|edit)$/,
76
- hidden: true
77
- },
78
- {
79
- regex: /^\/ztna\/device-posture-check\/view\/([A-Za-z0-9\-_]+)/,
80
- label: "header.ztna.device-posture-check.view.text"
81
- },
82
- {
83
- regex: /^\/ztna\/device-posture-check\/edit\/([A-Za-z0-9\-_]+)/,
84
- label: "header.ztna.device-posture-check.edit.text"
85
- },
86
- /* Insights */
87
- {
88
- regex: /^\/insights$/,
89
- // /insights ya da /insights/alerts ikisinden biri yeterli
90
- label: "header.insights.text",
91
- path: "/insights/alerts?tab=alerts&page=1"
92
- },
93
- {
94
- regex: /^\/insights(?:\/alerts)$/,
95
- // /insights ya da /insights/alerts ikisinden biri yeterli
96
- label: "header.insights.alerts.text",
97
- path: "/insights/alerts?tab=alerts&page=1"
98
- },
99
- {
100
- regex: /^\/insights(?:\/traffic)$/,
101
- // /insights ya da /insights/alerts ikisinden biri yeterli
102
- label: "header.insights.traffic.text",
103
- path: "/insights/traffic?tab=log&page=1"
104
- },
105
- {
106
- regex: /^\/insights(?:\/events)$/,
107
- // /insights ya da /insights/events ikisinden biri yeterli
108
- label: "header.insights.events.text",
109
- path: "/insights/events?tab=user&page=1"
110
- },
111
- {
112
- regex: /^\/insights\/reports\/(?!templates)([A-Za-z0-9\-_]+)/,
113
- label: "header.insights.tracker.reports.detail.text"
114
- },
115
- {
116
- regex: /^\/insights\/reports\/templates$/,
117
- label: "header.insights.tracker.reports.templates.text",
118
- path: "/insights/reports?page=1"
119
- },
120
- {
121
- regex: /^\/insights\/reports\/templates\/([A-Za-z0-9\-_]+)/,
122
- label: "header.insights.tracker.reports.templates.edit.text"
123
- },
124
- {
125
- regex: /^\/insights\/tracker$/,
126
- label: "header.insights.tracker.text",
127
- path: "/insights/tracker?tab=overview"
128
- },
129
- {
130
- regex: /^\/insights\/tracker\/overview$/,
131
- label: "header.insights.tracker.overview.text",
132
- path: "/insights/tracker?tab=overview"
133
- },
134
- {
135
- regex: /^\/insights\/tracker\/user(?:s)?$/,
136
- label: "header.insights.tracker.users.text",
137
- path: "/insights/tracker?tab=users"
138
- },
139
- {
140
- regex: /^\/insights\/tracker\/team(?:s)?$/,
141
- label: "header.insights.tracker.teams.text",
142
- path: "/insights/tracker?tab=teams"
143
- },
144
- {
145
- regex: /^\/insights\/tracker\/application(?:s)?$/,
146
- label: "header.insights.tracker.applications.text",
147
- path: "/insights/tracker?tab=applications"
148
- },
149
- {
150
- regex: /^\/insights\/tracker\/user\/([A-Za-z0-9\-_]+)/,
151
- label: "header.insights.tracker.user.detail.text"
152
- },
153
- {
154
- regex: /^\/insights\/tracker\/team\/([A-Za-z0-9\-_]+)/,
155
- label: "header.insights.tracker.team.detail.text"
156
- },
157
- {
158
- regex: /^\/insights\/tracker\/application\/([A-Za-z0-9\-_]+)/,
159
- label: "header.insights.tracker.application.detail.text"
160
- },
161
- {
162
- regex: /^\/insights\/dpc-reports$/,
163
- // /insights ya da /insights/events ikisinden biri yeterli
164
- label: "header.insights.dpc-reports.text",
165
- path: "/insights/dpc-reports?tab=overview"
166
- },
167
- {
168
- regex: /^\/insights\/dpc-reports\/(?!overview|devices|posture_checks)([A-Za-z0-9\-_]+)$/,
169
- label: "header.insights.dpc-reports.detail.text",
170
- path: "/insights/dpc-reports?tab=overview"
171
- },
172
- {
173
- regex: /^\/insights\/dpc-reports\/([A-Za-z0-9\-_]+)\/([A-Za-z0-9\-_]+)$/,
174
- label: "header.insights.dpc-reports.batch_id.detail.text",
175
- path: "/insights/dpc-reports?tab=overview",
176
- deep: true,
177
- parameter: "show"
178
- },
179
- {
180
- regex: /^\/settings$/,
181
- label: "header.settings.text",
182
- path: "/settings/integrations"
183
- },
184
- {
185
- regex: /^\/settings\/configuration\/(?:trusted_networks|trusted-networks)$/,
186
- label: "header.settings.configuration.trusted_networks.text",
187
- path: "/settings/configuration?tab=trusted_networks"
188
- },
189
- {
190
- regex: /^\/settings\/configuration\/trusted-networks\/(?!create)([A-Za-z0-9\-_]+)$/,
191
- label: "header.settings.configuration.trusted_networks.edit.text",
192
- path: "/settings/configuration?tab=trusted_networks"
193
- },
194
- {
195
- regex: /^\/settings\/tags\/new$/,
196
- label: "header.settings.tags.new.text"
197
- },
198
- {
199
- regex: /^\/settings\/tags\/(?!new)([A-Za-z0-9\-_]+)/,
200
- label: "header.settings.tags.detail.text"
201
- },
202
- {
203
- regex: /^\/settings\/administrators$/,
204
- label: "header.settings.administrators.text"
205
- },
206
- {
207
- regex: /^\/settings\/administrators\/roles$/,
208
- label: "header.settings.administrators.roles.text",
209
- path: "/settings/administrators?tab=roles"
210
- },
211
- {
212
- regex: /^\/settings\/administrators\/roles\/detail$/,
213
- label: "header.settings.administrators.roles.create.text"
214
- },
215
- {
216
- regex: /^\/settings\/administrators\/roles\/detail\?id=\d+$/,
217
- label: "header.settings.administrators.roles.edit.text"
218
- }
219
- // {
220
- // path: 'settings',
221
- // regex: '/settings/.*',
222
- // label: 'header.settings.detail.text',
223
- // },
224
- ];