Skip to content

Commit

Permalink
feat: Identity file changes in Codebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Dec 11, 2023
1 parent 6ad715f commit 1741dbb
Show file tree
Hide file tree
Showing 43 changed files with 88 additions and 132 deletions.
3 changes: 1 addition & 2 deletions src/components/CustomCharts/HighchartHorizontalBarChart.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
external objToJson: 'a => Js.Json.t = "%identity"
module RawHBarChart = {
@react.component
let make = (~options: Js.Json.t) => {
Expand Down Expand Up @@ -159,7 +158,7 @@ let make = (
enabled: false,
},
}
defaultOptions->objToJson
defaultOptions->Identity.genericTypeToJson
}, (barChartData, theme))

<RawHBarChart options=barOption />
Expand Down
3 changes: 1 addition & 2 deletions src/components/CustomCharts/HighchartPieChart.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
external objToJson: 'a => Js.Json.t = "%identity"
%%raw(`require("./highcharts.css")`)
module RawPieChart = {
@react.component
Expand Down Expand Up @@ -106,7 +105,7 @@ let make = (
backgroundColor: theme === Dark ? "#202124" : "white",
},
}
defaultOptions->objToJson
defaultOptions->Identity.genericTypeToJson
}, (pieSeriesData, theme))

<RawPieChart options=barOption />
Expand Down
35 changes: 17 additions & 18 deletions src/components/CustomCharts/HighchartTimeSeriesChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ type domElement
open LogicUtils
open DictionaryUtils

external toJson: 'a => Js.Json.t = "%identity"

type ele
external toElement: Dom.element => ele = "%identity"

