-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #838 from tailwarden/develop
v3.0.18 release 🚀
- Loading branch information
Showing
33 changed files
with
1,523 additions
and
766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ ARG TARGETPLATFORM | |
ARG BUILDPLATFORM | ||
ARG SEGMENT_WRITE_KEY | ||
ARG VERSION | ||
MAINTAINER mlabouardy <[email protected]> | ||
LABEL MAINTAINER="mlabouardy <[email protected]>" | ||
|
||
RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log | ||
|
||
|
@@ -15,4 +15,4 @@ RUN chmod +x /usr/bin/komiser && \ | |
mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 | ||
|
||
EXPOSE $PORT | ||
ENTRYPOINT ["komiser", "start"] | ||
ENTRYPOINT ["komiser", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 102 additions & 40 deletions
142
dashboard/components/inventory/components/view/alerts/InventoryViewAlerts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,123 @@ | ||
import { ToastProps } from '../../../../toast/hooks/useToast'; | ||
import useSlackAlerts from './hooks/useSlackAlerts'; | ||
import InventoryViewAlertsDisplay from './InventoryViewAlertsDisplay'; | ||
import InventoryViewAlertsEditSlackAlert from './InventoryViewAlertsEditSlackAlert'; | ||
import useAlerts from './hooks/useAlerts'; | ||
import InventoryViewAlertsDeleteAlert from './InventoryViewAlertsDeleteAlert'; | ||
import InventoryViewAlertDisplayAlerts from './InventoryViewAlertsDisplay'; | ||
import InventoryViewAlertsCreateOrEditAlert from './InventoryViewAlertsEditAlert'; | ||
import InventoryViewAlertsError from './InventoryViewAlertsError'; | ||
import InventoryViewAlertHasNoSlackAlerts from './InventoryViewAlertsHasNoSlackAlerts'; | ||
import InventoryViewAlertHasNoSlackIntegration from './InventoryViewAlertsHasNoSlackIntegration'; | ||
import InventoryViewAlertHasNoExistingAlerts from './InventoryViewAlertsHasNoAlerts'; | ||
import InventoryViewAlertsSkeleton from './InventoryViewAlertsSkeleton'; | ||
import InventoryViewAlertsChooseAlertMethod from './InventoryViewAlertsChooseAlertMethod'; | ||
|
||
type InventoryViewAlertsProps = { | ||
viewId: number; | ||
setToast: (toast: ToastProps | undefined) => void; | ||
}; | ||
|
||
const viewControllerOptions = { | ||
NO_ALERTS_OR_EXSITING_ALERTS: 0, | ||
CHOOSE_ALERT_METHOD: 1, | ||
CREATE_OR_EDIT_ALERT: 2, | ||
DELETE_ALERT: 3 | ||
}; | ||
|
||
function InventoryViewAlerts({ viewId, setToast }: InventoryViewAlertsProps) { | ||
const { | ||
loading, | ||
error, | ||
hasSlack, | ||
slackAlerts, | ||
hasNoSlackAlerts, | ||
editSlackAlert, | ||
currentSlackAlert, | ||
createOrEditSlackAlert, | ||
closeSlackAlert, | ||
hasAlerts, | ||
isSlackConfigured, | ||
alerts, | ||
alertsViewController, | ||
editAlert, | ||
alertMethod, | ||
currentAlert, | ||
setAlertMethodInAndIncrementViewController, | ||
setViewControllerToAlertsBaseView, | ||
setViewControllerToDeleteView, | ||
createOrEditAlert, | ||
incrementViewController, | ||
decrementViewController, | ||
closeAlert, | ||
fetchViewAlerts | ||
} = useSlackAlerts({ viewId }); | ||
|
||
if (loading) return <InventoryViewAlertsSkeleton />; | ||
} = useAlerts({ viewId }); | ||
|
||
if (error) | ||
if (loading) { | ||
return <InventoryViewAlertsSkeleton />; | ||
} | ||
if (error) { | ||
return <InventoryViewAlertsError fetchViewAlerts={fetchViewAlerts} />; | ||
} | ||
|
||
if (!hasSlack) return <InventoryViewAlertHasNoSlackIntegration />; | ||
|
||
if (hasNoSlackAlerts) | ||
return ( | ||
<InventoryViewAlertHasNoSlackAlerts | ||
createOrEditSlackAlert={createOrEditSlackAlert} | ||
/> | ||
); | ||
|
||
if (editSlackAlert) | ||
return ( | ||
<InventoryViewAlertsEditSlackAlert | ||
currentSlackAlert={currentSlackAlert} | ||
closeSlackAlert={closeSlackAlert} | ||
viewId={viewId} | ||
setToast={setToast} | ||
/> | ||
); | ||
switch (alertsViewController) { | ||
case viewControllerOptions.NO_ALERTS_OR_EXSITING_ALERTS: | ||
if (!hasAlerts) { | ||
return ( | ||
<InventoryViewAlertHasNoExistingAlerts | ||
incrementViewController={incrementViewController} | ||
/> | ||
); | ||
} | ||
if (editAlert) { | ||
return ( | ||
<InventoryViewAlertsCreateOrEditAlert | ||
alertMethod={alertMethod} | ||
setViewControllerOnSubmit={setViewControllerToAlertsBaseView} | ||
setViewControllerOnClickingBackButton={ | ||
setViewControllerToAlertsBaseView | ||
} | ||
setViewControllerOnDelete={setViewControllerToDeleteView} | ||
currentAlert={currentAlert} | ||
closeAlert={closeAlert} | ||
viewId={viewId} | ||
setToast={setToast} | ||
/> | ||
); | ||
} | ||
return ( | ||
<InventoryViewAlertDisplayAlerts | ||
alerts={alerts} | ||
createOrEditAlert={createOrEditAlert} | ||
setViewControllerOnAddAlert={incrementViewController} | ||
/> | ||
); | ||
|
||
return ( | ||
<InventoryViewAlertsDisplay | ||
slackAlerts={slackAlerts} | ||
createOrEditSlackAlert={createOrEditSlackAlert} | ||
/> | ||
); | ||
case viewControllerOptions.CHOOSE_ALERT_METHOD: | ||
return ( | ||
<InventoryViewAlertsChooseAlertMethod | ||
setAlertMethodInViewController={ | ||
setAlertMethodInAndIncrementViewController | ||
} | ||
setViewControllerOnClickingBackButton={decrementViewController} | ||
isSlackConfigured={isSlackConfigured} | ||
/> | ||
); | ||
case viewControllerOptions.CREATE_OR_EDIT_ALERT: | ||
return ( | ||
<InventoryViewAlertsCreateOrEditAlert | ||
alertMethod={alertMethod} | ||
setViewControllerOnSubmit={setViewControllerToAlertsBaseView} | ||
setViewControllerOnClickingBackButton={decrementViewController} | ||
setViewControllerOnDelete={incrementViewController} | ||
currentAlert={currentAlert} | ||
closeAlert={closeAlert} | ||
viewId={viewId} | ||
setToast={setToast} | ||
/> | ||
); | ||
case viewControllerOptions.DELETE_ALERT: | ||
return ( | ||
<InventoryViewAlertsDeleteAlert | ||
alertMethod={alertMethod} | ||
viewControllerOnCancelButton={decrementViewController} | ||
currentAlert={currentAlert} | ||
closeAlert={closeAlert} | ||
viewId={viewId} | ||
setToast={setToast} | ||
/> | ||
); | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
export default InventoryViewAlerts; |
92 changes: 92 additions & 0 deletions
92
...oard/components/inventory/components/view/alerts/InventoryViewAlertsChooseAlertMethod.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import Image from 'next/image'; | ||
import ChevronRightIcon from '../../../../icons/ChevronRightIcon'; | ||
import ArrowLeftIcon from '../../../../icons/ArrowLeftIcon'; | ||
import { AlertMethod } from './hooks/useAlerts'; | ||
|
||
type InventoryViewAlertsChooseAlertMethodProps = { | ||
setAlertMethodInViewController: (alertName: AlertMethod) => void; | ||
setViewControllerOnClickingBackButton: () => void; | ||
isSlackConfigured: boolean; | ||
}; | ||
|
||
function InventoryViewAlertsChooseAlertMethod({ | ||
setAlertMethodInViewController, | ||
setViewControllerOnClickingBackButton, | ||
isSlackConfigured | ||
}: InventoryViewAlertsChooseAlertMethodProps) { | ||
const webhookOptions = [ | ||
{ | ||
id: AlertMethod.SLACK, | ||
name: 'Slack', | ||
message: 'Get directly notified to take action', | ||
image: '/assets/img/others/slack.svg', | ||
alt: 'Slack logo' | ||
}, | ||
{ | ||
id: AlertMethod.WEBHOOK, | ||
name: 'Webhook', | ||
message: 'Integrate actions into your system', | ||
image: '/assets/img/others/custom-webhook.svg', | ||
alt: 'Webhook logo' | ||
} | ||
]; | ||
|
||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<div | ||
onClick={() => setViewControllerOnClickingBackButton()} | ||
className="flex cursor-pointer items-center gap-2 self-start text-sm text-black-900" | ||
> | ||
<ArrowLeftIcon width={24} height={24} /> | ||
Pick a Handler | ||
</div> | ||
|
||
{webhookOptions?.map(alert => ( | ||
<div key={alert.id}> | ||
<div | ||
onClick={() => { | ||
if (alert.id !== AlertMethod.SLACK || isSlackConfigured) { | ||
setAlertMethodInViewController(alert.id); | ||
} | ||
}} | ||
className={`flex cursor-pointer select-none items-center justify-between rounded-lg border border-black-170 p-6 hover:border-black-200 | ||
${ | ||
alert.id === AlertMethod.SLACK && !isSlackConfigured | ||
? 'pointer-events-none bg-gray-200' | ||
: '' | ||
}`} | ||
> | ||
<div className="flex items-center gap-4"> | ||
<Image src={alert.image} height={42} width={42} alt={alert.alt} /> | ||
<div className="flex flex-col"> | ||
<p className="font-semibold text-black-900">{alert.name}</p> | ||
<p className="text-xs text-black-400">{alert.message}</p> | ||
</div> | ||
</div> | ||
<ChevronRightIcon width={24} height={24} /> | ||
</div> | ||
|
||
{alert.id === AlertMethod.SLACK && !isSlackConfigured && ( | ||
<div className="mt-2"> | ||
<p className="text-xs text-black-400"> | ||
You have not set up your Slack integration. Learn how through | ||
our{' '} | ||
<a | ||
href="https://docs.komiser.io/docs/introduction/getting-started/#slack-integration-alerts" | ||
target="_blank" | ||
rel="noreferrer" | ||
className="text-primary" | ||
> | ||
<u>guide</u> | ||
</a> | ||
. | ||
</p> | ||
</div> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default InventoryViewAlertsChooseAlertMethod; |
81 changes: 81 additions & 0 deletions
81
dashboard/components/inventory/components/view/alerts/InventoryViewAlertsDeleteAlert.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import Image from 'next/image'; | ||
import Button from '../../../../button/Button'; | ||
import { AlertMethod, Alert } from './hooks/useAlerts'; | ||
import useEditAlerts from './hooks/useEditAlerts'; | ||
import { ToastProps } from '../../../../toast/hooks/useToast'; | ||
|
||
type InventoryViewAlertsDeleteAlertProps = { | ||
alertMethod: AlertMethod; | ||
closeAlert: (action?: 'hasChanges' | undefined) => void; | ||
viewId: number; | ||
setToast: (toast: ToastProps | undefined) => void; | ||
viewControllerOnCancelButton: () => void; | ||
currentAlert: Alert | undefined; | ||
}; | ||
|
||
function InventoryViewAlertsDeleteAlert({ | ||
alertMethod, | ||
viewId, | ||
closeAlert, | ||
setToast, | ||
viewControllerOnCancelButton, | ||
currentAlert | ||
}: InventoryViewAlertsDeleteAlertProps) { | ||
const { deleteAlert, loading } = useEditAlerts({ | ||
alertMethod, | ||
currentAlert, | ||
viewId, | ||
closeAlert, | ||
setToast | ||
}); | ||
return ( | ||
<div className="rounded-lg bg-komiser-100 p-6"> | ||
<div className="flex flex-col items-center gap-6"> | ||
<Image | ||
src="/assets/img/others/warning.svg" | ||
alt="Purplin" | ||
width={48} | ||
height={48} | ||
className="mx-auto flex-shrink-0" | ||
/> | ||
<div className="mb-8 flex flex-col items-center gap-2 px-4"> | ||
<p className="text-center font-semibold text-black-900"> | ||
Are you sure you want to delete this alert? | ||
</p> | ||
<p className="text-center text-sm text-black-400"> | ||
By deleting the “{currentAlert?.name}”{' '} | ||
{currentAlert?.isSlack ? 'slack' : 'webhook'} alert, you won’t | ||
receive any more notifications regarding the cost limit you set up. | ||
</p> | ||
</div> | ||
</div> | ||
<div className="flex items-center justify-end"> | ||
<div className="flex gap-4"> | ||
<Button | ||
style="ghost" | ||
size="lg" | ||
onClick={viewControllerOnCancelButton} | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
size="sm" | ||
style="delete" | ||
type="button" | ||
onClick={() => { | ||
viewControllerOnCancelButton(); | ||
if (currentAlert) { | ||
deleteAlert(currentAlert.id); | ||
} | ||
}} | ||
loading={loading} | ||
> | ||
Delete alert | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default InventoryViewAlertsDeleteAlert; |
Oops, something went wrong.