Skip to content

Commit

Permalink
based on new workflow data updated and necessary change simplemented
Browse files Browse the repository at this point in the history
Signed-off-by: Ankita Sahu <[email protected]>
  • Loading branch information
SAHU-01 committed Dec 16, 2024
1 parent c97087f commit ef4d455
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 124 deletions.
86 changes: 0 additions & 86 deletions .github/workflows/feature-list.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,3 @@
# name: Feature List Update

# on:
# schedule:
# - cron: '0 0 * * *' # Run every night at midnight UTC
# workflow_dispatch:

# permissions:
# contents: write
# actions: read

# jobs:
# check-and-update-features:
# runs-on: ubuntu-latest
# env:
# FEATURES_FILE: 'data/features.json'

# steps:
# - name: Checkout current repository
# uses: actions/checkout@v4

# - name: Restore cache
# id: cache-sha
# uses: actions/cache@v3
# with:
# path: .sha-cache
# key: feature-data-sha
# restore-keys: |
# feature-data-sha

# - name: Check for updates in source repository
# id: check-updates
# uses: actions/github-script@v7
# with:
# script: |
# const { data: sourceFile } = await github.rest.repos.getContent({
# owner: 'layer5labs',
# repo: 'meshery-extensions-packages',
# path: 'feature_data.json',
# ref: 'master'
# });

# // Store the latest commit SHA
# const latestSHA = sourceFile.sha;

# const fs = require('fs');

# // Check if we have a previous SHA
# let hasUpdates = true;
# const shaCachePath = '.sha-cache/latest-sha';
# if (fs.existsSync(shaCachePath)) {
# const lastSHA = fs.readFileSync(shaCachePath, 'utf8');
# hasUpdates = lastSHA !== latestSHA;
# }

# if (hasUpdates) {
# // Save the new SHA
# fs.mkdirSync('.sha-cache', { recursive: true });
# fs.writeFileSync(shaCachePath, latestSHA);

# // Decode and save the content
# const content = Buffer.from(sourceFile.content, 'base64').toString('utf8');

# // Create data directory if it doesn't exist
# fs.mkdirSync('data', { recursive: true });

# // Write the new content
# fs.writeFileSync(process.env.FEATURES_FILE, content);

# core.setOutput('has-updates', 'true');
# } else {
# core.setOutput('has-updates', 'false');
# }

# - name: Commit changes
# if: steps.check-updates.outputs.has-updates == 'true'
# uses: stefanzweifel/git-auto-commit-action@v5
# with:
# commit_message: "Updated feature data from source repository"
# file_pattern: ${{ env.FEATURES_FILE }}
# branch: master
# commit_options: "--signoff"
# commit_user_name: l5io
# commit_user_email: [email protected]
# commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>

name: Feature List

on:
Expand Down
8 changes: 5 additions & 3 deletions layouts/docs/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
{{ partial "sidebar.html" . }}
</aside>
<aside class="d-none d-xl-block col-xl-2 td-sidebar-toc d-print-none">
{{ partial "page-meta-links.html" . }} {{ partial "toc.html" . }} {{
partial "taxonomy_terms_clouds.html" . }}
{{ partial "page-meta-links.html" . }}
{{ partial "toc.html" . }}
{{ partial "taxonomy_terms_clouds.html" . }}
</aside>
<main class="col-12 col-md-9 col-xl-8 ps-md-5" role="main">
{{ partial "version-banner.html" . }}
Expand All @@ -35,7 +36,8 @@
</div>
{{ partial "footer.html" . }}
</div>
{{ partial "scripts.html" . }} {{ partial "image-modal.html" . }}
{{ partial "scripts.html" . }}
{{ partial "image-modal.html" . }}
</body>

</html>
60 changes: 25 additions & 35 deletions layouts/partials/feature-info.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,47 @@
{{ $currentPage := .Page.Permalink }}
{{ $features := .Site.Data.features }}
{{ $features := .Site.Data.feature_data }}
{{ if not $features }}
{{ $features = getJSON "features.json" }}
{{ $features = getJSON "feature_data.json" }}
{{ end }}

{{ $currentPage := .Page.Permalink }}

{{ if $features }}
{{ $groupedFeatures := dict }}
{{ range $features }}
{{ $docUrl := .documentation | default "" }}
{{ $docUrl := .docs | default "" }}
{{ $cleanDocUrl := (index (split $docUrl "#") 0) }}
{{ $currentPagePath := path.Clean (urls.Parse $currentPage).Path }}
{{ $cleanDocUrlPath := path.Clean (urls.Parse $cleanDocUrl).Path }}

{{ if eq $cleanDocUrlPath $currentPagePath }}
{{ $tier := index .entire_row "Subscription Tier" }}
{{ $feature := index .entire_row "Feature" }}
{{ $currentFeatures := index $groupedFeatures $tier | default "" }}
{{ $groupedFeatures = merge $groupedFeatures (dict $tier (printf "%s%s%s" $currentFeatures (cond (eq $currentFeatures
"") "" ", ") $feature)) }}
{{ if and (ne $docUrl "") (eq $cleanDocUrlPath $currentPagePath) }}
{{ $tiers := slice }}

{{ if .comparisonTiers.free }}
{{ $tiers = $tiers | append "Free" }}
{{ end }}

{{ if .comparisonTiers.teamDesigner }}
{{ $tiers = $tiers | append "Team Designer" }}
{{ end }}

{{ if ne (len $groupedFeatures) 0 }}
{{ $maxTier := "" }}
{{ $maxLength := 0 }}
{{ range $tier, $features := $groupedFeatures }}
{{ $length := len (split $features ", ") }}
{{ if gt $length $maxLength }}
{{ $maxTier = $tier }}
{{ $maxLength = $length }}
{{ if .comparisonTiers.teamOperator }}
{{ $tiers = $tiers | append "Team Operator" }}
{{ end }}

{{ if .comparisonTiers.enterprise }}
{{ $tiers = $tiers | append "Enterprise" }}
{{ end }}

{{ if len $tiers }}
<div class="matterinfo">
<div class="plan-support all-plans {{ lower $maxTier }}-plan">
<div class="plan-support all-plans">
<img src="/images/subscription.svg" alt="Icon" class="support-icon adaptive-icon" data-modal="false">
Subscription: <a href="https://layer5.io/pricing" class="tier-link" target="_blank"><span class="tier">{{ $maxTier
}}</span> </a>
</div>
{{ if gt (len $groupedFeatures) 1 }}
<div class="add-ons">
<strong>Add-ons:</strong>
{{ $first := true }}
{{ range $tier, $features := $groupedFeatures }}
{{ if ne $tier $maxTier }}
{{ if not $first }}, {{ end }}
{{ $first = false }}
{{ $features }} [<a href="https://layer5.io/pricing" class="tier-link" target="_blank"><span class="tier">{{ $tier
}}</span></a>]
{{ end }}
{{ end }}
Subscription: <a href="https://layer5.io/pricing" class="tier-link" target="_blank">
<span class="tier">{{ delimit $tiers ", " }}</span>
</a>
</div>
{{ end }}
</div>
{{ end }}
{{ end }}
{{ end }}
{{ end }}

0 comments on commit ef4d455

Please sign in to comment.