@adminforth/clone-row 1.1.7 → 1.2.1

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.
@@ -23,7 +23,10 @@ steps:
23
23
  commands:
24
24
  - apt update && apt install -y rsync
25
25
  - . /woodpecker/deploy.vault.env
26
- - npm clean-install
26
+ - npm install --global corepack@latest
27
+ - corepack enable pnpm
28
+ - corepack use pnpm@latest-10
29
+ - pnpm install
27
30
  - /bin/bash ./.woodpecker/buildRelease.sh
28
31
  - npm audit signatures
29
32
 
@@ -36,7 +39,10 @@ steps:
36
39
  - main
37
40
  commands:
38
41
  - . /woodpecker/deploy.vault.env
39
- - npx semantic-release
42
+ - npm install --global corepack@latest
43
+ - corepack enable pnpm
44
+ - corepack use pnpm@latest-10
45
+ - pnpm exec semantic-release
40
46
 
41
47
  slack-on-failure:
42
48
  image: curlimages/curl
package/build.log CHANGED
@@ -5,7 +5,8 @@
5
5
  sending incremental file list
6
6
  custom/
7
7
  custom/CloneRowButton.vue
8
+ custom/CloneRowThreeDots.vue
8
9
  custom/tsconfig.json
9
10
 
10
- sent 2,087 bytes received 58 bytes 4,290.00 bytes/sec
11
- total size is 1,869 speedup is 0.87
11
+ sent 3,612 bytes received 77 bytes 7,378.00 bytes/sec
12
+ total size is 3,322 speedup is 0.90
@@ -7,7 +7,7 @@
7
7
  values: save_btoa(JSON.stringify(redirectToCreatePage())),
8
8
  }
9
9
  }">
10
- <IconFileCloneOutline class="w-5 h-5 me-2"/>
10
+ <IconFileCloneSolid class="w-5 h-5 me-2"/>
11
11
  </RouterLink>
12
12
  <template v-slot:tooltip>
13
13
  {{ $t('Clone record') }}
@@ -18,7 +18,7 @@
18
18
  <script lang="ts" setup>
19
19
  import { Tooltip } from '@/afcl';
20
20
  import { AdminUser, type AdminForthResourceCommon } from '@/types';
21
- import { IconFileCloneOutline } from '@iconify-prerendered/vue-flowbite';
21
+ import { IconFileCloneSolid } from '@iconify-prerendered/vue-flowbite';
22
22
  import { useI18n } from 'vue-i18n';
23
23
 
24
24
  const { t } = useI18n();
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <RouterLink
3
+ class="flex px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300"
4
+ :to="{
5
+ name: `resource-create`,
6
+ params: { resourceId: props.meta.resourceId },
7
+ query: {
8
+ values: save_btoa(JSON.stringify(redirectToCreatePage())),
9
+ }
10
+ }">
11
+ <IconFileCloneSolid class="w-5 h-5 me-2 text-lightPrimary dark:text-darkPrimary"/>
12
+ {{ $t('Clone record') }}
13
+ </RouterLink>
14
+ </template>
15
+
16
+ <script lang="ts" setup>
17
+ import { Tooltip } from '@/afcl';
18
+ import { AdminUser, type AdminForthResourceCommon } from '@/types';
19
+ import { IconFileCloneSolid } from '@iconify-prerendered/vue-flowbite';
20
+ import { useI18n } from 'vue-i18n';
21
+
22
+ const { t } = useI18n();
23
+
24
+ const props = defineProps<{
25
+ meta: any,
26
+ resource: AdminForthResourceCommon,
27
+ adminUser: AdminUser,
28
+ record: any,
29
+ updateRecords: Function,
30
+ }>();
31
+
32
+ function redirectToCreatePage() {
33
+ const fieldsToFill = { ...props.resource.columns.filter((col: any) => col.showIn.create === true) }
34
+ let dataToFill = {};
35
+ for (const field of Object.values(fieldsToFill)) {
36
+ if (field.foreignResource) {
37
+ dataToFill[field.name] = props.record[field.name]?.pk
38
+ continue;
39
+ }
40
+ dataToFill[field.name] = props.record[field.name];
41
+ }
42
+ return dataToFill;
43
+ }
44
+
45
+ function save_btoa(str) {
46
+ const cleaned = str.replace(/\uFEFF/g, '');
47
+ return btoa(cleaned);
48
+ }
49
+ </script>
@@ -7,7 +7,7 @@
7
7
  values: save_btoa(JSON.stringify(redirectToCreatePage())),
