Skip to content

Commit

Permalink
Merge branch 'permRef' of https://github.com/iArchitSharma/meshery in…
Browse files Browse the repository at this point in the history
…to permRef
  • Loading branch information
iArchitSharma committed May 15, 2024
2 parents 4370d18 + 9906e33 commit 9e55af3
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 69 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/docs-keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch:
inputs:
spreadsheet_uri:
description: Link to the spreadsheet containing keys.
description: Link of the spreadsheet containing keys.
type: string
default: https://docs.google.com/spreadsheets/d/e/2PACX-1vQwzrUSKfuSRcpkp7sJTw1cSB63s4HCjYLJeGPWECsvqn222hjaaONQlN4X8auKvlaB0es3BqV5rQyz/pub?gid=64355745&single=true&output=csv
jobs:
Expand All @@ -15,31 +15,25 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GH_ACCESS_TOKEN }}
fetch-depth: 1
- name: Set spreadsheet_uri as environment variable
run: |
echo "spreadsheet_uri=" >> $GITHUB_ENV
if [ -n "${{ inputs.spreadshet_uri }}" ]; then
echo "spreadsheet_uri=${{ inputs.spreadshet_uri }}" >> $GITHUB_ENV
fi
run: echo "spreadsheet_uri=${{inputs.spreadsheet_uri}}" >> $GITHUB_ENV
if: inputs.spreadsheet_uri != ''

- name: Dump keys from the spreadsheet
run: |
curl -L "${{ inputs.spreadshet_uri }}" -o "./keys.csv"
- name: Exclude specific columns
run: |
# Keep columns 12, 14, and from 16 to the last one
awk -F',' 'BEGIN{OFS=","} {print $12, $14; for(i = 16; i <= NF; i++) printf "%s%s", $i, (i == NF ? ORS : OFS)}' keys.csv > keys_modified.csv
- name: Save to /docs/_data
curl -L "${{ env.spreadsheet_uri }}" -o "./keys.csv";
- name: Create permissions folder
run: |
[ ! -d "./docs/_data" ] && mkdir -p "./docs/_data";
mv keys_modified.csv ./docs/_data/keys.csv;
[ ! -d "./docs/assets/excel" ] && mkdir -p "./docs/assets/excel";
mv keys.csv docs/assets/excel/keys.csv;
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Added permissions keys, excluding specific columns."
commit_message: Added permissions keys.
branch: master
commit_options: '--signoff'
commit_user_name: l5io
commit_user_email: ci@layer5.io
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>author of the commit that triggered the run
2 changes: 2 additions & 0 deletions docs/_data/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@
links:
- title: Error Code Reference
url: reference/error-codes
- title: Permissions Reference
url: reference/permissions
- title: "REST & GraphQL APIs ↆ"
url: extensibility/api
children:
Expand Down
107 changes: 55 additions & 52 deletions docs/pages/reference/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,62 @@
layout: default
title: Permissions
permalink: reference/permissions
redirect_from: reference/permissions
language: en
list: exclude
type: Reference
abstract: List of default permissions.
---
<style>
.scrollable-container {
overflow-x: auto;
}
table {
border-collapse: collapse;
width: auto;
}
</style>

<!-- <table>
{% for row in site.data.keys %}
{% if forloop.first %}
<tr>
{% for pair in row %}
<th>{{ pair[0] }}</th>
{% endfor %}
</tr>
{% endif %}
{% tablerow pair in row %}
{{ pair[1] }}
{% endtablerow %}
{% endfor %}
</table> -->

<!-- Assuming the CSV data is stored in site.data.data -->
<table>
<thead>
<!-- If you want to include headers from the first row -->
<tr>
{% assign all_rows = site.data.keys %}
{% assign header_row = all_rows[1] %}
{% for header in header_row %}
<th>{{ header }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
<!-- Start loop from the second row -->
{% for row in all_rows %}
{% unless forloop.index == 1 %}
<tr>
<!-- Access each value in the row -->
{% for value in row %}
<td>{{ value }}</td>
{% endfor %}
</tr>
{% endunless %}
{% endfor %}
</tbody>

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Excel to HTML Table</title>
</head>
<body>

<table id="excelTable" border="1">

</table>

<script>

window.onload = function() {
const xhr = new XMLHttpRequest();
xhr.open('GET', '../../assets/excel/keys.csv', true);
xhr.responseType = 'arraybuffer';

xhr.onload = function() {
if (xhr.status === 200) {
const data = new Uint8Array(xhr.response);
const workbook = XLSX.read(data, { type: 'array' });
const sheet = workbook.Sheets[workbook.SheetNames[0]];
const htmlTable = XLSX.utils.sheet_to_html(sheet);

// Remove the first row from the HTML table
const tableElement = document.createElement('div');
tableElement.innerHTML = htmlTable;
tableElement.querySelector('table').deleteRow(0);
// Remove the second, fourth column from the HTML table
const rows = tableElement.querySelectorAll('tr');
rows.forEach(row => {
row.deleteCell(1);
row.deleteCell(2);
});
const modifiedHtmlTable = tableElement.innerHTML;

document.getElementById('excelTable').innerHTML = modifiedHtmlTable;
} else {
console.error('Failed to load Excel file! Status code: ' + xhr.status);
}
};

xhr.onerror = function() {
console.error('Failed to load Excel file!');
};

xhr.send();
};
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.4/xlsx.full.min.js"></script>
</body>
</html>

0 comments on commit 9e55af3

Please sign in to comment.