Skip to content

Commit

Permalink
Merge branch 'main' into no-veda-dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Jan 14, 2025
2 parents a269ea3 + 2f741b7 commit 201b7c4
Show file tree
Hide file tree
Showing 21 changed files with 257 additions and 174 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
name: Release Every Other Monday
on:
workflow_dispatch:
# Run action at 16:15 PM on Monday (UTC)
# schedule:
# @TODO: the schedule below is weekly. Do byweekly check.
# - cron: '15 16 * * 1'
schedule:
# At 10AM EST Monday
- cron: '0 15 * * 1'

# Sets the GITHUB_TOKEN permissions to allow release
permissions:
contents: write
env:
# Solutions is from https://github.com/wham/bi-weekly-action/blob/main/.github/workflows/bi-weekly-action.yml
# The date of the first run of the action. It has to be set to a date that is on the same weekday as the cron.
FIRST_RUN_DATE: 2025-01-06

# This action requires a GitHub app with content write access installed
# to bypass the main branch protection rule and dispatch the event to a different repo

jobs:
weekindex:
runs-on: ubuntu-latest
outputs:
weekindex: ${{ steps.calculate.outputs.weekindex }}
steps:
- name: Calculate weekdiff
id: calculate
run: |
current_date=$(date +%Y-%m-%d)
start=$(date -d ${{ env.FIRST_RUN_DATE }} +%s)
end=$(date -d $current_date +%s)
weekdiff=$(((end-start) / 60 / 60 / 24 / 7))
weekindex=$((weekdiff % 2))
echo "weekindex=$weekindex" >> "$GITHUB_OUTPUT"
echo "FIRST_RUN_DATE: ${{ env.FIRST_RUN_DATE }}" >> $GITHUB_STEP_SUMMARY
echo "current_date: $current_date" >> $GITHUB_STEP_SUMMARY
echo "weekdiff: $weekdiff" >> $GITHUB_STEP_SUMMARY
echo "weekindex: $weekindex" >> $GITHUB_STEP_SUMMARY
if [ $weekindex -eq 0 ]; then
echo "🟢 The week index is 0. The action is going to run." >> $GITHUB_STEP_SUMMARY
else
echo "🔴 The week index is 1. The action is going to be skipped." >> $GITHUB_STEP_SUMMARY
fi
release:
if: ${{ needs.weekindex.outputs.weekindex == 0 }}
runs-on: ubuntu-latest
needs:
- weekindex
steps:
- name: Generate a token
id: generate-token
Expand Down
3 changes: 1 addition & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
yarn lint-staged
yarn lint-staged
3 changes: 3 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
yarn ts-check
yarn test
2 changes: 1 addition & 1 deletion .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"release": true,
"releaseName": "v${version}",
"releaseNotes": null,
"autoGenerate": true,
"autoGenerate": false,
"preRelease": false,
"draft": false
}
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/components/common/blocks/block-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
getDatasetLayers
} from '$components/exploration/data-utils-no-faux-module';
import { useReconcileWithStacMetadata } from '$components/exploration/hooks/use-stac-metadata-datasets';
import { ProjectionOptions, VedaDatum, DatasetData } from '$types/veda';
import { ProjectionOptions, VedaData, DatasetData } from '$types/veda';
import { useVedaUI } from '$context/veda-ui-provider';

export const mapHeight = '32rem';
Expand Down Expand Up @@ -111,7 +111,7 @@ function validateBlockProps(props: MapBlockProps) {
}

interface MapBlockProps {
datasets: VedaDatum<DatasetData>;
datasets: VedaData<DatasetData>;
dateTime?: string;
compareDateTime?: string;
center?: [number, number];
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/common/blocks/lazy-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function LazyScrollyTelling(props) {
offset={100}
once
>
<ScrollytellingBlock {...props} />
<ScrollytellingBlock {...props} datasets={veda_faux_module_datasets} />
</LazyLoad>
);
}
Expand Down
36 changes: 15 additions & 21 deletions app/scripts/components/common/blocks/scrollytelling/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ import { CSSTransition, SwitchTransition } from 'react-transition-group';
import { CollecticonCircleXmark } from '@devseed-ui/collecticons';

