You've already forked AstralRinth
forked from didirus/AstralRinth
Moderation Checklist Fixes (#3986)
* fix: DEV-164 * fix: dev-163 * feat: DEV-162
This commit is contained in:
@@ -153,6 +153,13 @@ export interface DropdownActionOption extends WeightedMessage {
|
||||
* The label of the option, which is displayed to the moderator.
|
||||
*/
|
||||
label: string
|
||||
|
||||
/**
|
||||
* A function that determines whether this option should be shown for a given project.
|
||||
*
|
||||
* By default, it returns `true`, meaning the option is always shown.
|
||||
*/
|
||||
shouldShow?: (project: Project) => boolean
|
||||
}
|
||||
|
||||
export interface DropdownAction extends BaseAction {
|
||||
@@ -179,6 +186,13 @@ export interface MultiSelectChipsOption extends WeightedMessage {
|
||||
* The label of the chip, which is displayed to the moderator.
|
||||
*/
|
||||
label: string
|
||||
|
||||
/**
|
||||
* A function that determines whether this option should be shown for a given project.
|
||||
*
|
||||
* By default, it returns `true`, meaning the option is always shown.
|
||||
*/
|
||||
shouldShow?: (project: Project) => boolean
|
||||
}
|
||||
|
||||
export interface MultiSelectChipsAction extends BaseAction {
|
||||
|
||||
@@ -125,13 +125,19 @@ export function processMessage(
|
||||
export function findMatchingVariant(
|
||||
variants: ConditionalMessage[],
|
||||
selectedActionIds: string[],
|
||||
allValidActionIds?: string[],
|
||||
): ConditionalMessage | null {
|
||||
for (const variant of variants) {
|
||||
const conditions = variant.conditions
|
||||
|
||||
const meetsRequired =
|
||||
!conditions.requiredActions ||
|
||||
conditions.requiredActions.every((id) => selectedActionIds.includes(id))
|
||||
conditions.requiredActions.every((id) => {
|
||||
if (allValidActionIds && !allValidActionIds.includes(id)) {
|
||||
return false
|
||||
}
|
||||
return selectedActionIds.includes(id)
|
||||
})
|
||||
|
||||
const meetsExcluded =
|
||||
!conditions.excludedActions ||
|
||||
@@ -148,9 +154,14 @@ export function findMatchingVariant(
|
||||
export async function getActionMessage(
|
||||
action: ButtonAction | ToggleAction,
|
||||
selectedActionIds: string[],
|
||||
allValidActionIds?: string[],
|
||||
): Promise<string> {
|
||||
if (action.conditionalMessages && action.conditionalMessages.length > 0) {
|
||||
const matchingConditional = findMatchingVariant(action.conditionalMessages, selectedActionIds)
|
||||
const matchingConditional = findMatchingVariant(
|
||||
action.conditionalMessages,
|
||||
selectedActionIds,
|
||||
allValidActionIds,
|
||||
)
|
||||
if (matchingConditional) {
|
||||
return (await matchingConditional.message()) as string
|
||||
}
|
||||
|
||||
@@ -103,6 +103,10 @@ const props = defineProps({
|
||||
type: Function,
|
||||
default: undefined,
|
||||
},
|
||||
maxVisibleOptions: {
|
||||
type: Number,
|
||||
default: undefined,
|
||||
},
|
||||
})
|
||||
|
||||
function getOptionLabel(option) {
|
||||
@@ -263,7 +267,7 @@ const isChildOfDropdown = (element) => {
|
||||
|
||||
.options {
|
||||
z-index: 10;
|
||||
max-height: 18.75rem;
|
||||
max-height: v-bind('maxVisibleOptions ? `calc(${maxVisibleOptions} * 3rem)` : "18.75rem"');
|
||||
overflow-y: auto;
|
||||
box-shadow:
|
||||
var(--shadow-inset-sm),
|
||||
|
||||
Reference in New Issue
Block a user