Skip to content

Commit

Permalink
feat(api): remove layout.json; fix gradle error (#42)
Browse files Browse the repository at this point in the history
* feat(api): remove layout.json; fix gradle error; reorder travis jobs for non-blocking failures - #40 

Co-authored-by: Christian Murphy <christian.murphy.42@gmail.com>
  • Loading branch information
cbeach47 and ChristianMurphy committed Mar 1, 2021
1 parent 0f1fdc6 commit bc5863a
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ install:
script:
- npm run lint
- npm test
- npm run ci:commitlint
- npx lerna run build
- npm run ci:commitlint # sometimes, it's OK for the commits to not be formatted correctly. Make sure everything else runs
cache:
directories:
- ~/.npm
34 changes: 34 additions & 0 deletions @uportal/context-menu-navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ Here's the guts of that html file:

- Note: The component includes bootstrap, so that you can use bootstrap's styles in your content slots. However, font-awesome has issues crossing the shadow-dom boundry, so that if you include an icon in the content slot, you also need to include a `<link>` to the font-awesome stylesheet from uPortal (or elsewhere if you wish).

### Logging

Makes use of the `debug` [utility](https://www.npmjs.com/package/debug#browser-support). The handle is `up:context-nav-menu`.

To enable, navigate to your console and type `localStorage.debug="up:context-nav-menu"`. Note, you can enable multiple `debug` loggers with wild cards and a CSV, such as `localStorage.debug="up:*,sockjs-client:websocket"`.

To disable, use: `localStorage.debug=""`.

### Portlet Definitions

While the portlet layout in the menu will be determined by `layout.json`, only portlets that have a portlet parameter of `widgetType` will have a context or flyout area rendered. The `widgetType` is checked when building the menu, but in essence is passed through to the `Widget Renderer`.

To customize the context / flyout area for a portlet in the `context-menu`, add a `widgetTemplate` portlet parameter. The field can be HTML.

Note: The HTML is directly rendered onto the screen without sanitization. For this reason, use care when customizing the `widgetTemplate`s.

Example portlet parameters to render a context / flyout area in the `context-menu`:

```html
<parameter>
<name>widgetTemplate</name>
<value
><![CDATA[ <div> <span>Check out the latest business cartoon. Click on the link below! <a
href="/uPortal/p/daily-business-cartoon-4"><img
src="https://raw.githubusercontent.com/Jasig/uPortal/master/docs/images/uPortal-logo.jpg"
alt="uP"/></a> </span> </div>]]>
</value>
</parameter>
<parameter>
<name>widgetType</name>
<value>generic</value>
</parameter>
```

##### Notice

We have a `/proxy/` leading the `oidc-url` attribute. This is a developer convenience to be able to query against your local running instance of uPortal. The proxy is configured in `package.json`:
Expand Down
62 changes: 47 additions & 15 deletions @uportal/context-menu-navigation/src/components/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@
>
<WidgetRenderer
class="portlet-content"
:template="
portletContent
? portletContent.widgetTemplate || portletContent.description
: ''
"
:config="portletContent.widgetConfig"
:url="portletContent.widgetUrl"
:type="portletContent.widgetType"
:template="cleanWidgetTemplate"
:url="portletContent.parameters.widgetUrl"
:type="portletContent.parameters.widgetType"
/>
</div>
</li>
Expand All @@ -51,6 +46,8 @@
</template>
<script>
import WidgetRenderer from '@uportal/content-renderer/src/components/WidgetRenderer';
import debugFactory from 'debug';
const debugLogger = debugFactory('up:context-nav-menu');
export const keyCodes = {
13: 'enter',
Expand Down Expand Up @@ -82,10 +79,6 @@ export default {
};
}
},
registry: {
type: Array,
default: () => []
},
isOpen: {
type: Boolean,
default: false
Expand Down Expand Up @@ -169,14 +162,53 @@ export default {
);
},
portletContent() {
return this.registry
? this.registry.find(portlet => portlet.fname === this.selected)
: {};
const selDetails = this.contentItemDetails;
if (selDetails) {
const retVal =
selDetails.parameters && selDetails.parameters.widgetType ? selDetails : false;
debugLogger(
'portletContent: [',
this.selected,
']. retVal=[',
retVal,
']. Selected details:'
);
debugLogger(selDetails);
return retVal;
} else {
debugLogger('portletContent: [', this.selected, ']. No selected details found.');
return false;
}
},
contentRegistry() {
return this.tab.content
.reduce((collection, group) => [...collection, ...group.content], [])
.map(c => c.fname);
},
contentItemDetails() {
if (this.selected) {
return this.tab.content
.reduce((collection, group) => [...collection, ...group.content], [])
.find(c => c.fname == this.selected);
} else {
return this.selected;
}
},
cleanWidgetTemplate() {
const escapedXmlMapping = {
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&apos;': "'",
'&amp;': '&'
};
const wTemplate = this.contentItemDetails?.parameters?.widgetTemplate;
if (wTemplate) {
return wTemplate.replace(/(&quot;|&lt;|&gt;|&apos;|&amp;)/g, function(str, marker) {
return escapedXmlMapping[marker];
});
}
return this.contentItemDetails?.description;
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
? 'dropleft'
: 'dropright'
"
:registry="registry"
></context-menu>
</li>
</ul>
Expand All @@ -44,6 +43,8 @@ import oidc from '@uportal/open-id-connect';
import Vue from 'vue';
import AsyncComputed from 'vue-async-computed';
import ky from 'ky';
import debugFactory from 'debug';
const debugLogger = debugFactory('up:context-nav-menu');
import ContextMenu from './ContextMenu';
Expand Down Expand Up @@ -71,10 +72,6 @@ export default {
layoutApiUrl: {
type: String,
default: '/uPortal/api/v4-3/dlm/layout.json'
},
layoutDocUrl: {
type: String,
default: '/uPortal/api/layoutDoc'
}
},
methods: {
Expand All @@ -98,6 +95,8 @@ export default {
},
mounted() {
document.addEventListener('click', this.handleOutsideClick, false);
debugLogger('Mounted Context-Nav-Menu');
},
computed: {
ignoreFolders() {
Expand Down Expand Up @@ -132,26 +131,6 @@ export default {
tabs: []
}
}
},
registry: {
async get() {
const { layoutDocUrl, debug } = this;
try {
const headers = debug
? {}
: {
Authorization: 'Bearer ' + (await oidc()).encoded,
'content-type': 'application/jwt'
};
return (await ky.get(layoutDocUrl, { headers }).json()).layout;
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
return {};
}
},
default: []
}
}
};
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.

0 comments on commit bc5863a

Please sign in to comment.