import { MapRef } from 'react-map-gl';
import { datasets, ProjectionOptions } from 'veda';
import { BlockErrorBoundary } from '..';
import {
chapterDisplayName,
ChapterProps,
ScrollyChapter,
validateChapter
} from './chapter';
import { ChapterProps, ScrollyChapter, validateChapter } from './chapter';
import { ProjectionOptions, VedaData } from '$types/veda';
import { projectionDefault } from '$components/common/map/controls/map-options/projections';
import { userTzDate2utcString, utcString2userTzDate } from '$utils/date';
import { S_FAILED, S_SUCCEEDED } from '$utils/status';
Expand All @@ -41,11 +36,12 @@ import {
import { Layer } from '$components/exploration/components/map/layer';
import { MapLoading } from '$components/common/loading-skeleton';
import {
DatasetData,
EADatasetDataLayer,
DatasetStatus,
VizDataset,
VizDatasetSuccess
} from '$components/exploration/types.d.ts';
import { DatasetData } from '$types/veda';
import { useReconcileWithStacMetadata } from '$components/exploration/hooks/use-stac-metadata-datasets';
import {
formatSingleDate,
Expand Down Expand Up @@ -96,12 +92,6 @@ function useChapterPropsFromChildren(children): ScrollyChapter[] {
any
>[];

if (chapters.some((c) => c.type.displayName !== chapterDisplayName)) {
throw new HintedError('Invalid ScrollytellingBlock children', [
'You can only use <Chapter> inside <ScrollytellingBlock>'
]);
}

const chErrors = chapters.reduce<string[]>(
(acc, ch, idx) => acc.concat(validateChapter(ch.props, idx)),
[]
Expand Down Expand Up @@ -140,7 +130,8 @@ function getChapterLayerKey(ch: ScrollyChapter) {
*/
function useMapLayersFromChapters(
chList: ScrollyChapter[],
envApiStacEndpoint: string
envApiStacEndpoint: string,
datasets: VedaData<DatasetData>
): [ResolvedScrollyMapLayer[], string[]] {
// The layers are unique based on the dataset, layer id and datetime.
// First we filter out any scrollytelling block that doesn't have layer.
Expand All @@ -155,7 +146,6 @@ function useMapLayersFromChapters(

return Object.values(unique);
}, [chList]);

// Create an array of datasetId & layerId pairs which we can easily validate when creating
// the layers array.
const uniqueLayerRefs = useMemo(() => {
Expand All @@ -170,8 +160,10 @@ function useMapLayersFromChapters(
const reconciledVizDatasets = uniqueLayerRefs.map(
({ datasetId, layerId }) => {
const layers = datasets[datasetId]?.data.layers;

const layer = layers?.find((l) => l.id === layerId) as DatasetData | null;
// @TECH-DEBT: We are casting which we shouldn't, look into types and clean up because this is masking bad typing issues
const layer = layers?.find(
(l) => l.id === layerId
) as EADatasetDataLayer | null;

if (!layer) {
throw new Error(
Expand Down Expand Up @@ -257,7 +249,7 @@ const MAP_OPTIONS = {
};

function Scrollytelling(props) {
const { children } = props;
const { children, datasets } = props;

const { envApiStacEndpoint } = useVedaUI();

Expand All @@ -272,7 +264,8 @@ function Scrollytelling(props) {

const [resolvedLayers, resolvedStatus] = useMapLayersFromChapters(
chapterProps,
envApiStacEndpoint
envApiStacEndpoint,
datasets
);

const [activeChapter, setActiveChapter] = useState<ScrollyChapter | null>(
Expand Down Expand Up @@ -482,7 +475,8 @@ function Scrollytelling(props) {
}

Scrollytelling.propTypes = {
children: T.node
children: T.node,
datasets: T.any
};

export function ScrollytellingBlock(props) {
Expand Down
Loading

0 comments on commit 201b7c4

Please sign in to comment.