-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: custom fields * feat: manage incident types * feat: add custom fields * doc: add security policy * fix: use factory to create onboarding service * fix: slack integration commands * style: ui tweaks * feat: make datetime columns tz aware * feat: add some checks
- Loading branch information
Showing
76 changed files
with
3,384 additions
and
426 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Security Policy | ||
|
||
At Incidental, we prioritize the security of our open source project. If you discover a vulnerability, please report it by emailing [email protected] with a detailed description and steps to reproduce. We kindly request that you avoid public disclosure until we've had a chance to address the issue. | ||
|
||
We aim to acknowledge reports within 48 hours and provide updates weekly. | ||
|
||
Thank you for helping keep Incidental secure. |
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
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
import enum | ||
import typing | ||
|
||
from sqlalchemy import Boolean, Enum, ForeignKey, String, UnicodeText | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
|
||
from app.db import Base | ||
|
||
from .mixins import SoftDeleteMixin, TimestampMixin | ||
|
||
if typing.TYPE_CHECKING: | ||
from .form_field import FormField | ||
from .incident_field_value import IncidentFieldValue | ||
from .organisation import Organisation | ||
|
||
|
||
class InterfaceKind(str, enum.Enum): | ||
"""What we display the field as in the UI""" | ||
|
||
SINGLE_SELECT = "SINGLE_SELECT" | ||
MULTI_SELECT = "MULTI_SELECT" | ||
TEXT = "TEXT" | ||
TEXTAREA = "TEXTAREA" | ||
|
||
|
||
class FieldKind(str, enum.Enum): | ||
"""What type of data this field will contain""" | ||
|
||
USER_DEFINED = "USER_DEFINED" # from `available_options` field | ||
|
||
# core options | ||
INCIDENT_NAME = "INCIDENT_NAME" | ||
INCIDENT_TYPE = "INCIDENT_TYPE" | ||
INCIDENT_SEVERITY = "INCIDENT_SEVERITY" | ||
INCIDENT_STATUS = "INCIDENT_STATUS" | ||
INCIDENT_SUMMARY = "INCIDENT_SUMMARY" | ||
|
||
|
||
class Field(Base, TimestampMixin, SoftDeleteMixin): | ||
__prefix__ = "field" | ||
|
||
organisation_id: Mapped[str] = mapped_column( | ||
String(50), ForeignKey("organisation.id", ondelete="cascade"), nullable=False, index=True | ||
) | ||
label: Mapped[str] = mapped_column(UnicodeText, nullable=False) | ||
description: Mapped[str | None] = mapped_column(UnicodeText, nullable=True) | ||
interface_kind: Mapped[InterfaceKind] = mapped_column(Enum(InterfaceKind, native_enum=False), nullable=False) | ||
available_options: Mapped[list[str] | None] = mapped_column(JSONB, nullable=True) | ||
kind: Mapped[FieldKind] = mapped_column(Enum(FieldKind, native_enum=False), nullable=False) | ||
|
||
is_deletable: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False) | ||
is_editable: Mapped[bool] = mapped_column(Boolean, nullable=False) | ||
is_system: Mapped[bool] = mapped_column(Boolean, nullable=False) | ||
|
||
# relationships | ||
organisation: Mapped["Organisation"] = relationship("Organisation", back_populates="fields") | ||
form_fields: Mapped[list["FormField"]] = relationship("FormField", back_populates="field") | ||
incident_field_values: Mapped["IncidentFieldValue"] = relationship("IncidentFieldValue", back_populates="field") |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import typing | ||
|
||
from sqlalchemy import ForeignKey, String, UniqueConstraint | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
|
||
from app.db import Base | ||
|
||
from .mixins import SoftDeleteMixin, TimestampMixin | ||
|
||
if typing.TYPE_CHECKING: | ||
from .field import Field | ||
from .incident import Incident | ||
|
||
|
||
class IncidentFieldValue(Base, TimestampMixin, SoftDeleteMixin): | ||
__prefix__ = "ifv" | ||
|
||
incident_id: Mapped[str] = mapped_column( | ||
String(50), ForeignKey("incident.id", ondelete="cascade"), nullable=False, index=True | ||
) | ||
field_id: Mapped[str] = mapped_column(String(50), ForeignKey("field.id", ondelete="cascade"), index=True) | ||
|
||
# store values here, where value is stored depends on the field type | ||
value_text: Mapped[str | None] = mapped_column(String, nullable=True) | ||
value_single_select: Mapped[str | None] = mapped_column(String, nullable=True) | ||
value_multi_select: Mapped[list[str] | None] = mapped_column(JSONB, nullable=True) | ||
|
||
# relationships | ||
incident: Mapped["Incident"] = relationship("Incident", back_populates="incident_field_values") | ||
field: Mapped["Field"] = relationship("Field", back_populates="incident_field_values") | ||
|
||
__table_args__ = (UniqueConstraint("incident_id", "field_id"),) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from sqlalchemy import ForeignKey, String | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from app.db import Base | ||
|
||
from .mixins import SoftDeleteMixin, TimestampMixin | ||
|
||
|
||
class IncidentTypeField(Base, TimestampMixin, SoftDeleteMixin): | ||
"""Which fields are available for an incident type""" | ||
|
||
__prefix__ = "itf" | ||
|
||
incident_type_id: Mapped[str] = mapped_column( | ||
String(50), ForeignKey("incident_type.id", ondelete="cascade"), nullable=False, index=True | ||
) | ||
field_id: Mapped[str] = mapped_column( | ||
String(50), ForeignKey("field.id", ondelete="cascade"), nullable=False, index=True | ||
) |
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
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
Oops, something went wrong.