|
40 | 40 | </div> |
41 | 41 | </b-form-checkbox-group> |
42 | 42 | </pm-modal> |
| 43 | + <pm-modal ref="secretModal" id="secretModal" :title="secretTitle" style="display: none;" |
| 44 | + :set-custom-buttons="true" |
| 45 | + :custom-buttons="customModalButtons" |
| 46 | + @close="hideSecretModal"> |
| 47 | + <div class="form-group"> |
| 48 | + <label for="secret">{{__('Secret')}}</label> |
| 49 | + <div class="input-group"> |
| 50 | + <input readonly disabled type="text" class="form-control" id="secret" v-model="secret"> |
| 51 | + <div class="input-group-append"> |
| 52 | + <button type="button" class="btn btn-primary" @click="copySecret(secret)" v-b-tooltip.hover :title="$t('Copy Secret To Clipboard')"> |
| 53 | + <i class="fa-lg fas fa-copy" aria-hidden="true"></i> |
| 54 | + </button> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + </div> |
| 58 | + <div class="tw-flex tw-items-start tw-gap-3 tw-p-3 tw-mt-3 tw-rounded-lg tw-border tw-border-amber-300 tw-bg-amber-50 tw-text-amber-900" role="alert"> |
| 59 | + <i class="fas fa-exclamation-triangle tw-text-amber-500 tw-mt-0.5 tw-shrink-0" aria-hidden="true"></i> |
| 60 | + <p class="tw-text-sm tw-m-0">{{ __('This is the only time you will be able to view the client secret. Keep it in a safe place.') }}</p> |
| 61 | + </div> |
| 62 | + </pm-modal> |
43 | 63 |
|
44 | 64 | <div class="px-3 page-content"> |
45 | 65 | <div id="search-bar" class="search mb-3" vcloak> |
|
66 | 86 | <auth-clients-listing ref="authClientList" :permission="{{ \Auth::user()->hasPermissionsFor('auth_clients') }}" :filter="filter" @edit="edit"/> |
67 | 87 | </div> |
68 | 88 | </div> |
69 | | - |
70 | 89 | </div> |
71 | 90 | @endsection |
72 | 91 |
|
|
88 | 107 | errors: null, |
89 | 108 | disabled: false, |
90 | 109 | title:'', |
| 110 | + secretTitle:'', |
| 111 | + customModalButtons: [], |
| 112 | + secret: "", |
91 | 113 | }, |
92 | 114 | beforeMount() { |
| 115 | + this.initCustomModalButtons(); |
93 | 116 | this.resetValues(); |
94 | 117 | }, |
95 | 118 | methods: { |
|
120 | 143 | data: this.authClient, |
121 | 144 | }).then(response => { |
122 | 145 | this.$refs.createEditAuthClient.hide(); |
123 | | - this.$refs.authClientList.fetch(); |
124 | 146 | this.loading = false; |
| 147 | + if (response.data.secret) { |
| 148 | + this.secret = response.data.secret |
| 149 | + this.$refs.secretModal.show(); |
| 150 | + } |
| 151 | + else { |
| 152 | + this.$refs.authClientList.fetch(); |
| 153 | + } |
125 | 154 | ProcessMaker.alert(this.$t("The auth client was ") + verb + ".", this.$t("success")) |
126 | 155 | }).catch(error => { |
127 | 156 | this.disabled = false; |
|
130 | 159 | }, |
131 | 160 | resetValues() { |
132 | 161 | this.title = this.$t('Create Auth-Client') |
| 162 | + this.secretTitle = this.$t('Copy Secret To Clipboard') |
133 | 163 | this.authClient = { |
134 | 164 | id: null, |
135 | 165 | name: "", |
|
143 | 173 | types: null |
144 | 174 | }; |
145 | 175 | this.disabled = false; |
| 176 | + this.initCustomModalButtons(); |
146 | 177 | }, |
147 | 178 | edit(item) { |
148 | 179 | this.title = this.$t('Edit Auth Client'); |
149 | 180 | this.authClient = item; |
150 | 181 | this.$refs.createEditAuthClient.show(); |
151 | | - } |
| 182 | + }, |
| 183 | + initCustomModalButtons() { |
| 184 | + this.customModalButtons = [ |
| 185 | + { |
| 186 | + content: "Close", |
| 187 | + action: "close", |
| 188 | + variant: "secondary", |
| 189 | + disabled: false, |
| 190 | + hidden: false, |
| 191 | + }, |
| 192 | + ]; |
| 193 | + }, |
| 194 | + hideSecretModal() { |
| 195 | + this.$refs.secretModal.hide(); |
| 196 | + this.$refs.authClientList.fetch(); |
| 197 | + }, |
| 198 | + copySecret(secret) { |
| 199 | + navigator.clipboard.writeText(secret).then(() => { |
| 200 | + ProcessMaker.alert(this.$t("Secret copied to clipboard."), "success"); |
| 201 | + }, () => { |
| 202 | + ProcessMaker.alert(this.$t("Secret not copied to clipboard."), "danger"); |
| 203 | + }); |
| 204 | + }, |
152 | 205 | }, |
153 | 206 | }) |
154 | 207 | </script> |
|
0 commit comments