index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div>
  3. <a-form-item class="mb-0">
  4. <a-radio-group v-decorator="decorators.secretType" @change="secretTypeChange">
  5. <a-radio-button value="none">{{$t('k8s.text_75')}}</a-radio-button>
  6. <a-radio-button value="select">{{$t('k8s.text_76')}}</a-radio-button>
  7. </a-radio-group>
  8. </a-form-item>
  9. <a-form-item v-if="secretType === 'select'">
  10. <base-select
  11. v-decorator="decorators.imagePullSecrets"
  12. resource="secrets"
  13. version="v1"
  14. :params="params"
  15. :need-params="true"
  16. :select-props="{ mode: 'multiple', placeholder: $t('k8s.text_77') }" />
  17. <div slot="extra">{{$t('k8s.text_78')}}<a-button type="link" @click="createImageSecret">{{$t('k8s.text_79')}}</a-button>
  18. </div>
  19. </a-form-item>
  20. </div>
  21. </template>
  22. <script>
  23. import { SECRET_DEFAULT_TYPE } from '@K8S/constants'
  24. import WindowsMixin from '@/mixins/windows'
  25. export default {
  26. name: 'K8SImageSecrets',
  27. mixins: [WindowsMixin],
  28. props: {
  29. decorators: {
  30. type: Object,
  31. default: val => val.secretType && val.imagePullSecrets,
  32. },
  33. cluster: {},
  34. namespace: {},
  35. form: {
  36. type: Object,
  37. required: true,
  38. validator: val => val.fc,
  39. },
  40. },
  41. data () {
  42. return {
  43. secretType: 'none',
  44. }
  45. },
  46. computed: {
  47. params () {
  48. if (this.cluster && this.namespace) {
  49. return {
  50. type: SECRET_DEFAULT_TYPE,
  51. cluster: this.cluster,
  52. namespace: this.namespace,
  53. }
  54. }
  55. return {}
  56. },
  57. },
  58. methods: {
  59. secretTypeChange (e) {
  60. this.secretType = e.target.value
  61. },
  62. createImageSecret () {
  63. this.createDialog('K8SImageSecretCreateDialog', {
  64. title: this.$t('k8s.text_80'),
  65. cluster: this.cluster,
  66. namespace: this.namespace,
  67. success: name => {
  68. if (this.form.fc) {
  69. this.form.fc.setFieldsValue({
  70. [this.decorators.imagePullSecrets[0]]: [name],
  71. })
  72. }
  73. },
  74. })
  75. },
  76. },
  77. }
  78. </script>