|
| 1 | +/* |
| 2 | + * Copyright 2025, Seqera Labs |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package nextflow.slack |
| 18 | + |
| 19 | +import groovy.transform.CompileStatic |
| 20 | + |
| 21 | +/** |
| 22 | + * Configuration for Seqera Platform action buttons in Slack messages. |
| 23 | + * |
| 24 | + * <p>Link mode (default) emits URL buttons that open the Platform run page. |
| 25 | + * Interactive mode emits action_id buttons for an external Slack interactivity handler. |
| 26 | + */ |
| 27 | +@CompileStatic |
| 28 | +class SeqeraPlatformActionButtonsConfig { |
| 29 | + |
| 30 | + static final String MODE_LINK = 'link' |
| 31 | + static final String MODE_INTERACTIVE = 'interactive' |
| 32 | + |
| 33 | + final String mode |
| 34 | + final boolean cancel |
| 35 | + final boolean resume |
| 36 | + final boolean relaunch |
| 37 | + |
| 38 | + SeqeraPlatformActionButtonsConfig(Map config) { |
| 39 | + config = config ?: [:] |
| 40 | + this.mode = (config.mode as String ?: MODE_LINK).toLowerCase() |
| 41 | + this.cancel = config.cancel != null ? config.cancel as boolean : true |
| 42 | + this.resume = config.resume != null ? config.resume as boolean : true |
| 43 | + this.relaunch = config.relaunch != null ? config.relaunch as boolean : true |
| 44 | + } |
| 45 | + |
| 46 | + boolean isLinkMode() { |
| 47 | + return mode == MODE_LINK |
| 48 | + } |
| 49 | + |
| 50 | + boolean isInteractiveMode() { |
| 51 | + return mode == MODE_INTERACTIVE |
| 52 | + } |
| 53 | +} |
0 commit comments