8
8
  }
9
9
  }">
10
- <IconFileCloneOutline class="w-5 h-5 me-2"/>
10
+ <IconFileCloneSolid class="w-5 h-5 me-2"/>
11
11
  </RouterLink>
12
12
  <template v-slot:tooltip>
13
13
  {{ $t('Clone record') }}
@@ -18,7 +18,7 @@
18
18
  <script lang="ts" setup>
19
19
  import { Tooltip } from '@/afcl';
20
20
  import { AdminUser, type AdminForthResourceCommon } from '@/types';
21
- import { IconFileCloneOutline } from '@iconify-prerendered/vue-flowbite';
21
+ import { IconFileCloneSolid } from '@iconify-prerendered/vue-flowbite';
22
22
  import { useI18n } from 'vue-i18n';
23
23
 
24
24
  const { t } = useI18n();
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <RouterLink
3
+ class="flex px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300"
4
+ :to="{
5
+ name: `resource-create`,
6
+ params: { resourceId: props.meta.resourceId },
7
+ query: {
8
+ values: save_btoa(JSON.stringify(redirectToCreatePage())),
9
+ }
10
+ }">
11
+ <IconFileCloneSolid class="w-5 h-5 me-2 text-lightPrimary dark:text-darkPrimary"/>
12
+ {{ $t('Clone record') }}
13
+ </RouterLink>
14
+ </template>
15
+
16
+ <script lang="ts" setup>
17
+ import { Tooltip } from '@/afcl';
18
+ import { AdminUser, type AdminForthResourceCommon } from '@/types';
19
+ import { IconFileCloneSolid } from '@iconify-prerendered/vue-flowbite';
20
+ import { useI18n } from 'vue-i18n';
21
+
22
+ const { t } = useI18n();
23
+
24
+ const props = defineProps<{
25
+ meta: any,
26
+ resource: AdminForthResourceCommon,
27
+ adminUser: AdminUser,
28
+ record: any,
29
+ updateRecords: Function,
30
+ }>();
31
+
32
+ function redirectToCreatePage() {
33
+ const fieldsToFill = { ...props.resource.columns.filter((col: any) => col.showIn.create === true) }
34
+ let dataToFill = {};
35
+ for (const field of Object.values(fieldsToFill)) {
36
+ if (field.foreignResource) {
37
+ dataToFill[field.name] = props.record[field.name]?.pk
38
+ continue;
39
+ }
40
+ dataToFill[field.name] = props.record[field.name];
41
+ }
42
+ return dataToFill;
43
+ }
44
+
45
+ function save_btoa(str) {
46
+ const cleaned = str.replace(/\uFEFF/g, '');
47
+ return btoa(cleaned);
48
+ }
49
+ </script>
package/dist/index.js CHANGED
@@ -25,10 +25,22 @@ export default class extends AdminForthPlugin {
25
25
  if (!resourceConfig.options.pageInjections.list) {
26
26
  resourceConfig.options.pageInjections.list = {};
27
27
  }
28
- if (!resourceConfig.options.pageInjections.list.customActionIcons) {
29
- resourceConfig.options.pageInjections.list.customActionIcons = [];
28
+ if (this.options.makeCloneButtonAsQuickAction) {
29
+ if (!resourceConfig.options.pageInjections.list.customActionIcons) {
30
+ resourceConfig.options.pageInjections.list.customActionIcons = [];
31
+ }
32
+ resourceConfig.options.pageInjections.list.customActionIcons.push({ file: this.componentPath('CloneRowButton.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId } });
33
+ }
34
+ else {
35
+ //TODO: after customActionIconsThreeDotsMenuItems will be released in adminforth.main, remove ts-ignore
36
+ //@ts-ignore
37
+ if (!resourceConfig.options.pageInjections.list.customActionIconsThreeDotsMenuItems) {
38
+ //@ts-ignore
39
+ resourceConfig.options.pageInjections.list.customActionIconsThreeDotsMenuItems = [];
40
+ }
41
+ //@ts-ignore
42
+ resourceConfig.options.pageInjections.list.customActionIconsThreeDotsMenuItems.push({ file: this.componentPath('CloneRowThreeDots.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId } });
30
43
  }
31
- resourceConfig.options.pageInjections.list.customActionIcons.push({ file: this.componentPath('CloneRowButton.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId } });
32
44
  // simply modify resourceConfig or adminforth.config. You can get access to plugin options via this.options;
33
45
  });
34
46
  }
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AdminForthPlugin } from "adminforth";
2
- import type { IAdminForth, IHttpServer, AdminForthResourceColumn, AdminForthResource, IAdminForthHttpResponse, AdminUser, AdminForthComponentDeclaration } from "adminforth";
2
+ import type { IAdminForth, AdminForthResource, AdminForthComponentDeclaration } from "adminforth";
3
3
  import type { PluginOptions } from './types.js';
4
4
 
5
5
 
@@ -20,12 +20,25 @@ export default class extends AdminForthPlugin {
20
20
  if ( !resourceConfig.options.pageInjections.list ) {
21
21
  resourceConfig.options.pageInjections.list = {};
22
22
  }
23
- if ( !resourceConfig.options.pageInjections.list.customActionIcons ) {
24
- resourceConfig.options.pageInjections.list.customActionIcons = [];
23
+ if ( this.options.makeCloneButtonAsQuickAction ) {
24
+ if ( !resourceConfig.options.pageInjections.list.customActionIcons ) {
25
+ resourceConfig.options.pageInjections.list.customActionIcons = [];
26
+ }
27
+ (resourceConfig.options.pageInjections.list.customActionIcons as AdminForthComponentDeclaration[]).push(
28
+ { file: this.componentPath('CloneRowButton.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId } }
29
+ );
30
+ } else {
31
+ //TODO: after customActionIconsThreeDotsMenuItems will be released in adminforth.main, remove ts-ignore
32
+ //@ts-ignore
33
+ if ( !resourceConfig.options.pageInjections.list.customActionIconsThreeDotsMenuItems ) {
34
+ //@ts-ignore
35
+ resourceConfig.options.pageInjections.list.customActionIconsThreeDotsMenuItems = [];
36
+ }
37
+ //@ts-ignore
38
+ (resourceConfig.options.pageInjections.list.customActionIconsThreeDotsMenuItems as AdminForthComponentDeclaration[]).push(
39
+ { file: this.componentPath('CloneRowThreeDots.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId } }
40
+ );
25
41
  }
26
- (resourceConfig.options.pageInjections.list.customActionIcons as AdminForthComponentDeclaration[]).push(
27
- { file: this.componentPath('CloneRowButton.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId } }
28
- );
29
42
 
30
43
  // simply modify resourceConfig or adminforth.config. You can get access to plugin options via this.options;
31
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/clone-row",
3
- "version": "1.1.7",
3
+ "version": "1.2.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -16,11 +16,12 @@
16
16
  "description": "",
17
17
  "devDependencies": {
18
18
  "@types/node": "latest",
19
+ "semantic-release": "^24.2.1",
19
20
  "semantic-release-slack-bot": "^4.0.2",
20
21
  "typescript": "^5.7.3"
21
22
  },
22
23
  "peerDependencies": {
23
- "adminforth": "next"
24
+ "adminforth": "^2.24.0"
24
25
  },
25
26
  "release": {
26
27
  "plugins": [
@@ -31,6 +32,7 @@
31
32
  [
32
33
  "semantic-release-slack-bot",
33
34
  {
35
+ "packageName": "@adminforth/clone-row",
34
36
  "notifyOnSuccess": true,
35
37
  "notifyOnFail": true,
36
38
  "slackIcon": ":package:",
@@ -45,5 +47,6 @@
45
47
  "name": "next",
46
48
  "prerelease": true
47
49
  }
48
- ]
50
+ ],
51
+ "packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017"
49
52
  }
package/types.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export interface PluginOptions {
2
-
2
+ makeCloneButtonAsQuickAction?: boolean;
3
3
  }