Skip to content

Commit

Permalink
Add Edit Webhooks Modal on NotificationsManagementModal
Browse files Browse the repository at this point in the history
Adding `BaseComponents` like `Forms` and `Buttons`

See: BIDS-3014
  • Loading branch information
MarcelBitfly committed Jul 23, 2024
1 parent 80c356a commit 64f90c6
Show file tree
Hide file tree
Showing 14 changed files with 461 additions and 18 deletions.
20 changes: 17 additions & 3 deletions frontend/assets/css/colors.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// When updating values here, please keep in mind that you might have to updated utils/colors.ts too

:root {
--dark-dark-grey: #5C4E4E;
--white: #ffffff;
--grey: #a5a5a5;
--medium-grey: #b3b3b3;
Expand All @@ -11,6 +12,7 @@
--light-grey-3: #d3d3d3;
--light-grey-4: #dddddd;
--light-grey-5: #eaeaea;
--light-grey-7: #C0C0C0;
--dark-grey: #5c4e4e;
--very-dark-grey: #362f32;
--asphalt: #484f56;
Expand Down Expand Up @@ -51,6 +53,7 @@
--text-color-inverted: var(--light-grey);
--text-color-disabled: var(--grey);
--text-color-discreet: var(--dark-grey);
--text-color--error: var(--flashy-red);

--button-color-active: var(--primary-orange);
--button-color-hover: var(--primary-orange-hover);
Expand All @@ -63,6 +66,11 @@
--button-text-color-disabled: var(--grey-4);
--button-text-color-dangerous: var(--white);

--button-secondary-background-color: var(--light-grey);
--button-secondary-background-color--hover: var(--light-grey-4 );
--button-secondary-color: var(--light-black);
--button-secondary-border-color: var(--light-grey-7);

--checkbox-background-color: var(--light-grey-4);

--container-background: var(--grey-4);
Expand Down Expand Up @@ -146,9 +154,15 @@
--button-color-dark-pattern: var(--light-grey);
--button-text-color-disabled: var(--light-grey);
--button-text-color-dangerous: var(--light-grey);

--checkbox-background-color: var(--light-grey);


--button-secondary-background-color: var(--very-dark-grey);
--button-secondary-background-color--hover: var(--light-black);
--button-secondary-color: var(--light-grey);
--button-secondary-border-color: var(--dark-dark-grey);

--checkbox-background-color: var(--very-dark-grey);
--checkbox-border-color: var(--dark-grey);

--container-background: var(--light-black);
--container-color: var(--grey-4);
--container-border-color: var(--dark-grey);
Expand Down
1 change: 1 addition & 0 deletions frontend/assets/css/prime.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
width: 20px;
height: 20px;
border-radius: var(--border-radius);
border: 1px solid var(--checkbox-border-color);
background: var(--checkbox-background-color);
&.p-highlight:not(:hover) {
background: var(--primary-color);
Expand Down
68 changes: 68 additions & 0 deletions frontend/components/bc/BcButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<script lang="ts" setup>
const props =defineProps<{
/**
* ℹ️ should only be used rarely, e.g. in cases where the action should not be triggerd twice
*/
isDisabled?: boolean,
/**
* ♿️ buttons that are aria-disabled are still perceivable by screen readers
* as they can still be focused on
*/
isAriaDisabled?: boolean,
variant?: 'secondary' // | 'red'
}>()
const shouldAppearDisabled = computed(() => props.isDisabled || props.isAriaDisabled)
</script>

<template>
<Button
type="button"
:disabled="isDisabled"
:aria-disabled="isAriaDisabled"
:class="{
'bc-button--secondary': !shouldAppearDisabled && variant === 'secondary',
'bc-button--disabled': shouldAppearDisabled,
// 'bc-button--red': variant === 'red'
}"
>
<slot/>
<span
v-if="$slots.icon"
class="bc-button__icon"
>
<slot name="icon"/>
</span>
</Button>

</template>

<style lang="scss" scoped>
.bc-button--secondary {
border-color: var(--button-secondary-border-color);
background-color: var(--button-secondary-background-color);
color: var(--button-secondary-color);
&:hover {
background-color: var(--button-secondary-background-color--hover);
border-color: var(--button-secondary-border-color);
}
&:active {
background-color: var(--button-secondary-background-color);
border-color: var(--button-secondary-border-color);
}
}
.bc-button--disabled {
&,
&:hover,
&:focus {
background-color: var(--button-color-disabled);
border-color: var(--button-color-disabled);
color: var(--button-text-color-disabled);
cursor: not-allowed;
}
}
.bc-button__icon {
margin-left: var(--padding-small);
}
</style>
20 changes: 12 additions & 8 deletions frontend/components/bc/BcTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ interface Props {
scrollContainer?: string // query selector for scrollable parent container
dontOpenPermanently?: boolean
hoverDelay?: number
tooltipWidth?: `${number}px` | `${number}%`
tooltipTextAlign?: 'left' | 'center' | 'right'
}
const toolTipTextAlignWithDefault = computed(() => props.tooltipTextAlign || 'center')
const props = defineProps<Props>()
const bcTooltipOwner = ref<HTMLElement | null>(null)
const bcTooltip = ref<HTMLElement | null>(null)
Expand Down Expand Up @@ -222,14 +226,14 @@ onUnmounted(() => {
>
<slot />
<Teleport v-if="isOpen" to="body">
<div class="bc-tooltip-wrapper" :style="pos" :class="tooltipClass">
<div class="bc-tooltip-wrapper" :style="{...pos, ...{ width: tooltipWidth }}" :class="tooltipClass">
<div
ref="bcTooltip"
class="bc-tooltip"
:class="classList"
@click="$event.stopImmediatePropagation()"
@mouseover="instantHoverTooltip(true)"
@mouseleave="bounceHoverTooltip(false, false, true)"
ref="bcTooltip"
class="bc-tooltip"
:class="classList"
@click="$event.stopImmediatePropagation()"
@mouseover="instantHoverTooltip(true)"
@mouseleave="bounceHoverTooltip(false, false, true)"
>
<slot name="tooltip">
<span>
Expand Down Expand Up @@ -296,7 +300,7 @@ onUnmounted(() => {
flex-wrap: wrap;
opacity: 0;
transition: opacity 1s;
text-align: center;
text-align: v-bind(toolTipTextAlignWithDefault);
padding: 9px 12px;
border-radius: var(--border-radius);
background: var(--tt-bg-color);
Expand Down
17 changes: 17 additions & 0 deletions frontend/components/bc/form/BcForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts" setup>
</script>

<template>
<form class="bc-form">
<slot/>
</form>
</template>

<style lang="scss" scoped>
.bc-form {
display: flex;
flex-direction: column;
row-gap: var(--padding-small);
}
</style>
23 changes: 23 additions & 0 deletions frontend/components/bc/form/BcFormRow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts" setup>
</script>

<template>
<div class="bc-form-row">
<slot/>
</div>
</template>

<style lang="scss" scoped>
.bc-form-row {
display: grid;
justify-content: space-between;
align-items: center;
grid-template-columns: 1fr auto;
row-gap: var(--padding-small);
grid-template-areas:
"label input"
"error error";
}
</style>
58 changes: 58 additions & 0 deletions frontend/components/bc/input/BcInputCheckbox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script lang="ts" setup>
import {
faInfoCircle
} from '@fortawesome/pro-regular-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import type { BcInputError } from '~/components/bc/input/BcInputError.vue';
const props = defineProps<{
error?: BcInputError,
label?: string,
infoText?: string,
}>()
const id = props.label ? useId() : undefined
const input = defineModel<boolean>()
</script>

<template>
<BcInputError :error>
<span>
<label
v-if="label"
class="label"
:for="id"
>
{{ label }}
</label>
<BcTooltip
v-if="infoText"
class="bc-input-checkbox__info"
tooltip-width="217px"
tooltip-text-align="left"
>
<FontAwesomeIcon :icon="faInfoCircle" />
<template #tooltip>
{{ infoText }}
</template>
</BcTooltip>
</span>
<Checkbox
v-model="input"
:input-id="id"
v-bind="$attrs"
binary
class="bc-input-checkbox__input"
/>
</BcInputError>
</template>

<style lang="scss">
.label{
cursor: pointer;
}
.bc-input-checkbox__info {
margin-left: var(--padding);
}
</style>
32 changes: 32 additions & 0 deletions frontend/components/bc/input/BcInputError.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script lang="ts" setup>
const idError = useId();
/**
* Spacing of error message will be removed by explicitly passing `false`.
* This should encourage to always think about the error message.
*/
export type BcInputError = false | string;
defineProps<{
error?: BcInputError;
}>();
</script>

<template>
<slot
:id-error
:aria-invalid="!!error"
:aria-describedby="idError"
/>
<div v-if="error !== false" :id="idError" class="bc-input-error">
{{ error }}
</div>
</template>

<style lang="scss" scoped>
.bc-input-error {
color: var(--text-color--error);
grid-column: span 2;
margin-left: auto; // 1.
--line-height--default: 1.2;
min-height: calc(16px * var(--line-height--default));
}
</style>
36 changes: 36 additions & 0 deletions frontend/components/bc/input/BcInputText.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script lang="ts" setup>
import type { BcInputError } from '~/components/bc/input/BcInputError.vue';
const idInput = useId();
const input = defineModel<string>();
defineProps<{
error?: BcInputError;
inputWidth?: `${number}px`;
label: string;
placeholder?: string;
type?: HTMLInputElement['type'];
}>();
</script>

<template>
<BcInputError :error>
<label :for="idInput">{{ label }}</label>
<InputText
:id="idInput"
v-model.trim="input"
v-bind="$attrs"
class="bc-input-text__input"
:placeholder
:type
/>
</BcInputError>
</template>

<style lang="scss">
// 1. the text is aligned right, but if the message is extra long
// it will start on the left side in the new line
.bc-input-text__input {
width: v-bind(inputWidth);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getGroupLabel } from '~/utils/dashboard/group'
import { type NotificationsManagementDashboardRow } from '~/types/notifications/management'
import type { DashboardType } from '~/types/dashboard'
import { useNotificationsManagementDashboards } from '~/composables/notifications/useNotificationsManagementDashboards'
import { NotificationsManagementModalWebhook } from '#components'
const { t: $t } = useI18n()
Expand Down Expand Up @@ -39,13 +40,23 @@ const wrappedDashboardGroups = computed(() => {
}
})
const onEdit = (col: 'delete' | 'subscriptions' | 'webhook' | 'networks', row: NotificationsManagementDashboardRow) => {
type Dialog = 'delete' | 'subscriptions' | 'webhook' | 'networks'
const activeDialog = ref<Dialog | ''>('')
const dialog = useDialog()
const onEdit = (col: Dialog, row: NotificationsManagementDashboardRow) => {
switch (col) {
case 'subscriptions':
alert('TODO: edit subscriptions' + row.group_id)
break
case 'webhook':
alert('TODO: edit webhook' + row.group_id)
activeDialog.value = col
dialog.open(NotificationsManagementModalWebhook, {
data: {
webhookUrl: row.webhook.url,
hasDiscord: row.webhook.via_discord,
},
})
break
case 'networks':
alert('TODO: edit networks' + row.group_id)
Expand Down
Loading

0 comments on commit 64f90c6

Please sign in to comment.