Expand Down Expand Up @@ -43,6 +41,7 @@ module TooltipString = {

type legendType = Table | Points
module LineChart1D = {
open Identity
@react.component
let make = (
~class: string="",
Expand Down Expand Up @@ -455,14 +454,14 @@ module LineChart1D = {
| Table =>
{
"enabled": {isMobileView ? false : showLegend},
}->DOMUtils.objToJson
}->genericObjectOrRecordToJson
| Points =>
{
"enabled": !isMultiDimensional,
"itemStyle": legendItemStyle(theme, "IBM Plex Sans", "12px"),
"itemHiddenStyle": legendHiddenStyle(theme),
"itemHoverStyle": legendItemStyle(theme),
}->DOMUtils.objToJson
}->genericObjectOrRecordToJson
}

let a: options<Js.Json.t> = {
Expand All @@ -489,13 +488,13 @@ module LineChart1D = {
tick.gridLine.attr(.
{
"stroke-width": "0",
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
)
} else {
tick.gridLine.attr(.
{
"stroke": strokeColor,
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
)
}
})
Expand All @@ -504,13 +503,13 @@ module LineChart1D = {
}
)->Some,
}->Some,
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
)
},
title: {
"text": chartTitle ? chartTitleText : "",
"style": chartTitleStyle,
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
credits: {
"enabled": false,
},
Expand All @@ -529,7 +528,7 @@ module LineChart1D = {
"style": {
"color": theme === Light ? "rgba(246, 248, 249, 1)" : "rgba(25, 26, 26, 1)",
},
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
plotOptions: Some(
{
"area": {
Expand All @@ -543,7 +542,7 @@ module LineChart1D = {
},
"lineWidth": 1.2,
"threshold": Js.Nullable.null,
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
"line": {
"pointStart": None,
"fillColor": None,
Expand All @@ -555,7 +554,7 @@ module LineChart1D = {
},
"lineWidth": 1.2,
"threshold": Js.Nullable.null,
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
"boxplot": {
"visible": false,
},
Expand All @@ -582,20 +581,20 @@ module LineChart1D = {
),
"mouseOver": None,
}),
}->DOMUtils.objToJson,
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
}->genericObjectOrRecordToJson,
),
xAxis: {
let defaultValue = {
"type": "datetime",
}->DOMUtils.objToJson
}->genericObjectOrRecordToJson
let defaultValue = if (
["run_date", "run_month", "run_week"]->Js.Array2.includes(groupKey)
) {
{
"type": "category",
"tickWidth": 0,
}->DOMUtils.objToJson
}->genericObjectOrRecordToJson
} else {
defaultValue
}
Expand Down Expand Up @@ -662,7 +661,7 @@ module LineChart1D = {
"title": {
"text": "",
"style": chartTitleStyle,
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
"labels": {
let labelsValue = {
"formatter": Some(
Expand All @@ -680,11 +679,11 @@ module LineChart1D = {
"letterSpacing": "1px",
"color": theme === Light ? "#4B5468" : "rgba(246, 248, 249, 0.25)",
},
}->DOMUtils.objToJson
}->genericObjectOrRecordToJson

labelsValue->getDictFromJsonObject->deleteKey("style")->Js.Json.object_
},
}->DOMUtils.objToJson,
}->genericObjectOrRecordToJson,
series: chartData,
}
a
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomExpandableTable.res
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let make = (
{
key: string_of_int(i),
options: obj.options,
selected: ev->formEventToStrArr,
selected: ev->Identity.formReactEventToArrayOfString,
}
} else {
obj
Expand Down
5 changes: 2 additions & 3 deletions src/components/DynamicTableUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ let tableHeadingClass = "font-bold text-xl text-black text-opacity-75 dark:text-
type view = Table | Card
@val @scope(("window", "location"))
external reload: unit => unit = "reload"
external convertToJsonDict: 't => Js.Dict.t<Js.Json.t> = "%identity"
external formEventToJsonArr: ReactEvent.Form.t => array<string> = "%identity"

let visibilityColFunc = (
~dateFormatConvertor: string => option<Js.Json.t>,
~jsonVal: option<Js.Json.t>,
Expand Down Expand Up @@ -54,7 +53,7 @@ let filteredData = (
switch item->Js.Nullable.toOption {
| Some(row) =>
// either to take this row or not if any filter is present then take row or else drop
let rowDict = row->convertToJsonDict
let rowDict = row->Identity.genericTypeToDictOfJson
let anyMatch = selectedFiltersKeys->Js.Array2.find(keys => {
// Selected fitler
switch Js.Dict.get(columnFilter, keys) {
Expand Down
4 changes: 1 addition & 3 deletions src/components/LocalFilters.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
let makeFieldInfo = FormRenderer.makeFieldInfo

external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"

module CheckLocalFilters = {
@react.component
let make = (
Expand Down Expand Up @@ -31,7 +29,7 @@ module CheckLocalFilters = {
None
}, [values])
let onChangeSelect = ev => {
let fieldNameArr = ev->formEventToStrArr
let fieldNameArr = ev->Identity.formReactEventToArrayOfString
let newlyAdded = Js.Array2.filter(fieldNameArr, newVal =>
!Js.Array2.includes(checkedFilters, newVal)
)
Expand Down
4 changes: 1 addition & 3 deletions src/components/RemoteFilter.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
let makeFieldInfo = FormRenderer.makeFieldInfo

external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"

@val @scope(("window", "location"))
external reload: unit => unit = "reload"
@val @scope(("window", "location"))
Expand Down Expand Up @@ -288,7 +286,7 @@ module CheckCustomFilters = {
let values = formState.values

let onChangeSelect = ev => {
let fieldNameArr = ev->formEventToStrArr
let fieldNameArr = ev->Identity.formReactEventToArrayOfString
let newlyAdded = Js.Array2.filter(fieldNameArr, newVal =>
!Js.Array2.includes(checkedFilters, newVal)
)
Expand Down
4 changes: 1 addition & 3 deletions src/components/SelectModal.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"

@react.component
let make = (
~modalHeading="Select Options",
Expand Down Expand Up @@ -66,7 +64,7 @@ let make = (
name: "cutomixedColumnsInput",
onBlur: _ev => (),
onChange: ev => {
let target = ev->formEventToStrArr
let target = ev->Identity.formReactEventToArrayOfString
Js.log2("ppp", target)
maxLengthArray(target, setValues)
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table.res
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ module TableHeadingCell = {
? {
key: string_of_int(i),
options: obj.options,
selected: ev->formEventToStrArr,
selected: ev->Identity.formReactEventToArrayOfString,
}
: obj
})
Expand Down
2 changes: 0 additions & 2 deletions src/components/Table.resi
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type filterDataType = TableUtils.filterDataType =
| Float(float, float)
| String
| DateTime

external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"
external jsonToStr: Js.Json.t => string = "%identity"
type textAlign = TableUtils.textAlign = Left | Right
type fontBold = bool
Expand Down
1 change: 0 additions & 1 deletion src/components/TableUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ type hideItem = {
value: string,
}

external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"
external jsonToStr: Js.Json.t => string = "%identity"

type textAlign = Left | Right
Expand Down
1 change: 0 additions & 1 deletion src/components/TableUtils.resi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type selectAllSubmitActions = {
disableParam: disableField,
}
type hideItem = {key: string, value: string}
external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"
external jsonToStr: Js.Json.t => string = "%identity"
type textAlign = Left | Right
type fontBold = bool
Expand Down
3 changes: 1 addition & 2 deletions src/components/form/SelectBoxCard.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module CustomViewSection = {
external formEventToInt: ReactEvent.Form.t => int = "%identity"
external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"
external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
external jsonArrToa: array<Js.Json.t> => array<'a> = "%identity"

Expand Down Expand Up @@ -52,7 +51,7 @@ module CustomViewSection = {
->ignore
}
} else {
let evArr = ev->formEventToStrArr
let evArr = ev->Identity.formReactEventToArrayOfString
for i in 0 to evArr->Js.Array2.length - 1 {
valueArrReversed
->Js.Array2.find(x => keyExtractor(x) == evArr[i]->Belt.Option.getWithDefault(""))
Expand Down
3 changes: 1 addition & 2 deletions src/components/priority-logics/AddPLGateway.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
external formEventToStrArr: ReactEvent.Form.t => array<string> = "%identity"
type gateway = PriorityLogicUtils.gateway

module GatewayView = {
Expand Down Expand Up @@ -105,7 +104,7 @@ let make = (
name: "gateways",
onBlur: _ev => (),
onChange: ev => {
let newSelectedOptions = ev->formEventToStrArr
let newSelectedOptions = ev->Identity.formReactEventToArrayOfString
if newSelectedOptions->Js.Array2.length === 0 {
gateWaysInput.onChange([]->Identity.anyTypeToReactEvent)
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/components/priority-logics/PriorityLogicUtils.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
type val =
StringArray(array<string>) | String(string) | IntArray(array<int>) | Int(int) | Bool(bool)

external tojsonObjTest: 'a => Js.Json.t = "%identity"

type gateway = {
gateway_name: string,
distribution: int,
Expand Down
1 change: 0 additions & 1 deletion src/entities/analytics/IntegrationsEntity.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
external toDict: 'a => Js.Dict.t<Js.Json.t> = "%identity"
let domain = "integrations"

open LogicUtils
Expand Down
9 changes: 0 additions & 9 deletions src/genericUtils/DOMUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ type event
external event: string => event = "Event"
@send external dispatchEvent: ('a, event) => unit = "dispatchEvent"
@send external postMessage: (window, Js.Json.t, string) => unit = "postMessage"

@val @scope(("window", "location")) external windowOrigin: string = "origin"
external toString: option<Js.Json.t> => string = "%identity"
external convertToStrDict: 't => Js.Json.t = "%identity"
external objToJson: {..} => Js.Json.t = "%identity"

external toJson: exn => Js.Json.t = "%identity"
external toRespJson: Fetch.Response.t => Js.Json.t = "%identity"
@get external keyCode: 'a => int = "keyCode"

external formEventToBoolean: ReactEvent.Form.t => bool = "%identity"
@send external querySelectorAll: (document, string) => array<Dom.element> = "querySelectorAll"
6 changes: 6 additions & 0 deletions src/genericUtils/Identity.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ external anyTypeToReactEvent: 'a => ReactEvent.Form.t = "%identity"
external arrofStringToReactEvent: array<string> => ReactEvent.Form.t = "%identity"
external jsonToNullableJson: Js.Json.t => Js.Nullable.t<Js.Json.t> = "%identity"
external jsonToReactDOMStyle: Js.Json.t => ReactDOM.style = "%identity"
external genericTypeToJson: 'a => Js.Json.t = "%identity"
external genericTypeToBool: 'a => bool = "%identity"
external formReactEventToBool: ReactEvent.Form.t => bool = "%identity"
external genericObjectOrRecordToJson: {..} => Js.Json.t = "%identity"
external genericTypeToDictOfJson: 't => Js.Dict.t<Js.Json.t> = "%identity"
external formReactEventToArrayOfString: ReactEvent.Form.t => array<string> = "%identity"
8 changes: 4 additions & 4 deletions src/hooks/AuthHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type sessionStorage = {

external dictToObj: Js.Dict.t<'a> => {..} = "%identity"
@val external atob: string => string = "atob"
external toJson: 'a => Js.Json.t = "%identity"
let getAgentId = _ => {
switch LocalStorage.getItem("agentId")->Js.Nullable.toOption {
| Some(str) => str
Expand Down Expand Up @@ -74,7 +73,7 @@ let getHeadersJson = (
key
->Js.String2.replace("-----BEGIN PUBLIC KEY-----\n", "")
->Js.String2.replace("\n-----END PUBLIC KEY-----", "")
->toJson,
->Identity.genericTypeToJson,
)
} else {
Js.Dict.set(headerObj, "X-RequestId", requestId->Js.Json.string)
Expand All @@ -94,7 +93,7 @@ let getHeadersJson = (
key
->Js.String2.replace("-----BEGIN PUBLIC KEY-----\n", "")
->Js.String2.replace("\n-----END PUBLIC KEY-----", "")
->toJson,
->Identity.genericTypeToJson,
)
}
}
Expand All @@ -110,11 +109,12 @@ let getHeadersJson = (
key
->Js.String2.replace("-----BEGIN PUBLIC KEY-----\n", "")
->Js.String2.replace("\n-----END PUBLIC KEY-----", "")
->toJson,
->Identity.genericTypeToJson,
)
}
}
}

headerObj->Js.Json.object_
}

Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Jose.res
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ external generateKeyPairs: 'a = "generateKeyPair"
@module("jose") external importPKCS8: ('a, string) => Js.Promise.t<key> = "importPKCS8"
@module("jose") external compactDecrypt: ('a, key) => Js.Promise.t<Js.Json.t> = "compactDecrypt"
@module("jose") external compactVerify: ('a, key) => Js.Promise.t<bool> = "compactVerify"
external toJson: 'a => Js.Json.t = "%identity"

let getKey = keyType => {
switch LocalStorage.getItem(keyType)->Js.Nullable.toOption {
| Some(str) => str
Expand Down
Loading

0 comments on commit 1741dbb

Please sign in to comment.