@adminforth/clone-row 1.1.6 → 1.2.0

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.
@@ -4,8 +4,10 @@ set -x
4
4
 
5
5
  COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
6
6
 
7
+ STATUS=${1}
7
8
 
8
- if [ "$CI_PREV_PIPELINE_STATUS" = "success" ]; then
9
+
10
+ if [ "$STATUS" = "success" ]; then
9
11
  MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
10
12
 
11
13
  curl -s -X POST -H "Content-Type: application/json" -d '{
@@ -16,25 +16,42 @@ steps:
16
16
  commands:
17
17
  - infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
18
18
 
19
- release:
19
+ build:
20
20
  image: node:20
21
21
  when:
22
22
  - event: push
23
23
  commands:
24
24
  - apt update && apt install -y rsync
25
- - export $(cat /woodpecker/deploy.vault.env | xargs)
25
+ - . /woodpecker/deploy.vault.env
26
26
  - npm clean-install
27
27
  - /bin/bash ./.woodpecker/buildRelease.sh
28
28
  - npm audit signatures
29
+
30
+ release:
31
+ image: node:20
32
+ when:
33
+ - event:
34
+ - push
35
+ branch:
36
+ - main
37
+ commands:
38
+ - . /woodpecker/deploy.vault.env
29
39
  - npx semantic-release
30
40
 
31
41
  slack-on-failure:
42
+ image: curlimages/curl
32
43
  when:
33
44
  - event: push
34
- status: [failure, success]
35
- - event: push
45
+ status: [failure]
46
+ commands:
47
+ - . /woodpecker/deploy.vault.env
48
+ - /bin/sh ./.woodpecker/buildSlackNotify.sh failure
49
+
50
+ slack-on-success:
36
51
  image: curlimages/curl
52
+ when:
53
+ - event: push
54
+ status: [success]
37
55
  commands:
38
- - export $(cat /woodpecker/deploy.vault.env | xargs)
39
- - /bin/sh ./.woodpecker/buildSlackNotify.sh
40
-
56
+ - . /woodpecker/deploy.vault.env
57
+ - /bin/sh ./.woodpecker/buildSlackNotify.sh success
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,616 bytes received 77 bytes 7,386.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.6",
3
+ "version": "1.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/types.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export interface PluginOptions {
2
-
2
+ makeCloneButtonAsQuickAction?: boolean;
3
3
  }